test-definitions/blob/master/auto-test/etcd/etcd.sh

#!/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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值