- 利用不同的 port ,啟動多個 Redis 服務!
- 架設 Redis Server ,請參考這一篇!
-
複製主要設定檔:
# cp -a /etc/redis.conf /etc/redis6479.conf
-
編修設定檔 /etc/redis6479.conf:
# vim /etc/redis6479.conf (修改下列項目...) port 6479 tcp-backlog 611 pidfile /var/run/redis_6479.pid logfile /var/log/redis/redis_6479.log
-
修正設定檔 /etc/redis6479.conf 權限:
# chown redis /etc/redis6479.conf
-
切換到系統服務目錄,修改設定檔:
# cd /usr/lib/systemd/system/ # cp -a redis.service redis6479.service # vim redis6479.service (修改下列項目...) ExecStart=/usr/bin/redis-server /etc/redis6479.conf --daemonize no ExecStop=/usr/libexec/redis-shutdown redis6479
-
切換到系統服務目錄的設定目錄,新增設定目錄:
#cd /etc/systemd/system/ # cp -a redis.service.d/ redis6479.service.d/
-
新增記錄檔:
#touch /var/log/redis/redis_6479.log # chown redis.redis /var/log/redis/redis_6479.log
-
SELinux 的設定與修正:
#chcon --reference=/etc/redis.conf /etc/redis6479.conf #chcon --reference=/usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis6479.service #chcon -R --reference=/etc/systemd/system/redis.service.d/ /etc/systemd/system/redis6479.service.d/ #chcon --reference=/var/log/redis/redis.log /var/log/redis/redis_6479.log #semanage port -a -t redis_port_t -p tcp 6479 #semanage port -l | grep redis
-
防火牆設定:
#firewall-cmd --permanent --add-port=6479/tcp #firewall-cmd --reload
-
啟動服務:
#systemctl enable redis6479.service # systemctl start redis6479.service # systemctl status redis6479.service -l
-
測試服務:
# redis-cli -p 6479 -a 123456 127.0.0.1:6479> exit
參考文獻:
- https://www.cnyunwei.cc/archives/996
- https://read01.com/eE2GGK.html http://wangxin123.com/2016/09/18/Redis%E5%A4%9A%E5%AE%9E%E4%BE%8B%E5%8F%8A%E4%B8%BB%E4%BB%8E%E6%90%AD%E5%BB%BA/