This commit is contained in:
zhangzhihan
2020-01-17 15:35:48 +08:00
commit 960bdaa91f
58 changed files with 7988 additions and 0 deletions

Binary file not shown.

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,7 @@
#!/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
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,26 @@
- 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
tags: template
- name: "Template config-server.json"
template:
src: "{{ role_path }}/templates/config-server.json.j2"
dest: /opt/consul-cluster/etc/consul
tags: template
- name: "Install consul-cluster"
shell: cd /opt/consul-cluster;sh install.sh
- name: "Start consul-cluster"
systemd:
name: consul-server-cluster
enabled: yes
daemon_reload: yes

View File

@@ -0,0 +1,12 @@
{
"server" : true,
"datacenter" : "{{ consul.datacenter }}",
"data_dir" : "/var/consul-cluster",
"encrypt" : "{{ consul.keys}}",
"disable_update_check" : true,
"bootstrap" : true,
"log_file" : "/var/consul-cluster/log/consul_cluster.log",
"retry_join" : ["{{ inventory_hostname }}"],
"retry_interval" : "10s"
}

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 {{ consul.cluster_nig_mgr }} | grep inet | head -1 |awk '{print $2}')
#BIND_ADDRESS=192.168.200.5
systemctl set-environment CONSUL_BIND_ADDRESS=${BIND_ADDRESS}