–
一、下载etcd etcd可从GitHub下载Linux版本,下载地址:https://github.com/coreos/etcd/releases 二、解压 当前etcd最新版本是v3.5.9。下载 https://github.com/etcd-io/etcd/releases/download/v3.5.9/etcd-v3.5.9-linux-amd64.tar.gz 执行以下命令解压 tar xf etcd-v3.5.9-linux-amd64.tar.gz etcd只有两个可执行文件,etcd和etcdctl ,将解压后的这两个文件复制到/usr/local/bin目录下。执行以下命令 cp -r etcd* /usr/local/bin/ 三、配置 1、配置etcd.service 在/etc/systemd/system目录下新建etcd.service文件, 执行命令: cat /etc/systemd/system/etcd.service [Unit] Description=Etcd Server After=network.target [Service] Type=simple WorkingDirectory=/var/lib/etcd/ EnvironmentFile=-/etc/etcd/etcd.conf ExecStart=/usr/local/bin/etcd [Install] WantedBy=multi-user.target 2、新建etcd工作目录 在/var/lib/目录下新建etcd的工作目录etcd,执行命令: mkdir /var/lib/etcd 3、配置etcd.conf 新建/etc/etcd/etcd.conf文件,配置内容如下:如果想暴露出去,可以添加node的ip mkdir /etc/etcd vim /etc/etcd/etcd.conf #[member] ETCD_NAME=default ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS="http://localhost:2379,http://xx,xx,x,x:2379" ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379,http://xx,xx,x,x:2379" 四、启动并验证 配置完成后,执行以下命令,启动etcd服务。 systemctl daemon-reload && systemctl enable etcd.service && systemctl start etcd.service && systemctl status etcd.service 启动后执行以下命令验证: etcdctl endpoint health 输出: 127.0.0.1:2379 is healthy: successfully committed proposal: took = 9.129744ms 开启密码 [root@centos-170-21 ~]#etcdctl role add root Role root created [root@centos-170-21 ~]#etcdctl user add root Password of root: Type password of root again for confirmation: User root created [root@centos-170-21 ~]#etcdctl user grant-role root root Role root is granted to user root [root@centos-170-21 ~]#etcdctl auth enable Authentication Enabled [root@centos-170-21 ~]#etcdctl get / --prefix {"level":"warn","ts":"2023-10-25T11:31:45.351763+0800","logger":"etcd-client","caller":"v3@v3.5.9/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc00038e700/127.0.0.1:2379","attempt":0,"error":"rpc error: code = InvalidArgument desc = etcdserver: user name is empty"} Error: etcdserver: user name is empty [root@centos-170-21 ~]#etcdctl --user=root:redhat get / --prefix
–
–
评论前必须登录!
注册