ansible all -i _etc_ansible_hosts -m file -a "path=/opt/zookeeper state=directory" zookeeper_servers -m copy -a "src=/opt/zookeeper-3.4.12.tar.gz dest=/opt/ owner=root group=root mode=0644"
ansible all -i _etc_ansible_hosts -m file -a "path=/opt/zookeeper state=directory" ansible all -i _etc_ansible_hosts -m file -a "path=/opt/zookeeper/zkdata/ state=directory" ansible all -i _etc_ansible_hosts -m file -a "path=/opt/zookeeper/zkdatalog/ state=directory"
ansible all -i _etc_ansible_hosts -m command -a "tar xf /opt/zookeeper-3.4.12.tar.gz -C /opt/zookeeper/"
ansible all -i _etc_ansible_hosts -m copy -a "src=/opt/zookeeper/zookeeper-3.4.12/conf/zoo.cfg dest=/opt/zookeeper/zookeeper-3.4.12/conf/ owner=root group=root mode=0644"
在zookeeper-server1上:
echo “1” > /opt/zookeeper/zkdata/myid
在zookeeper-server2上:
echo “2” > /opt/zookeeper/zkdata/myid
在zookeeper-server3上:
echo “3” > /opt/zookeeper/zkdata/myid
zookeeper服务启停操作:
1 2 3
ansible all -i _etc_ansible_hosts -m command -a "/opt/zookeeper/zookeeper-3.4.12/bin/zkServer.sh start" ansible all -i _etc_ansible_hosts -m command -a "/opt/zookeeper/zookeeper-3.4.12/bin/zkServer.sh status" ansible all -i _etc_ansible_hosts -m command -a "/opt/zookeeper/zookeeper-3.4.12/bin/zkServer.sh stop"
FAQ:
Q: Error contacting service. It is probably not running. A: