构建后端为etcd的CoreDNS的容器集群(三)、etcd功能测试

本文使用官方etcd镜像生成一个容器,并进行功能测试。

一、镜像获取

请见上文:构建后端为etcd的CoreDNS的容器集群(二)、下载最新的etcd容器镜像

二、查看镜像
bash 复制代码
[root@localhost opt]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
quay.io/coreos/etcd   v3.5.16             8523cb381f23        5 weeks ago         59MB
三、创建容器

为便于检查创建参数并进行保存,建议通过脚本进行创建,先进行单容器创建测试

bash 复制代码
[root@localhost etcd]# vi etcd_docker_run.sh  
docker run -d \
    -p 2379:2379 \
    -p 2380:2380 \
    --name etcd-1 \
    quay.io/coreos/etcd:v3.5.16 \
    /usr/local/bin/etcd \
    --name etcd-1 \
    --listen-client-urls http://0.0.0.0:2379 \
    --advertise-client-urls http://0.0.0.0:2379 \
    --listen-peer-urls http://0.0.0.0:2380 \
    --initial-advertise-peer-urls http://0.0.0.0:2380 \
    --initial-cluster etcd-1=http://0.0.0.0:2380 \
    --initial-cluster-token tkn \
    --initial-cluster-state new \
[root@localhost etcd]# sh etcd_docker_run.sh
849f5cc7098a4d64a25aa624bac6d248e8a2ce475994ed233cf8e11b665df4d5
[root@localhost etcd]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
849f5cc7098a quay.io/coreos/etcd:v3.5.16 "/usr/local/bin/etcd..." 7 seconds ago Up 5 seconds 0.0.0.0:2379-2380->2379-2380/tcp etcd-1
四、程序版本检查
bash 复制代码
[root@localhost etcd]# docker exec etcd-1 /usr/local/bin/etcd --version
etcd Version: 3.5.16
Git SHA: f20bbad
Go Version: go1.22.7
Go OS/Arch: linux/amd64
[root@localhost etcd]# docker exec etcd-1 /usr/local/bin/etcdctl version
etcdctl version: 3.5.16
API version: 3.5
[root@localhost etcd]# docker exec etcd-1 /usr/local/bin/etcdutl version
etcdutl version: 3.5.16
API version: 3.5
五、API健康检查
bash 复制代码
[root@localhost etcd]# docker exec etcd-1 /usr/local/bin/etcdctl endpoint health
127.0.0.1:2379 is healthy: successfully committed proposal: took = 3.414086ms
六、容器内数据存取测试
bash 复制代码
[root@localhost etcd]# docker exec etcd-1 /usr/local/bin/etcdctl put foo bar
OK
[root@localhost etcd]# docker exec etcd-1 /usr/local/bin/etcdctl get foo
foo
bar

以上测试了"foo":"bar"键值对,可见数据存取正常

七、容器外接口测试

将容器内的etcdctl程序拷贝到本地,进行接口测试

bash 复制代码
[root@localhost etcd]# docker cp etcd-1:/usr/local/bin/etcdctl .
[root@localhost etcd]# ./etcdctl --endpoints=http://192.168.80.135:2379 version
etcdctl version: 3.5.16
API version: 3.5
八、容器外数据存取测试
bash 复制代码
[root@localhost etcd]# ./etcdctl --endpoints=http://192.168.80.135:2379 get foo
foo
bar
[root@localhost etcd]# ./etcdctl --endpoints=http://192.168.80.135:2379 put www.sina.com.cn 192.168.8.8
[root@localhost etcd]# ./etcdctl --endpoints=http://192.168.80.135:2379 get www.sina.com.cn  
www.sina.com.cn
192.168.8.8

测试新增"www.sina.com.cn":"192.168.8.8"键值对,存取正常。

相关推荐
Source.Liu5 分钟前
【Ubuntu】文件与目录管理命令
linux·运维·ubuntu
Elastic 中国社区官方博客8 分钟前
Agent Builder,超越聊天框:推出增强型基础设施
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
专注echarts研发20年13 分钟前
Qt自定义双击事件实现方案(规避原生双击附带单击问题)
数据库
Linux蓝魔15 分钟前
外网同步所有ubuntu源到内网使用
linux·数据库·ubuntu
墨香幽梦客20 分钟前
系统性能优化技巧:数据库索引、缓存与异步处理的综合应用
数据库·缓存·性能优化
麦麦在写代码38 分钟前
Mysql--DDL语句
数据库·mysql
周公挚友42 分钟前
centos 7.9 防火墙
linux·运维·centos
宇钶宇夕43 分钟前
CoDeSys入门实战一起学习(十六):采样跟踪功能详解
运维·自动化·软件工程
梁正雄1 小时前
linux服务-麒麟10安装sqlserver
linux·运维·sqlserver
飞Link1 小时前
cmd、powershell、linux下命令对比
linux·运维·服务器