#!/bin/bash
#回显执行的命令和参数
set -x
#cd到目录执行脚本,然后通过cd - 返回到当前目录
cd ../../utils
. ./sys_info.sh
. ./sh-test-lib
cd -
#根据不同的发行版安装repo
case "${distro}" in
centos|fedora)
sudo wget -O /etc/yum.repos.d/estuary.repo https://raw.githubusercontent.com/open-estuary/distro-repo/master/estuaryftp.repo
sudo chmod +r /etc/yum.repos.d/estuary.repo
sudo rpm --import ftp://repoftp:repopushez7411@117.78.41.188/releases/ESTUARY-GPG-KEY
yum clean dbcache
print_info $? setup-estuary-repository
#保存好repo之后安装etcd的安装包
pkgs="etcd"
install_deps "${pkgs}"
print_info $? install-bazel
;;
*)
error_msg "Unsupported distribution!"
esac
#启动etcd server 并在后台运行
etcd &
print_info $? start-single-etcd
#执行etcdctl 命令
etcdctl set hello world
print_info $? create-key-value
etcdctl get hello | grep "world"
print_info $? search-key-value
#删除etcd 进程
kill -9 $(pidof etcd)
print_info $? stop-single-etcd
echo $local_ip
#重新执行etcd命令,设置位置参数
etcd --name infra0 --initial-advertise-peer-urls http://$local_ip:2380 \
--listen-peer-urls http://$local_ip:2380 \
--listen-client-urls http://$local_ip:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://$local_ip:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://$local_ip:2380,infra1=http://$local_ip:2382,infra2=http://$local_ip:2384 \
--initial-cluster-state new &
etcd --name infra1 --initial-advertise-peer-urls http://$local_ip:2382 \
--listen-peer-urls http://$local_ip:2382 \
--listen-client-urls http://$local_ip:2381,http://127.0.0.1:2381 \
--advertise-client-urls http://$local_ip:2381 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://$local_ip:2380,infra1=http://$local_ip:2382,infra2=http://$local_ip:2384 \
--initial-cluster-state new &
etcd --name infra2 --initial-advertise-peer-urls http://$local_ip:2384 \
--listen-peer-urls http://$local_ip:2384 \
--listen-client-urls http://$local_ip:2383,http://127.0.0.1:2383\
--advertise-client-urls http://$local_ip:2383 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://$local_ip:2380,infra1=http://$local_ip:2382,infra2=http://$local_ip:2384 \
--initial-cluster-state new &
print_info $? start-cluster-etcd
#执行etcdctl命令
etcdctl member list
print_info $? search-cluster-list
etcdctl cluster-health | grep 'cluster is healthy'
print_info $? check-cluster-health
#删除etcd 进程
kill -9 $(pidof etcd)
print_info $? stop-cluster-etcd
#删除包
yum remove -y etcd
print_info $? remove-etcd
test-definitions/blob/master/auto-test/etcd/etcd.sh
最新推荐文章于 2024-02-01 15:45:11 发布