etcd的单节点手工安装

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/happyredstar/article/details/53195478

etcd的单节点手工安装

 

etcd就两个可执行文件(截至到3.0.15前)。

下载地址:https://github.com/coreos/etcd/releases

 

注:etcd可以集群安装,在这里只想做一个单机测试,所以只是启动一个节点就可以。

 

1. 解压,并将文件放入系统路径中:

tar zxvf etcd-v3.0.15-linux-amd64.tar.gz

cp etcd /usr/bin/

cp etcdctl /usr/bin/

 

2. 创建一个服务描述文件,放入systemd的服务目录下

cat /usr/lib/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/bin/etcd

 

[Install]

WantedBy=multi-user.target

 

3. etcd的配置

cat /etc/etcd/etcd.conf

# [member]

ETCD_NAME=default

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"

ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

 

4. 给etcd创建一个工作目录:

[root@localhost etcd]# mkdir /var/lib/etcd

 

5. 启动etcd,并测试

[root@localhost etcd]# mkdir /etc/etcd

[root@localhost etcd]# cp etcd.conf /etc/etcd/

[root@localhost etcd]# cp etcd.service/usr/lib/systemd/system/

[root@localhost etcd]# systemctl daemon-reload

[root@localhost etcd]# systemctl start etcd

[root@localhost etcd]# systemctl enable etcd

Created symlink from/etc/systemd/system/multi-user.target.wants/etcd.service to/usr/lib/systemd/system/etcd.service.

[root@localhost etcd]# systemctl status etcd

 

[root@localhost etcd]# etcdctl cluster-health

member 8e9e05c52164694d is healthy: got healthyresult from http://localhost:2379

cluster is healthy

 

通过容器启动etcd(另一种方便的方法)

 

如果机器有外网连接,直接使用docker启动etcd也是很方便的:

[root@localhost setup]# docker run --name etcdquay.io/coreos/etcd:v3.0.15

Unable to find image 'quay.io/coreos/etcd:v3.0.15'locally

v3.0.15: Pulling from coreos/etcd

3690ec4760f9: Pull complete

53b6b297c402: Pull complete

0ee7413b6e7d: Pull complete

0b6d568d289d: Pull complete

f79877e4a632: Pull complete

Digest:sha256:aed90a29fbe7ad0e6629b2ea5a290f5b6efb9b719cec97c756df13f1db3760bf

Status: Downloaded newer image forquay.io/coreos/etcd:v3.0.15

2016-11-16 04:01:09.545844 I | etcdmain: etcdVersion: 3.0.15

2016-11-16 04:01:09.545969 I | etcdmain: Git SHA:fc00305

… …

 

通过docker命令查看一下镜像和进程:

[root@localhost ~]# docker ps

CONTAINER ID       IMAGE                         COMMAND                 CREATED             STATUS              PORTS               NAMES

392fa38235b0       quay.io/coreos/etcd:v3.0.15  "/usr/local/bin/etcd"  29 seconds ago      Up 28seconds       2379-2380/tcp       etcd

[root@localhost ~]#

[root@localhost ~]#

[root@localhost ~]# docker images

REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE

quay.io/coreos/etcd  v3.0.15            2bdf33352107        4 daysago          43.43 MB

 

没有更多推荐了,返回首页