saltstack一键安装redis主从
saltstack安装redis主从分为两步,一,安装redis. 二,做主从。
1.saltstack关于redis的目录结构
2.salt关于redis内容
a.安装redis
[root@linux-node1 redis]# cat init.sls redis-install: pkg.installed: - name: redis redis-config: file.managed: - name: /etc/redis.conf - source: salt://redis/files/redis.conf - user: root - gourp: root - mode: 644 - template: jinja - defaults: PORT: 9400 IPADDR: {{ grains['fqdn_ip4'][0] }} redis-service: service.running: - name: redis - enable: True - reload: True
b.主redis安装
[root@linux-node1 redis]# cat master.sls include: - redis.init
c.从redis设置
[root@linux-node1 redis]# cat slave.sls include: - redis.init slave_config: cmd.run: - name: redis-cli -p 9400 -h 10.0.0.70 slaveof 10.0.0.9 9400 - unless: redis-cli -p 9400 -h 10.0.0.70 info |grep role:slave - require: - service: redis-service
3.配置top.sls
[root@linux-node1 redis]# cat /srv/salt/base/top.sls prod: 'linux-node1*': - redis.master 'linux-node2*': - redis.slave
4.一键安装
[root@linux-node1 redis]# salt 'linux-node*' state.highstate
5.测试
嗨、骚年、快来消灭0回复。