多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 注意: 修改命令行中的服务器IP和端口 ### **安装Redis**(新部署) ``` ansible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","master_host":"192.168.88.61"}' --tags install_redis ``` ### **初始化配置文件**(此时slaveof配置是注释的) ``` ansible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","redis_port":"6379","master_host":"192.168.88.61"}' --tags init_redis_conf # 如果你想改配置,请用这个(如改密码、端口) ansible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","redis_port":"6379","master_host":"192.168.88.61","redis_password":"custom_password","master_password":"custom_password"}' --tags init_redis_conf ``` ### **打开复制配置**(修改配置文件) ``` # 增加了when,master_host跳过此操作 ansible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","redis_port":"6379","master_host":"192.168.88.61"}' --tags turn_on_replication ``` ### **设置密码** ``` nsible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","redis_port":"6379","master_host":"192.168.88.61"}' --tags turn_on_local_auth,turn_on_master_auth ``` ### **启动服务** ``` ansible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","redis_port":"6379","master_host":"192.168.88.61"}' --tags start_redis ``` ## **其他操作** ### **停止服务**(当需要重启生效时) ``` ansible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","redis_port":"6379","master_host":"192.168.88.61"}' --tags stop_redis ``` ### **关闭Cluster**(按需,仅关闭,不同步新配置) ``` ansible-playbook -i hosts/redis_hosts redis/redis.yml -e '{"redis_version":"3.2.13","redis_port":"6379","master_host":"192.168.88.61"}' --tags turn_off_cluster ```