1、redis6.0.9下载地址 https://download.redis.io/releases/redis-6.0.9.tar.gz
[root@localhost ~]# wget https://download.redis.io/releases/redis-6.0.9.tar.gz
2、安装依赖gcc
# 查看gcc版本是否在9.3以上,centos7.6默认安装4.8.5 [root@localhost ~]#gcc -v # 升级gcc到9.3及以上,如下: 升级到gcc 9.3: [root@localhost ~]#yum -y install centos-release-scl [root@localhost ~]#yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils [root@localhost ~]#scl enable devtoolset-9 bash 需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。 如果要长期使用gcc 9.3的话: [root@localhost ~]#echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile 这样退出shell重新打开就是新版的gcc了 以下其他版本同理,修改devtoolset版本号即可。
3、下载的压缩包上传到/usr/local目录下
[root@localhost ~]#tar zxf redis-6.0.9.tar.gz [root@localhost ~]#cd redis-6.0.9 [root@localhost redis-6.0.9]#make&&make install PREFIX=/usr/local/redis
4、启动Redis
(1) 前台启动
[root@localhost redis-6.0.9]# /usr/local/redis/bin/redis-server
(2) 后台启动
从 redis 的源码目录中复制 redis.conf 到 redis 的安装目录
[root@localhost redis-6.0.9]# cd redis-6.0.9
[root@localhost redis-6.0.9]# cp redis.conf /usr/local/redis/bin/
5.修改redis.conf配置文件
(1) 修改 redis.conf 文件,把 daemonize no 改为 daemonize yes
(2) 注释掉 # bind 127.0.0.1,并修改 protected-mode yes 改为 protected-mode no
(3) 设置密码
#requirepass 123456 (注释不设置密码)
##启动命令 [root@localhost redis-6.0.9]#/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
## 停止命令 [root@localhost redis-6.0.9]#/usr/local/redis/bin/redis-cli shutdown
6、设置redis服务开机自启动
(1)编写脚本
[root@localhost ~]#vim /etc/init.d/redis
创建脚本文件
#!/bin/bash #chkconfig: 22345 10 90 #description: Start and Stop redis REDISPORT=6379 EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis.pid CONF="/usr/local/redis/bin/redis.conf" case "$1" in start) if [ -f $PIDFILE ];then echo "$PIDFILE exists,process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi ;; stop) if [ ! -f $PIDFILE ];then echo "$PIDFILE does not exist,process is not running" else PID=$(cat $PIDFILE) echo "Stopping..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart) "$0" stop sleep 3 "$0" start ;; *) echo "Please use start or stop or restart as first argument" ;; esac
(2) 写完记得修改文件权限
[root@localhost ~] #chmod +x /etc/init.d/redis
(3) 把脚本添加到系统服务列表
[root@localhost ~] #chkconfig --add redis [root@localhost ~] #chkconfig redis on [root@localhost ~] #chkconfig --list //查看所有注册的脚本文件
7、RedisDesktopManager 工具下载地址