k8x/systemd/install_etcd.sh

57 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2024-05-17 21:45:52 -04:00
#!/bin/bash
echo ""
echo "... ] INSTALLING ETCD [ ..."
HOME=$( cd "$(dirname "$0")" && pwd )
source $HOME/../config
systemctl stop etcd.service
gzip -v -c -d $HOME/../blobs/etcd.gz > /usr/local/bin/etcd
chmod +x /usr/local/bin/etcd
#create new db dir
mkdir -p /var/lib/etcd/
cat <<EOF | tee /etc/systemd/system/etcd.service
[Unit]
Description=etcd
Documentation=https://coreos.com/etcd/docs/latest/
After=network.target
[Service]
User=root
Type=notify
ExecStart=/usr/local/bin/etcd \\
--name=${NODE_NAME_SHORT} \\
--listen-client-urls=https://${ETCD_IP}:2379,https://127.0.0.1:2379 \\
--advertise-client-urls=https://${ETCD_IP}:2379 \\
--data-dir=/var/lib/etcd \\
--cert-file=${CA_DIR}/etcd.crt \\
--key-file=${CA_DIR}/etcd.key \\
--peer-cert-file=${CA_DIR}/etcd-peer.crt \\
--peer-key-file=${CA_DIR}/etcd-peer.key \\
--trusted-ca-file=${CA_DIR}/etcd-ca.crt \\
--peer-trusted-ca-file=${CA_DIR}/etcd-ca.crt \\
--peer-client-cert-auth \\
--listen-peer-urls=https://${ETCD_IP}:2380 \\
--client-cert-auth \\
--initial-advertise-peer-urls=https://${ETCD_IP}:2380 \\
--initial-cluster-token="k8x-21b5f25de1" \\
--initial-cluster=${ETCD_1_NAME}=https://${ETCD_1_IP}:2380,${ETCD_2_NAME}=https://${ETCD_2_IP}:2380,${ETCD_3_NAME}=https://${ETCD_3_IP}:2380 \\
--initial-cluster-state=new
Restart=always
RestartSec=10s
LimitNOFILE=40000
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable etcd.service
systemctl start etcd.service