Redis主从集群搭建三主三从的集群为Spring-boot连接提供Redis服务-----Redis

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.92.129  netmask 255.255.255.0  broadcast 192.168.92.255
        inet6 fe80::5d0e:f975:2a1e:b6d2  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:8f:1b:2b  txqueuelen 1000  (Ethernet)
        RX packets 135  bytes 30577 (29.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 144  bytes 15221 (14.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 68  bytes 5916 (5.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 5916 (5.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:55:d3:7b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@localhost ~]# redis-server /myredis/redis6379.conf 
[root@localhost ~]# redis-cli -a abc123 -p 6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
 1) "order"
 2) "zet1"
 3) "k4"
 4) "k5"
 5) "hash1"
 6) "k1"
 7) "str2"
 8) "str3"
 9) "str1"
10) "\xac\xed\x00\x05t\x00\aord:168"
11) "k2"
12) "mylist"
127.0.0.1:6379> 
[root@localhost ~]# redis-cli -a abc123 -p 6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get "\xac\xed\x00\x05t\x00\aord:168"
"\xac\xed\x00\x05t\x000\xe4\xba\xac\xe4\xb8\x9c\xe8\xae\xa2\xe5\x8d\x95db9ed0b6-2898-4077-8b93-a2622c56c238"
127.0.0.1:6379> get \xac\xed\x00\x05t\x00\aord:168
(nil)
127.0.0.1:6379> get ord:186
"\xe4\xba\xac\xe4\xb8\x9c\xe8\xae\xa2\xe5\x8d\x9568b2a2da-3180-4a62-b71b-2a8f7e182e00"
127.0.0.1:6379> keys *
 1) "order"
 2) "zet1"
 3) "k4"
 4) "k5"
 5) "hash1"
 6) "ord:186"
 7) "k1"
 8) "str2"
 9) "str3"
10) "str1"
11) "\xac\xed\x00\x05t\x00\aord:168"
12) "k2"
13) "mylist"
127.0.0.1:6379> quit
[root@localhost ~]# redis-cli -a abc123 -p 6379 --raw
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get ord:186
京东订单68b2a2da-3180-4a62-b71b-2a8f7e182e00
127.0.0.1:6379> get ord:808
"京东订单621b2615-ddd0-4e19-8d97-22c79578594b"
127.0.0.1:6379> keys *
ord:245
order
zet1
k4
ord:808
k5
hash1
ord:186
k1
str2
str3
str1
��tord:168
k2
mylist
127.0.0.1:6379> shutdown
not connected> quit
[root@localhost ~]# ps -ef|grep redis
root       3052   2478  0 10:58 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6381.conf 
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6382.conf 
[root@localhost ~]# ps -ef|grep redis
root       3123      1  0 11:02 ?        00:00:00 redis-server 0.0.0.0:6381 [cluster]
root       3135      1  0 11:02 ?        00:00:00 redis-server 0.0.0.0:6382 [cluster]
root       3147   2478  0 11:02 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# redis-cli -a abc123 -p 6381 -c --raw
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6381> cluster nodes
2eabe702c6bba38aee780477fab74bc4969d9bf3 192.168.92.129:6382@16382 slave 30b1f7bfccd93049117e1dab1cd6385eaf800015 0 1706152114315 5 connected
30b1f7bfccd93049117e1dab1cd6385eaf800015 192.168.92.131:6385@16385 master,fail - 1706151760733 1706151758814 5 connected 12288-16383
a5757758fd0bdd8106e10905bbd1674c574f10c1 192.168.92.131:6386@16386 slave,fail 1fca4878cd2a2a4fe055003f53d53c84cb589859 1706151761337 1706151758814 3 connected
69d920127eec13adc0d9fcaf0e9448a80d1a4803 192.168.92.130:6384@16384 slave,fail ee718fe879729ec1f961b08c4342c78537997ab4 1706151759726 1706151758814 10 connected
1fca4878cd2a2a4fe055003f53d53c84cb589859 192.168.92.130:6383@16383 master,fail - 1706151761337 1706151758814 3 connected 6827-10922
ee718fe879729ec1f961b08c4342c78537997ab4 192.168.92.129:6381@16381 myself,master - 0 1706152114000 10 connected 0-6826 10923-12287
127.0.0.1:6381> cluster nodes
2eabe702c6bba38aee780477fab74bc4969d9bf3 192.168.92.129:6382@16382 slave 30b1f7bfccd93049117e1dab1cd6385eaf800015 0 1706152180828 5 connected
30b1f7bfccd93049117e1dab1cd6385eaf800015 192.168.92.131:6385@16385 master - 0 1706152180000 5 connected 12288-16383
a5757758fd0bdd8106e10905bbd1674c574f10c1 192.168.92.131:6386@16386 slave 1fca4878cd2a2a4fe055003f53d53c84cb589859 0 1706152180123 3 connected
69d920127eec13adc0d9fcaf0e9448a80d1a4803 192.168.92.130:6384@16384 slave ee718fe879729ec1f961b08c4342c78537997ab4 0 1706152178812 10 connected
1fca4878cd2a2a4fe055003f53d53c84cb589859 192.168.92.130:6383@16383 master - 0 1706152179518 3 connected 6827-10922
ee718fe879729ec1f961b08c4342c78537997ab4 192.168.92.129:6381@16381 myself,master - 0 1706152178000 10 connected 0-6826 10923-12287

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.92.129  netmask 255.255.255.0  broadcast 192.168.92.255
        inet6 fe80::5d0e:f975:2a1e:b6d2  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:8f:1b:2b  txqueuelen 1000  (Ethernet)
        RX packets 135  bytes 30577 (29.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 144  bytes 15221 (14.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 68  bytes 5916 (5.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 5916 (5.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:55:d3:7b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@localhost ~]# redis-server /myredis/redis6379.conf 
[root@localhost ~]# redis-cli -a abc123 -p 6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
 1) "order"
 2) "zet1"
 3) "k4"
 4) "k5"
 5) "hash1"
 6) "k1"
 7) "str2"
 8) "str3"
 9) "str1"
