增加集群服务器ha配置;更新pyinstaller打包后找不到依赖库的bug.

This commit is contained in:
lijia
2020-10-20 22:46:23 +08:00
parent 2344df69ee
commit 25e4f39bcc
47 changed files with 679 additions and 30 deletions

View File

@@ -0,0 +1,6 @@
#!/bin/bash
#
killall -9 consul-replicate
cd /opt/consul-internal/bin/;./consul-replicate -prefix "device_info@consul-external_new" &>/dev/null &
cd /opt/consul-internal/bin/;./consul-replicate -prefix "device_list@consul-external_new" &>/dev/null &
cd /opt/consul-internal/bin/;./consul-replicate -prefix "tags@consul-external_new" &>/dev/null &

View File

@@ -0,0 +1,12 @@
{
"server" : true,
"datacenter" : "consul-ADC01",
"data_dir" : "/var/consul-external",
"encrypt" : "h1fHoHnJ+n+764ObqTNVjw==",
"disable_update_check" : true,
"bootstrap" : true,
"log_file" : "/var/consul-external/log/consul_external.log",
"retry_join" : ["192.168.200.5"],
"retry_interval" : "10s"
}

View File

@@ -0,0 +1,14 @@
# Systemd unit file for default tomcat
#
[Unit]
Description=Consul-cluster
After=network.target
[Service]
EnvironmentFile=/opt/consul-cluster/etc/systemd/consul.conf
ExecStartPre=/opt/consul-cluster/script/consul_bind_ip_generate.sh
ExecStart=/opt/consul-cluster/bin/consul agent -config-dir /opt/consul-cluster/etc/ -config-file /opt/consul-cluster/etc/consul/config-server.json -bind ${CONSUL_BIND_ADDRESS} -client 0.0.0.0
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,8 @@
#!/bin/bash
rm -rf /usr/lib/systemd/system/consul*service
rm -rf /usr/lib/systemd/system/consul*service
rm -rf /var/consul*
cp -f /opt/consul-cluster/etc/systemd/consul-server.service /usr/lib/systemd/system/consul-server-cluster.service
cp -f /opt/consul-cluster/bin/consul /usr/bin/
ln -sf /opt/consul-cluster/script/consul_path_setup.sh /etc/profile.d/

View File

@@ -0,0 +1,6 @@
#!/bin/bash
#BIND_ADDRESS=$(/usr/sbin/ip route | /usr/bin/grep default | head -n 1 | /usr/bin/awk '{print $5}' | /usr/bin/xargs ifconfig | /usr/bin/grep "inet" | /usr/bin/grep -v "inet6" | /usr/bin/awk '{print $2}')
BIND_ADDRESS=$(ifconfig ens34 | grep inet | head -1 |awk '{print $2}')
#BIND_ADDRESS=192.168.200.5
systemctl set-environment CONSUL_BIND_ADDRESS=${BIND_ADDRESS}

View File

@@ -0,0 +1,3 @@
PATH=/opt/consul-external/bin:${PATH}
export PATH

View File

@@ -0,0 +1,27 @@
- name: "copy consul-cluster to destination server"
copy:
src: "{{ role_path }}/files/"
dest: /opt
mode: 0755
- name: "Template consul_bind_ip_generate.sh"
template:
src: "{{ role_path }}/templates/consul_bind_ip_generate.sh.j2"
dest: /opt/consul-cluster/script/consul_bind_ip_generate.sh
tags: template
- name: "Template config-server.json"
template:
src: "{{ role_path }}/templates/config-server.json.j2"
dest: /opt/consul-cluster/etc/consul/config-server.json
tags: template
- name: "Install consul-cluster"
shell: cd /opt/consul-cluster;sh install.sh
- name: "Start consul-cluster"
systemd:
name: consul-server-cluster
state: restarted
enabled: yes
daemon_reload: yes

View File

@@ -0,0 +1,13 @@
{
"server" : true,
"datacenter" : "{{ consul.datacenter }}",
"data_dir" : "/var/consul-cluster",
"encrypt" : "{{ consul.dckey }}",
"disable_update_check" : true,
"bootstrap_expect": 2,
"log_level" : "info",
"log_file" : "/var/consul-cluster/log/consul_cluster.log",
"retry_join" : ["{{ consul.cluster_ip }}","{{ consul.cluster_ip_backup }}"],
"retry_interval" : "10s"
}

View File

@@ -0,0 +1,4 @@
#!/bin/bash
BIND_ADDRESS=$(ifconfig {{ consul.cluster_ethname }} | grep inet | head -1 |awk '{print $2}')
systemctl set-environment CONSUL_BIND_ADDRESS=${BIND_ADDRESS}