您好,登錄后才能下訂單哦!
本文源碼:GitHub·點這里 || GitEE·點這里
Linux:centos7 三臺
三臺Linux服務
192.168.72.129
192.168.72.130
192.168.72.131
Redis:redis-4.0.14
[root@localhost local]# cd /usr/local/
[root@localhost local]# mkdir mysoft
[root@localhost mysoft]# cd /usr/local/mysoft/
[root@localhost mysoft]# ll
total 1704
-rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz
[root@localhost mysoft]# tar -zxvf redis-4.0.14.tar.gz
[root@localhost mysoft]# ll
total 1708
drwxrwxr-x. 6 root root 4096 Mar 19 00:23 redis-4.0.14
-rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz
[root@localhost mysoft]# cd redis-4.0.14/
[root@localhost redis-4.0.14]# make MALLOC=libc
[root@localhost redis-4.0.14]# cd src && make install
[root@localhost redis-4.0.14]# cd src
[root@localhost src]# ./redis-server
修改redis.conf
daemonize yes
[root@localhost redis-4.0.14]# ./src/redis-server redis.conf
11320:C 05 May 14:26:31.053 # Redis is starting
11320:C 05 May 14:26:31.053 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11320, just started
11320:C 05 May 14:26:31.053 # Configuration loaded
[root@localhost redis-4.0.14]# ps -aux |grep redis
root 11321 0.1 0.1 141840 2028 ? Ssl 14:26 0:00 ./src/redis-server *:6379
root 11338 0.0 0.0 112708 980 pts/1 S+ 14:27 0:00 grep --color=auto redis
[root@localhost redis-4.0.14]# kill -9 11321
[root@localhost init.d]# cd /etc
[root@localhost etc]# mkdir redis
[root@localhost etc]# cp /usr/local/mysoft/redis-4.0.14/redis.conf /etc/redis/6379.conf
[root@localhost etc]# cd redis/
[root@localhost redis]# ll
total 60
-rw-r--r--. 1 root root 58767 May 5 14:36 redis-6379.conf
[root@localhost redis]# cp /usr/local/mysoft/redis-4.0.14/utils/redis_init_script /etc/init.d/redisd
[root@localhost redis]# chkconfig redisd on # 開機啟動命令
[root@localhost redis]# service redisd start
Starting Redis server...
3163:C 05 May 14:59:13.872 # Redis is starting
3163:C 05 May 14:59:13.872 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=3163, just started
3163:C 05 May 14:59:13.872 # Configuration loaded
[root@localhost redis]# service redisd stop
Stopping ...
Waiting for Redis to shutdown ...
Redis stopped
[root@localhost ~]# ps -aux |grep redis
root 987 0.1 0.1 141836 2012 ? Ssl 15:02 0:00 /usr/local/bin/redis-server *:6379
root 2966 0.0 0.0 112712 980 pts/1 S+ 15:04 0:00 grep --color=auto redis
關閉防火墻,或者開放6379端口
firewalld的基本使用
啟動: systemctl start firewalld
關閉: systemctl stop firewalld
查看狀態: systemctl status firewalld
開機禁用 : systemctl disable firewalld
開機啟用 : systemctl enable firewalld
修改redis.conf 配置
注釋掉:# bind 127.0.0.1
修改保護模式:protected-mode no
192.168.72.129 主服務
192.168.72.130 從服務
192.168.72.131 從服務
requirepass 123456
masterauth 123456
requirepass 123456
slaveof 192.168.72.129 6379
masterauth 123456
protected-mode no
# sentinel monitor代表監控
# mymaster代表服務器的名稱,可以自定義,
# 192.168.72.129代表監控的主服務器,6379代表端口,
# 2 標識 >=2 哨兵認為主服務器不可用,執行failover操作。
sentinel monitor mymaster 192.168.72.129 6379 2
sentinel auth-pass mymaster 123456
先主服務,后從服務
[root@localhost src]# ./redis-server ../redis.conf
[root@localhost src]# ./redis-sentinel ../sentinel.conf
沒錯,就是這樣搭建完畢了!
GitHub·地址
https://github.com/cicadasmile/linux-system-base
GitEE·地址
https://gitee.com/cicadasmile/linux-system-base
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。