10) "\xac\xed\x00\x05t\x00\aord:168"
11) "k2"
12) "mylist"
127.0.0.1:6379> 
[root@localhost ~]# redis-cli -a abc123 -p 6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get "\xac\xed\x00\x05t\x00\aord:168"
"\xac\xed\x00\x05t\x000\xe4\xba\xac\xe4\xb8\x9c\xe8\xae\xa2\xe5\x8d\x95db9ed0b6-2898-4077-8b93-a2622c56c238"
127.0.0.1:6379> get \xac\xed\x00\x05t\x00\aord:168
(nil)
127.0.0.1:6379> get ord:186
"\xe4\xba\xac\xe4\xb8\x9c\xe8\xae\xa2\xe5\x8d\x9568b2a2da-3180-4a62-b71b-2a8f7e182e00"
127.0.0.1:6379> keys *
 1) "order"
 2) "zet1"
 3) "k4"
 4) "k5"
 5) "hash1"
 6) "ord:186"
 7) "k1"
 8) "str2"
 9) "str3"
10) "str1"
11) "\xac\xed\x00\x05t\x00\aord:168"
12) "k2"
13) "mylist"
127.0.0.1:6379> quit
[root@localhost ~]# redis-cli -a abc123 -p 6379 --raw
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get ord:186
京东订单68b2a2da-3180-4a62-b71b-2a8f7e182e00
127.0.0.1:6379> get ord:808
"京东订单621b2615-ddd0-4e19-8d97-22c79578594b"
127.0.0.1:6379> keys *
ord:245
order
zet1
k4
ord:808
k5
hash1
ord:186
k1
str2
str3
str1
��tord:168
k2
mylist
127.0.0.1:6379> shutdown
not connected> quit
[root@localhost ~]# ps -ef|grep redis
root       3052   2478  0 10:58 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6381.conf 
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6382.conf 
[root@localhost ~]# ps -ef|grep redis
root       3123      1  0 11:02 ?        00:00:00 redis-server 0.0.0.0:6381 [cluster]
root       3135      1  0 11:02 ?        00:00:00 redis-server 0.0.0.0:6382 [cluster]
root       3147   2478  0 11:02 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# redis-cli -a abc123 -p 6381 -c --raw
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6381> cluster nodes
2eabe702c6bba38aee780477fab74bc4969d9bf3 192.168.92.129:6382@16382 slave 30b1f7bfccd93049117e1dab1cd6385eaf800015 0 1706152114315 5 connected
30b1f7bfccd93049117e1dab1cd6385eaf800015 192.168.92.131:6385@16385 master,fail - 1706151760733 1706151758814 5 connected 12288-16383
a5757758fd0bdd8106e10905bbd1674c574f10c1 192.168.92.131:6386@16386 slave,fail 1fca4878cd2a2a4fe055003f53d53c84cb589859 1706151761337 1706151758814 3 connected
69d920127eec13adc0d9fcaf0e9448a80d1a4803 192.168.92.130:6384@16384 slave,fail ee718fe879729ec1f961b08c4342c78537997ab4 1706151759726 1706151758814 10 connected
1fca4878cd2a2a4fe055003f53d53c84cb589859 192.168.92.130:6383@16383 master,fail - 1706151761337 1706151758814 3 connected 6827-10922
ee718fe879729ec1f961b08c4342c78537997ab4 192.168.92.129:6381@16381 myself,master - 0 1706152114000 10 connected 0-6826 10923-12287
127.0.0.1:6381> cluster nodes
2eabe702c6bba38aee780477fab74bc4969d9bf3 192.168.92.129:6382@16382 slave 30b1f7bfccd93049117e1dab1cd6385eaf800015 0 1706152180828 5 connected
30b1f7bfccd93049117e1dab1cd6385eaf800015 192.168.92.131:6385@16385 master - 0 1706152180000 5 connected 12288-16383
a5757758fd0bdd8106e10905bbd1674c574f10c1 192.168.92.131:6386@16386 slave 1fca4878cd2a2a4fe055003f53d53c84cb589859 0 1706152180123 3 connected
69d920127eec13adc0d9fcaf0e9448a80d1a4803 192.168.92.130:6384@16384 slave ee718fe879729ec1f961b08c4342c78537997ab4 0 1706152178812 10 connected
1fca4878cd2a2a4fe055003f53d53c84cb589859 192.168.92.130:6383@16383 master - 0 1706152179518 3 connected 6827-10922
ee718fe879729ec1f961b08c4342c78537997ab4 192.168.92.129:6381@16381 myself,master - 0 1706152178000 10 connected 0-6826 10923-12287

[root@localhost ~]# redis-server /myredis/cluster/redisCluster6383.conf 
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6384.conf 
[root@localhost ~]# ps -ef|grep redis
root       2691      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6383 [cluster]
root       2703      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6384 [cluster]
root       2717   2643  0 11:07 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# systemctl stop firewalld

 [root@localhost ~]# redis-server /myredis/cluster/redisCluster6383.conf 
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6384.conf 
[root@localhost ~]# ps -ef|grep redis
root       2691      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6383 [cluster]
root       2703      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6384 [cluster]
root       2717   2643  0 11:07 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# redis-server /myredis/cluster/redisCluster6385.conf 
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6386.conf 
[root@localhost ~]# ps -ef|grep redis
root       2685      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6385 [cluster]
root       2697      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6386 [cluster]
root       2709   2628  0 11:08 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# systemctl stop firewalld

 [root@localhost ~]# redis-server /myredis/cluster/redisCluster6385.conf 
[root@localhost ~]# redis-server /myredis/cluster/redisCluster6386.conf 
[root@localhost ~]# ps -ef|grep redis
root       2685      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6385 [cluster]
root       2697      1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:6386 [cluster]
root       2709   2628  0 11:08 pts/0    00:00:00 grep --color=auto redis
[root@localhost ~]# systemctl stop firewalld

  • 22
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值