etcd2 不會在 CoreOS 上通過 systemctl 啟動
真的希望有人可以在這裡幫助我。我有一個 CoreOS etcd2 成員的磁碟已滿。重新啟動後,etcd2 情況不佳。最終,我刪除了 /var/lib/etcd2/member 數據目錄,並按照說明將機器刪除並重新添加到我的集群,如下所述:https ://coreos.com/etcd/docs/latest/runtime- configuration.html#remove-a-member
但是,雖然我可以手動執行 etcd2,但嘗試使用 systemctl 啟動它是行不通的。這是 etcd2.service:
[Unit] Description=etcd2 Conflicts=etcd.service [Service] User=etcd Type=notify Environment=ETCD_DATA_DIR=/var/lib/etcd2 Environment=ETCD_NAME=%m ExecStart=/usr/bin/etcd2 Restart=always RestartSec=10s LimitNOFILE=40000 TimeoutStartSec=0 [Install] WantedBy=multi-user.target # /run/systemd/system/etcd2.service.d/10-oem.conf [Service] Environment=ETCD_ELECTION_TIMEOUT=1200 # /run/systemd/system/etcd2.service.d/20-cloudinit.conf [Service] Environment="ETCD_ADVERTISE_CLIENT_URLS=http://172.31.9.22:2379,http://172.31.9.22:4001" Environment="ETCD_DISCOVERY=https://discovery.etcd.io/567d080563e28e62cf886e48425f632b" Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://172.31.9.22:2380" Environment="ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379" Environment="ETCD_LISTEN_PEER_URLS=http://172.31.9.22:2380" Environment="ETCD_DEBUG=true"
我添加了 ETCD_DEBUG=true 來嘗試改進日誌輸出。說到這裡:
Feb 26 07:23:36 geo-coreos-database-02 systemd[1]: Starting etcd2... Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_ADVERTISE_CLIENT_URLS=http://172.31.9.22:2379,http://172.31.9.22:4001 Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_DATA_DIR=/var/lib/etcd2 Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_DEBUG=true Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_DISCOVERY=https://discovery.etcd.io/567d080563e28e62cf886e48425f632b Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_ELECTION_TIMEOUT=1200 Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_INITIAL_ADVERTISE_PEER_URLS=http://172.31.9.22:2380 Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 Feb 26 07:23:36 geo-coreos-database-02 etcd2[2939]: recognized and used environment variable ETCD_LISTEN_PEER_URLS=http://172.31.9.22:2380 Feb 26 07:23:37 geo-coreos-database-02 systemd[1]: etcd2.service: Main process exited, code=exited, status=1/FAILURE Feb 26 07:23:37 geo-coreos-database-02 systemd[1]: Failed to start etcd2. Feb 26 07:23:37 geo-coreos-database-02 systemd[1]: etcd2.service: Unit entered failed state. Feb 26 07:23:37 geo-coreos-database-02 systemd[1]: etcd2.service: Failed with result 'exit-code'.
不是很有幫助。但是,當我手動執行它時,基於 etcd2.service 的配置,伺服器啟動並在前台執行而沒有問題:
export ETCD_NAME="e0a8edc41f634fcf9451b5c68e3442bd" export ETCD_DATA_DIR=/var/lib/etcd2 export ETCD_ADVERTISE_CLIENT_URLS=http://172.31.9.22:2379,http://172.31.9.22:4001 export ETCD_DISCOVERY=https://discovery.etcd.io/567d080563e28e62cf886e48425f632b export ETCD_INITIAL_ADVERTISE_PEER_URLS=http://172.31.9.22:2380 export ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 export ETCD_LISTEN_PEER_URLS=http://172.31.9.22:2380 export ETCD_DEBUG=true etcd2
這將啟動伺服器,並按照我的預期進行調試,我什至可以在伺服器上執行 etcdctl 命令。對於如何進一步調試,我完全不知所措。我絕對不想為如此瑣碎的事情創建一個新的集群,但這似乎總是 etcd 的方式,這是唯一給我們帶來問題的東西,而且它們通常是這樣的,晦澀難懂且難以修復。
當然,我在發布問題後會立即解決這個問題。當我第一次手動執行命令時,我是以 root 使用者身份執行的。因此數據目錄歸根使用者所有,而不是 etcd 使用者。更改權限解決了這個問題。即使在調試模式下,它也沒有記錄它仍然非常糟糕……
我正在使用雲配置,我必須添加
initial-cluster-state: existing
到我的雲配置中。如果沒有這個initial-cluster-state
預設設置new
,我重新添加的節點似乎正在拾取它的舊 GUID,該 GUID 已被“永久刪除”並導致 etcd2 無法啟動。
initial-cluster-state: existing
這是我的雲配置中沒有的日誌日誌:Jun 03 11:10:36 giscoreos2 systemd[1]: Stopped etcd2. Jun 03 11:10:36 giscoreos2 systemd[1]: Starting etcd2... Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_ADVERTISE_CLIENT_URLS=http://giscoreos2.example.com:2379 Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_DATA_DIR=/var/lib/etcd2 Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_DISCOVERY_SRV=example-corp.us Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_INITIAL_ADVERTISE_PEER_URLS=http://giscoreos2.example.com:2380 Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-1 Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_LISTEN_PEER_URLS=http://giscoreos2.example.com:2380 Jun 03 11:10:36 giscoreos2 etcd2[19970]: recognized and used environment variable ETCD_NAME=giscoreos2 Jun 03 11:10:36 giscoreos2 etcd2[19970]: etcd Version: 2.3.1 Jun 03 11:10:36 giscoreos2 etcd2[19970]: Git SHA: 2b67f52 Jun 03 11:10:36 giscoreos2 etcd2[19970]: Go Version: go1.5.3 Jun 03 11:10:36 giscoreos2 etcd2[19970]: Go OS/Arch: linux/amd64 Jun 03 11:10:36 giscoreos2 etcd2[19970]: setting maximum number of CPUs to 16, total number of available CPUs is 16 Jun 03 11:10:36 giscoreos2 etcd2[19970]: the server is already initialized as member before, starting as etcd member... Jun 03 11:10:36 giscoreos2 etcd2[19970]: got bootstrap from DNS for etcd-server at http://giscoreos3.example.com:2380 Jun 03 11:10:36 giscoreos2 etcd2[19970]: got bootstrap from DNS for etcd-server at http://giscoreos1.example.com:2380 Jun 03 11:10:36 giscoreos2 etcd2[19970]: got bootstrap from DNS for etcd-server at http://giscoreos2.example.com:2380 Jun 03 11:10:36 giscoreos2 etcd2[19970]: listening for peers on http://giscoreos2.example.com:2380 Jun 03 11:10:36 giscoreos2 etcd2[19970]: listening for client requests on http://0.0.0.0:2379 Jun 03 11:10:36 giscoreos2 etcd2[19970]: name = giscoreos2 Jun 03 11:10:36 giscoreos2 etcd2[19970]: data dir = /var/lib/etcd2 Jun 03 11:10:36 giscoreos2 etcd2[19970]: member dir = /var/lib/etcd2/member Jun 03 11:10:36 giscoreos2 etcd2[19970]: heartbeat = 100ms Jun 03 11:10:36 giscoreos2 etcd2[19970]: election = 1000ms Jun 03 11:10:36 giscoreos2 etcd2[19970]: snapshot count = 10000 Jun 03 11:10:36 giscoreos2 etcd2[19970]: advertise client URLs = http://giscoreos2.example.com:2379 Jun 03 11:10:36 giscoreos2 etcd2[19970]: restarting member d5f2eb850214f772 in cluster e1013a21e485d6ec at commit index 3 Jun 03 11:10:36 giscoreos2 etcd2[19970]: d5f2eb850214f772 became follower at term 242 Jun 03 11:10:36 giscoreos2 etcd2[19970]: newRaft d5f2eb850214f772 [peers: [], term: 242, commit: 3, applied: 0, lastindex: 3, lastterm: 1] Jun 03 11:10:36 giscoreos2 etcd2[19970]: starting server... [version: 2.3.1, cluster version: to_be_decided] Jun 03 11:10:36 giscoreos2 systemd[1]: Started etcd2. Jun 03 11:10:36 giscoreos2 etcd2[19970]: failed to find member c7f5106228d2b8a7 in cluster e1013a21e485d6ec Jun 03 11:10:36 giscoreos2 etcd2[19970]: failed to find member c7f5106228d2b8a7 in cluster e1013a21e485d6ec Jun 03 11:10:36 giscoreos2 etcd2[19970]: added member 2350c0e41172376a [http://giscoreos1.example.com:2380] to cluster e1013a21e485d6ec Jun 03 11:10:36 giscoreos2 systemd[1]: Starting Network fabric for containers... Jun 03 11:10:36 giscoreos2 etcd2[19970]: the member has been permanently removed from the cluster Jun 03 11:10:36 giscoreos2 etcd2[19970]: the data-dir used by this member must be removed. Jun 03 11:10:36 giscoreos2 etcd2[19970]: streaming request ignored (ID mismatch got b584365ea9e04f4d want d5f2eb850214f772) Jun 03 11:10:36 giscoreos2 etcd2[19970]: streaming request ignored (ID mismatch got b584365ea9e04f4d want d5f2eb850214f772) Jun 03 11:10:36 giscoreos2 etcd2[19970]: added member c7f5106228d2b8a7 [http://giscoreos3.example.com:2380] to cluster e1013a21e485d6ec Jun 03 11:10:36 giscoreos2 etcd2[19970]: added local member d5f2eb850214f772 [http://giscoreos2.example.com:2380] to cluster e1013a21e485d6ec Jun 03 11:10:36 giscoreos2 etcd2[19970]: aborting publish because server is stopped
initial-cluster-state: existing
這是我的雲配置中的日記:Jun 03 11:19:02 giscoreos2 systemd[1]: Starting etcd2... Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_ADVERTISE_CLIENT_URLS=http://giscoreos2.example.com:2379 Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_DATA_DIR=/var/lib/etcd2 Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_DISCOVERY_SRV=exammple-corp.us Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_INITIAL_ADVERTISE_PEER_URLS=http://giscoreos2.example.com:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_INITIAL_CLUSTER_STATE=existing Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-1 Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_LISTEN_PEER_URLS=http://giscoreos2.example.com:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: recognized and used environment variable ETCD_NAME=giscoreos2 Jun 03 11:19:02 giscoreos2 etcd2[20222]: etcd Version: 2.3.1 Jun 03 11:19:02 giscoreos2 etcd2[20222]: Git SHA: 2b67f52 Jun 03 11:19:02 giscoreos2 etcd2[20222]: Go Version: go1.5.3 Jun 03 11:19:02 giscoreos2 etcd2[20222]: Go OS/Arch: linux/amd64 Jun 03 11:19:02 giscoreos2 etcd2[20222]: setting maximum number of CPUs to 16, total number of available CPUs is 16 Jun 03 11:19:02 giscoreos2 etcd2[20222]: got bootstrap from DNS for etcd-server at http://giscoreos1.example.com:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: got bootstrap from DNS for etcd-server at http://giscoreos2.example.com:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: got bootstrap from DNS for etcd-server at http://giscoreos3.example.com:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: listening for peers on http://giscoreos2.example.com:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: listening for client requests on http://0.0.0.0:2379 Jun 03 11:19:02 giscoreos2 etcd2[20222]: resolving giscoreos1.example.com:2380 to 10.240.160.152:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: resolving giscoreos1.example.com:2380 to 10.240.160.152:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: resolving giscoreos2.example.com:2380 to 10.240.160.57:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: resolving giscoreos2.example.com:2380 to 10.240.160.57:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: resolving giscoreos3.example.com:2380 to 10.240.160.6:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: resolving giscoreos3.example.com:2380 to 10.240.160.6:2380 Jun 03 11:19:02 giscoreos2 etcd2[20222]: name = giscoreos2 Jun 03 11:19:02 giscoreos2 etcd2[20222]: data dir = /var/lib/etcd2 Jun 03 11:19:02 giscoreos2 etcd2[20222]: member dir = /var/lib/etcd2/member Jun 03 11:19:02 giscoreos2 etcd2[20222]: heartbeat = 100ms Jun 03 11:19:02 giscoreos2 etcd2[20222]: election = 1000ms Jun 03 11:19:02 giscoreos2 etcd2[20222]: snapshot count = 10000 Jun 03 11:19:02 giscoreos2 etcd2[20222]: advertise client URLs = http://giscoreos2.example.com:2379 Jun 03 11:19:02 giscoreos2 etcd2[20222]: starting member b584365ea9e04f4d in cluster e1013a21e485d6ec Jun 03 11:19:02 giscoreos2 etcd2[20222]: b584365ea9e04f4d became follower at term 0 Jun 03 11:19:02 giscoreos2 etcd2[20222]: newRaft b584365ea9e04f4d [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0] Jun 03 11:19:02 giscoreos2 etcd2[20222]: b584365ea9e04f4d became follower at term 1 Jun 03 11:19:02 giscoreos2 etcd2[20222]: the connection with 2350c0e41172376a became active Jun 03 11:19:02 giscoreos2 etcd2[20222]: starting server... [version: 2.3.1, cluster version: to_be_decided] Jun 03 11:19:02 giscoreos2 systemd[1]: Started etcd2.