基础版本
This commit is contained in:
10
parcels/roles/components/test/tasks/install_zk.yml
Normal file
10
parcels/roles/components/test/tasks/install_zk.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
- name: check jdk 1.8_73
|
||||
shell: if [ `expr {{groups.zookeeper|length}} % 2` -eq 0 ];then echo 1 ;else echo 0 ;fi
|
||||
ignore_errors: false
|
||||
register: jdk_out
|
||||
|
||||
- name: To terminate execution
|
||||
fail:
|
||||
msg: "JDK 未安装 请检查"
|
||||
when: jdk_out.stdout != '1'
|
||||
|
||||
1
parcels/roles/components/test/tasks/main.yml
Normal file
1
parcels/roles/components/test/tasks/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
- include: install_zk.yml
|
||||
23
parcels/roles/components/test/tasks/unload_zk.sh.j2
Executable file
23
parcels/roles/components/test/tasks/unload_zk.sh.j2
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
source /etc/profile
|
||||
|
||||
service keepzkalive stop
|
||||
sleep 5
|
||||
|
||||
livenum=`jps -l | grep "org.apache.zookeeper.server.quorum.QuorumPeerMain" | wc -l`
|
||||
if [ $livenum -ne 0 ];then
|
||||
keeppid=`jps -l |grep zookeeper | awk '{print $1}'`
|
||||
kill -9 $keeppid
|
||||
|
||||
rm -rf {{ install_path }}/{{ zookeeper_version }}
|
||||
rm -rf {{ data_path }}/{{ zookeeper_version }}
|
||||
chkconfig keepzkalive off
|
||||
systemctl daemon-reload
|
||||
rm -rf /etc/init.d/keepzkalive
|
||||
else
|
||||
rm -rf {{ install_path }}/{{ zookeeper_version }}
|
||||
rm -rf {{ data_path }}/{{ zookeeper_version }}
|
||||
chkconfig keepzkalive off
|
||||
systemctl daemon-reload
|
||||
rm -rf /etc/init.d/keepzkalive
|
||||
fi
|
||||
14
parcels/roles/components/test/templates/change_myid.sh.j2
Normal file
14
parcels/roles/components/test/templates/change_myid.sh.j2
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
id={{ zk_start_myid }}
|
||||
|
||||
for i in `echo "{{ ansible_play_hosts }}" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"`
|
||||
do
|
||||
ip=`echo $i | grep -E -o "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"`
|
||||
echo 'server.'$id'='$ip':2888:3888' >> {{ install_path }}/{{ zookeeper_version }}/conf/zoo.cfg
|
||||
if [[ $ip == {{ inventory_hostname }} ]];then
|
||||
echo $id > {{ install_path }}/{{ zookeeper_version }}/data/myid
|
||||
fi
|
||||
((id++))
|
||||
done
|
||||
|
||||
21
parcels/roles/components/test/templates/dae-zookeeper.sh.j2
Normal file
21
parcels/roles/components/test/templates/dae-zookeeper.sh.j2
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
#进程名称
|
||||
PRO_NAME=QuorumPeerMain
|
||||
#安装路径
|
||||
BASE_DIR={{ install_path }}
|
||||
VERSION={{ zookeeper_version }}
|
||||
source /etc/profile
|
||||
|
||||
|
||||
while true ; do
|
||||
NUM=`$BASE_DIR/$VERSION/bin/zkServer.sh status | egrep 'leader|follower' | wc -l`
|
||||
if [ "${NUM}" -lt "1" ];then
|
||||
$BASE_DIR/$VERSION/bin/zkServer.sh start
|
||||
OLD_NUM=`cat $BASE_DIR/$VERSION/logs/restart_sum.log`
|
||||
RESTART_NUM=`expr $OLD_NUM + 1`
|
||||
echo $RESTART_NUM > $BASE_DIR/$VERSION/logs/restart_sum.log
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` - zookeeper服务启动/异常重启 - 重启次数 -> $RESTART_NUM" >> $BASE_DIR/$VERSION/restart.log
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
6
parcels/roles/components/test/templates/java.env.j2
Normal file
6
parcels/roles/components/test/templates/java.env.j2
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_73
|
||||
# heap size MUST be modified according to cluster environment
|
||||
|
||||
export JVMFLAGS="-Xmx{{ zookeeper_max_mem }}m -Xms1024m $JVMFLAGS"
|
||||
34
parcels/roles/components/test/templates/keepzkalive.j2
Normal file
34
parcels/roles/components/test/templates/keepzkalive.j2
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# netconsole This loads the netconsole module with the configured parameters.
|
||||
#
|
||||
# chkconfig:123456 20 80
|
||||
# description: keepzkalive
|
||||
source /etc/profile
|
||||
PRO_NAME=keepzklive
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
keepnum=`ps -ef | grep dae-zookeeper.sh | grep -v grep | wc -l`
|
||||
|
||||
if [ $keepnum -eq "0" ];then
|
||||
nohup {{ install_path }}/{{ zookeeper_version }}/bin/dae-zookeeper.sh /home/bigdata > /dev/null 2>&1 &
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
keeppid=`ps -ef | grep dae-zookeeper.sh | grep -v grep | awk '{print $2}'`
|
||||
echo "守护进程PID:$keeppid"
|
||||
kill -9 $keeppid
|
||||
sleep 1
|
||||
sh {{ install_path }}/{{ zookeeper_version }}/bin/zkServer.sh stop
|
||||
;;
|
||||
|
||||
status)
|
||||
sh {{ install_path }}/{{ zookeeper_version }}/bin/zkServer.sh status
|
||||
;;
|
||||
|
||||
* )
|
||||
echo "use keepzklive [start|stop|status]"
|
||||
;;
|
||||
esac
|
||||
5
parcels/roles/components/test/templates/myid.j2
Normal file
5
parcels/roles/components/test/templates/myid.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
{% for dev_info in zk_host_list %}
|
||||
{% if inventory_hostname == dev_info.host %}
|
||||
{{dev_info.myid}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
17
parcels/roles/components/test/templates/set_zk_env.sh.j2
Normal file
17
parcels/roles/components/test/templates/set_zk_env.sh.j2
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
num=`cat /etc/profile | grep zookeeper | wc -l`
|
||||
|
||||
if [ $num -eq "0" ];then
|
||||
echo -e "\n#zookeeper" >> /etc/profile
|
||||
echo -e "export ZOOKEEPER_HOME={{ install_path }}/{{ zookeeper_version }}" >> /etc/profile
|
||||
echo -e "export PATH=\$ZOOKEEPER_HOME/bin:\$PATH" >> /etc/profile
|
||||
source /etc/profile
|
||||
fi
|
||||
|
||||
keeppsth='/etc/init.d/keepzkalive'
|
||||
if [ -x $keeppsth ];then
|
||||
chkconfig --add keepzkalive
|
||||
chkconfig keepzkalive on
|
||||
service keepzkalive start
|
||||
fi
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
docker rm -f zookeeper_exporter
|
||||
|
||||
sleep 3
|
||||
|
||||
docker run -d -p 9902:9114 --name zookeeper_exporter --restart always zookeeper_exporter:v1.0 {{ inventory_hostname }}:2181
|
||||
|
||||
31
parcels/roles/components/test/templates/zoo.cfg.j2
Normal file
31
parcels/roles/components/test/templates/zoo.cfg.j2
Normal file
@@ -0,0 +1,31 @@
|
||||
# The number of milliseconds of each tick
|
||||
tickTime=9000
|
||||
# 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_path }}/{{ zookeeper_version }}/data
|
||||
# the port at which the clients will connect
|
||||
clientPort={{ zookeeper_port }}
|
||||
# the maximum number of client connections.
|
||||
# increase this if you need to handle more clients
|
||||
maxClientCnxns=1000
|
||||
#
|
||||
# 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=5
|
||||
# Purge task interval in hours
|
||||
# Set to "0" to disable auto purge feature
|
||||
autopurge.purgeInterval=1
|
||||
dataLogDir={{ install_path }}/{{ zookeeper_version }}/logs
|
||||
#
|
||||
#the servers
|
||||
0
parcels/roles/components/test/vars/main.yml
Normal file
0
parcels/roles/components/test/vars/main.yml
Normal file
Reference in New Issue
Block a user