admin管理员组文章数量:1634952
文章目录
- 一、版本
- 二、上传配置文件到一台服务器
- 三、配置集群间服务器无密码ssh访问(ssh localhost也需要无密码访问)
- 四、修改配置文件 nodes
- 五、修改配置文件install.sh
- 六、运行集群安装脚本
- 七、检测集群中个节点安装情况
- 八、启动cluster集群
- 九、测试
- 十、redis 准备 slave
- 1、复制配置(nodes中每台服务器)
- 2、修改配置cluster.sh
- 3、跳转步骤六安装即可
一、版本
示范版本为 5.0.2
二、上传配置文件到一台服务器
➜ Downloads scp -r redis root@ecs:/root
root@ecs's password:
...
start.sh 100% 119 3.1KB/s 00:00
➜ Downloads
三、配置集群间服务器无密码ssh访问(ssh localhost也需要无密码访问)
集群间ssh无密码访问设置:
https://blog.csdn/weixin_44057144/article/details/102711716
[root@yue ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.44 redis-3
192.168.0.43 redis-2
192.168.0.33 redis-1
[root@yue ~]#
四、修改配置文件 nodes
# 修改为要安装集群的hosts
[root@yue ~]# cat redis/nodes
192.168.0.44
192.168.0.43
192.168.0.33
五、修改配置文件install.sh
修改端口port密码password
启动单节点 修改 open_cluster=‘no’ 运行 sh install.sh即可
[root@yue redis]# head -3 install.sh
port=7111
password=Iopdev_201902
open_cluster='yes'
[root@yue redis]#
六、运行集群安装脚本
[root@yue ~]# cd redis/
[root@yue redis]# sh cluster.sh
cluster.sh 100% 219 1.2MB/s 00:00
......
准备中... ########################################
正在升级/安装...
......
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: 离开目录“/usr/local/redis-cluster/redis-5.0.2/src”
chmod: 无法访问"/usr/local/redis-cluster/restart.sh": 没有那个文件或目录
[root@yue redis]# ps -aux | grep redis | grep -v grep
root 26662 0.1 0.2 153880 2848 ? Ssl 21:26 0:00 redis-server *:7111 [cluster]
[root@yue redis]# ssh root@192.168.0.43 'ps -aux | grep redis | grep -v grep'
root 12378 0.1 0.2 153880 2848 ? Ssl 21:26 0:00 redis-server *:7111 [cluster]
[root@yue redis]# ssh root@192.168.0.44 'ps -aux | grep redis | grep -v grep'
root 24632 0.1 0.2 153880 2848 ? Ssl 21:26 0:00 redis-server *:7111 [cluster]
[root@yue redis]#
七、检测集群中个节点安装情况
[root@yue redis]#
[root@yue redis]# ps -aux | grep redis | grep -v grep
root 26662 0.1 0.2 153880 2316 ? Ssl 21:26 0:00 redis-server *:7111 [cluster]
[root@yue redis]# ssh root@192.168.0.43 'ps -aux | grep redis | grep -v grep'
root 12378 0.1 0.2 176100 2848 ? Ssl 21:26 0:00 redis-server *:7111 [cluster]
[root@yue redis]# ssh root@192.168.0.44 'ps -aux | grep redis | grep -v grep'
root 24632 0.1 0.2 113176 1939 ? Ssl 21:27 0:00 redis-server *:7111 [cluster]
[root@yue redis]#
八、启动cluster集群
# 修改 start.sh,修改为个人在install.sh中配置的port password以及nodes中的数据
# 使用start.shq启动集群
[root@yue redis]# cat start.sh
redis-cli -a Iopdev_201902 --cluster create --cluster-replicas 0 192.168.0.33:7111 192.168.0.43:7111 192.168.0.44:7111
[root@yue redis-cluster]# sh start.sh
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on 3 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
M: a42c99628b3d5951d33038bdc3d31c1100425229 192.168.0.33:7111
slots:[0-5460] (5461 slots) master
M: a479827b413ce627d5591b274011c0e17e3ae000 192.168.0.43:7111
slots:[5461-10922] (5462 slots) master
M: f8bd2d360f2a481fe3e64030d322b121705f0322 192.168.0.44:7111
slots:[10923-16383] (5461 slots) master
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
.
>>> Performing Cluster Check (using node 192.168.0.33:7111)
M: a42c99628b3d5951d33038bdc3d31c1100425229 192.168.0.33:7111
slots:[0-5460] (5461 slots) master
M: f8bd2d360f2a481fe3e64030d322b121705f0322 192.168.0.43:7111
slots:[10923-16383] (5461 slots) master
M: a479827b413ce627d5591b274011c0e17e3ae000 192.168.0.44:7111
slots:[5461-10922] (5462 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@yue redis-cluster]#
九、测试
[root@localhost redis]# ./redis-cli -c -a Iopdev_201902 -p 7000
127.0.0.1:7111> set name yue
OK
192.168.0.43:7111> get anme
-> Redirected to slot [11897] located at 192.168.0.43:7111
192.168.0.43:7111> get name
"yue"
192.168.0.43:7111>
十、redis 准备 slave
1、复制配置(nodes中每台服务器)
[root@yue redis-cluster]# cp redis-7111.conf redis-7112.conf
[root@yue redis-cluster]# ll
总用量 2136
drwxr-xr-x 2 root root 4096 10月 24 21:26 7111
drwxr-xr-x 2 root root 4096 10月 24 21:45 7112
drwxrwxr-x 6 root root 4096 11月 22 2018 redis-5.0.2
-rwxr-xr-x 1 root root 1952989 10月 24 21:25 redis-5.0.2.tar.gz
-rwxr-xr-x 1 root root 62187 10月 24 21:26 redis-7111.conf
-rw-r--r-- 1 root root 2716 10月 24 21:45 redis-7111.log
-rwxr-xr-x 1 root root 62187 10月 24 21:43 redis-7112.conf
-rw-r--r-- 1 root root 2716 10月 24 21:45 redis-7112.log
-rwxr-xr-x 1 root root 110 10月 24 21:44 start.sh
-rwxr-xr-x 1 root root 195 10月 24 21:26 stop.sh
[root@yue redis-cluster]#
2、修改配置cluster.sh
==注意 --cluster-replicas 1 标志每个 master 一个 slave ==
[root@yue redis]# cat start.sh
redis-cli -a Iopdev_201902 --cluster create --cluster-replicas 1 192.168.0.33:7111 192.168.0.43:7111 192.168.0.44:7111 192.168.0.33:7112 192.168.0.43:7112 192.168.0.44:7112
[root@yue redis]#
3、跳转步骤六安装即可
版权声明:本文标题:redis-cluster集群搭建(多服务器一键部署脚本) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1729203893a1189852.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论