#安裝編譯環境[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...