Commit 1f7ec2ee by Your Name

add role zk-cluster

parent b8a872fa
[defaults]
inventory = /root/Ant_Devops/hosts
timeout=60
gathering = implicit
autocmd FileType yaml setlocal ts=2 sw=2
set ai!
set autoindent
set nu!
[jf-01] [app-01]
192.168.1.117 192.168.137.11
[jf-02] [app-02]
192.168.1.235 192.168.137.11
[jf-03] [app-03]
192.168.1.204 192.168.137.11
[jf-04]
192.168.1.162
[jf-05]
192.168.1.249
[jf-1-3]
192.168.1.117
192.168.1.235
192.168.1.204
[jf-02]
[jf]
192.168.1.117
192.168.1.235
192.168.1.204
192.168.1.162
192.168.1.249
[all:vars]
ansible_ssh_pass=JSY@1q2w3e4r
ansible_ssh_user=root
ansible_ssh_port=19221
[sales]
192.168.1.163
192.168.1.38
192.168.1.65
192.168.1.33
[sales:vars]
ansible_ssh_pass=JSY1q2w3e4r
ansible_ssh_user=root
---
- name: create data dir
file:
path: "{{ item }}"
state: directory
with_items:
- /opt/app
- /data/app-data/zookeeper
- /data/log/zookeeper
- name: "downloads zookeeper server"
# get_url:
# url: https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.14.tar.gz
# dest: "/usr/local/"
unarchive:
copy: yes
src: "/software/{{ zookeeper }}"
dest: "{{ software }}"
- name: "copy zk conf templates"
template:
src: zoo.cfg
dest: "{{ software }}/{{ zookeeperdir }}/conf/zoo.cfg"
- name: 配置zk myid
shell: "hostname -i| cut -d '.' -f 4|awk '{print $1}' > /data/app-data/zookeeper/myid"
- name: "run zk server"
shell: "nohup {{ software }}/{{ zookeeperdir }}/bin/zkServer.sh start > /dev/null 2>&1 &"
- name: 验证服务状态
# shell: "{{ software }}/{{ zookeeperdir }}/bin/zkServer.sh status"
shell: "sleep 3 && netstat -ntlp|grep 2181"
register: zookeeper_status_result
ignore_errors: True
- debug:
msg: "{{ zookeeper_status_result.stdout_lines }}"
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/app-data/zookeeper
dataLogDir=/data/log/zookeeper/
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.{{ zk01myid }}={{ zk01server }}:2881:3881
server.{{ zk02myid }}={{ zk02server }}:2881:3881
server.{{ zk03myid }}={{ zk03server }}:2881:3881
192.168.1.204
--- ---
- name: test - name: test
hosts: jf-03 hosts: app-01
remote_user: root remote_user: root
vars_files: vars_files:
- var/main.yml - var/main.yml
roles: roles:
- activemq - zk_cluster
--- ---
#zk-cluster
zk01server: 192.168.137.11
zk02server: 192.168.137.12
zk03server: 192.168.137.13
zk01myid: 11
zk02myid: 12
zk03myid: 13
#zabbix #zabbix
zabbix_server: 172.16.0.42 zabbix_server: 172.16.0.42
#bin #bin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment