#安装编译环境[root@localhost ~]# yum install gcc gcc-c++ make -y#远程挂载源码包[root@localhost ~]# mount.cifs //192.168.142.1/redis /mnt
Password for root@//192.168.142.1/redis:
#解压源码包[root@localhost ~]# cd /mnt[root@localhost mnt]# tar zxvf redis-5.0.7.tar.gz -C /opt#编译与安装[root@localhost mnt]# cd /opt/redis-5.0.7/[root@localhost redis-5.0.7]# make[root@localhost redis-5.0.7]# make PREFIX=/usr/local/redis/ install#建立服务命令软链接到系统[root@localhost redis-5.0.7]# ln -s /usr/redis/bin/* /usr/local/bin/#切入utils目录[root@localhost redis-5.0.7]# cd /opt/redis-5.0.7/utils/#执行启动脚本[root@localhost utils]# ./install_server.sh#以下内容,默认回车即可
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [] /usr/local/redis/bin/redis-server
#此处需手动指定扩展目录路径/usr/local/redis/bin/redis-server#使用进程控制启动服务[root@localhost utils]# /etc/init.d/redis_6379 start
Starting Redis server...
#配置redis的6379.conf文件,追加监听地址[root@localhost utils]# vim /etc/redis/6379.conf #注释第70行的监听127地址,已监听所有地址#bind 127.0.0.1 #去掉第89行注释关闭安全保护
protected-mode no
#去掉第93行注释,开启端口6379
port 6379
#去掉第137行注释,以独立进程启动
daemonize yes#去掉第833行注释,开启群集功能
cluster-enabled yes#去掉第841行注释,群集名称文件设置
cluster-config-file nodes-6379.conf
#去掉第847行注释,群集超时时间设置
cluster-node-timeout 15000
#去掉第700行注释,开启aof持久化
appendonly yes#重启服务[root@localhost utils]# /etc/init.d/redis_6379 restart
Stopping ...
Redis stopped
Starting Redis server...