etcd 尝试
vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
servers = {
:etcd1 => '192.168.1.21',
:etcd2 => '192.168.1.22',
:etcd3 => '192.168.1.23'
}
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
servers.each do |server_name, server_ip|
config.vm.define server_name do |server_config|
server_config.vm.hostname = "#{server_name.to_s}"
server_config.vm.network :private_network, ip: server_ip
server_config.vm.provider "virtualbox" do |vb|
vb.name = server_name.to_s
if vb.name == "etcd1"
vb.memory = 1024
vb.cpus = 1
else
vb.memory = 1024
vb.cpus = 1
end
end
end
end
end
install
install.sh
ETCD_VER=v3.4.9
# choose either URL
GOOGLE_URL=https://storage.googleapis.com/etcd
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
DOWNLOAD_URL=${GOOGLE_URL}
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
/tmp/etcd-download-test/etcd --version
/tmp/etcd-download-test/etcdctl version
cluster.sh
- infra0/1/2
- 192.168.1.21-23
/tmp/etcd-download-test/etcd --name infra1 --initial-advertise-peer-urls http://192.168.1.22:2380 \
--listen-peer-urls http://192.168.1.22:2380 \
--listen-client-urls http://192.168.1.22:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://192.168.1.22:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://192.168.1.21:2380,infra1=http://192.168.1.22:2380,infra2=http://192.168.1.23:2380 \
--initial-cluster-state new
/tmp/etcd-download-test/etcdctl put mykey “this is awesome” /tmp/etcd-download-test/etcdctl get mykey