##cat run.sh ####### etcd cluster for Centos7
####### local hostname this_server_name=k1 ####### local ip this_server_ip=192.168.10.2
####### etcd cluster token etcd_token=[email protected]
####### etcd cluster hostname list server_name_list=(k1 k2 k3) ####### etcd cluster ip list server_ip_list=(192.168.10.2 192.168.10.3 192.168.10.5) ####### etcd cluster ca ,${ca_path}/etcd/ca.pem,${ca_path}/etcd/k1.pem,${ca_path}/etcd/k1-key.pem ca_path=/opt/certs
####### docker run -p ${etcd_port}:2380 -p ${etcd_api_port}:2379 etcd_port=2380 etcd_api_port=2379 ####### local etcd data path etcd_data_path=/opt/etcd/data
################ bashrc_file=/root/.bashrc hosts_file=/etc/hosts
hostnamectl set-hostname ${this_server_name}
echo "" >> ${bashrc_file} echo "## sys add ##" >> ${bashrc_file}
echo "export THIS_SERVER_NAME=${this_server_name}" >> ${bashrc_file} echo "export THIS_SERVER_IP=${this_server_ip}" >> ${bashrc_file} echo "export CA_PATH=${ca_path}" >> ${bashrc_file}
echo "## ## ##" >> ${bashrc_file} echo "" >> ${bashrc_file}
etcd_cluster=""; etcd_cluster_api="";
echo "" >> ${bashrc_file} echo "## etcd add ##" >> ${bashrc_file}
for(( i=0;i<${#server_name_list[@]};i++)) do n=$[i+1]; echo "export SERVER_NAME_${n}=${server_name_list[i]}" >> ${bashrc_file}; echo "export SERVER_IP_${n}=${server_ip_list[i]}" >> ${bashrc_file}; echo "${server_ip_list[i]} ${server_name_list[i]}" >> ${hosts_file};
if [ "$etcd_cluster" = "" ] then etcd_cluster="${server_name_list[i]}=https://${server_name_list[i]}:${etcd_port}"; etcd_cluster_api="https://${server_name_list[i]}:${etcd_api_port}"; else etcd_cluster="${etcd_cluster},${server_name_list[i]}=https://${server_name_list[i]}:${etcd_port}"; etcd_cluster_api="${etcd_cluster_api},https://${server_name_list[i]}:${etcd_api_port}"; fi done;
echo "export ETCD_NAME=${this_server_name}_etcd" >> ${bashrc_file} echo "export ETCD_CLUSTER_STATE=new" >> ${bashrc_file} echo "export ETCD_CLUSTER=${etcd_cluster}" >> ${bashrc_file} echo "export ETCD_CLUSTER_API=${etcd_cluster_api}" >> ${bashrc_file} echo "export ETCD_TOKEN=${etcd_token}" >> ${bashrc_file}
echo "## ## ##" >> ${bashrc_file} echo "" >> ${bashrc_file}
. ${bashrc_file} . ${hosts_file}
docker run -d --name=${ETCD_NAME}
-p ${etcd_port}:2380 -p ${etcd_api_port}:2379
-v ${etcd_data_path}:/opt/etcd/data
-e ETCD_NAME=${ETCD_NAME}
-e THIS_SERVER_NAME=${THIS_SERVER_NAME}
-e THIS_SERVER_IP=${THIS_SERVER_IP}
-e ETCD_TOKEN=${ETCD_TOKEN}
-e ETCD_CA_PATH=${CA_PATH}/etcd
-e ETCD_CLUSTER_STATE=${ETCD_CLUSTER_STATE}
-e ETCD_CLUSTER=${ETCD_CLUSTER}
ailen/etcd:v3.3.2
Content type
Image
Digest
Size
33.3 MB
Last updated
over 8 years ago
docker pull ailen/etcd:v3.3.2