Author: ming Email: [email protected] Description: Ansible playbook for redis cluster, master-slave and sentinel Create Date: 2023/8/27 Last Modify Date: 2023/8/27
这是一个使用Ansible实现一键部署redis集群、哨兵、主从的脚本程序,并且 内附Dockerfile,可以使用Docker首先创建镜像,然后进入镜像执行本脚本。 注意,本脚本实现的集群部署仅仅是将相应的集群节点启动,但是不创建集群,创建 集群的工作留给用户进行。
startup.sh脚本是该程序的启动脚本,本地执行该脚本即可启动程序. 在开始安装部署前,请确认本地机器到目标机器的网络是放通的,并且确定本机到目标机器 的ssh密钥已经存在。通过修改invenroty文件来增加或者删除目标机器IP地址及端口。
接下来简单介绍使用Docker镜像运行本程序的步骤
sudo docker build -t repo:tag .
sudo docker continer run -name container_name -d repo:tag
vim /src/inventory
ssh-keygen
ssh-copy-id [email protected] -p xxx
./startup.sh
执行脚本后,会自动在被管理节点上部署redis集群、哨兵、主从,并且启动实例 安装目录默认为/data/software/redis 如需修改安装目录路径,打开/src/vars.yml文件,修改redis_base_dir变量即可