From 105767ffd209f62d1ad10a101f5b032c9acde411 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 16 Mar 2020 21:08:52 +0300 Subject: [PATCH] Keep opennebula running on one host, fix /etc/timezone --- etc/keepalived/keepalived.conf.env | 3 +++ etc/one/one-cluster.sh | 17 +++++++++++++++++ general.sh | 3 ++- network.sh | 2 +- opennebula.sh | 19 ++++++++++--------- run.sh | 12 ++++++++++++ 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100755 etc/one/one-cluster.sh diff --git a/etc/keepalived/keepalived.conf.env b/etc/keepalived/keepalived.conf.env index 84119b5..308187e 100644 --- a/etc/keepalived/keepalived.conf.env +++ b/etc/keepalived/keepalived.conf.env @@ -8,6 +8,8 @@ global_defs { smtp_server localhost smtp_connect_timeout 30 router_id $keepalived_router_id + script_user root + enable_script_security } vrrp_instance VI_1 { @@ -26,4 +28,5 @@ vrrp_instance VI_1 { virtual_ipaddress { $keepalived_virtual_ip } + notify /etc/one/one-cluster.sh } diff --git a/etc/one/one-cluster.sh b/etc/one/one-cluster.sh new file mode 100755 index 0000000..4756ac2 --- /dev/null +++ b/etc/one/one-cluster.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +TYPE=$1 +NAME=$2 +STATE=$3 +case $STATE in + "MASTER") systemctl opennebula start; systemctl opennebula-sunstone start + ;; + "BACKUP") systemctl opennebula stop; systemctl opennebula-sunstone stop + ;; + "FAULT") systemctl opennebula stop; systemctl opennebula-sunstone stop + exit 0 + ;; + *) /sbin/logger "ipsec unknown state" + exit 1 + ;; +esac diff --git a/general.sh b/general.sh index 07e3478..4e8425b 100755 --- a/general.sh +++ b/general.sh @@ -48,8 +48,9 @@ wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add - apt-get update || true +rm /etc/timezone echo Europe/Moscow > /etc/timezone -ln -fs /usr/share/zoneinfo/Europe/Moscow /etc/timezone +ln -fs /usr/share/zoneinfo/Europe/Moscow /etc/localtime if ! grep -q '^PermitRootLogin' /etc/ssh/sshd_config; then echo PermitRootLogin without-password >> /etc/ssh/sshd_config diff --git a/network.sh b/network.sh index 1634278..94f75f9 100755 --- a/network.sh +++ b/network.sh @@ -35,7 +35,7 @@ ssh root@$play_host ' ip link set $oldname down ip link set dev $oldname name $newname ip link set $newname up - if [ -e /run/network/ifstate.$oldname ]; then + if [ -e /run/network/ifstate.$oldname -a x`cat /run/network/ifstate.$oldname` != "x" ]; then rm -f /run/network/ifstate.$oldname echo $newname > /run/network/ifstate.$newname fi diff --git a/opennebula.sh b/opennebula.sh index 17cb9d1..96cceb5 100755 --- a/opennebula.sh +++ b/opennebula.sh @@ -43,11 +43,6 @@ DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" \ /usr/share/one/install_gems --yes EOF -### Setup keepalived -envsubst < ./etc/keepalived/keepalived.conf.env | \ - ssh root@$play_host 'cat > /etc/keepalived/keepalived.conf' -ssh root@$play_host 'systemctl restart keepalived' - ### Setup or join MariaDB Galera Cluster # Create a user for Galera (if not yet) @@ -126,12 +121,18 @@ while ! echo SELECT 1 | mysql; do echo Waiting for MySQL... done -systemctl enable opennebula -systemctl enable opennebula-sunstone -systemctl restart opennebula -systemctl restart opennebula-sunstone +systemctl disable opennebula +systemctl disable opennebula-sunstone +systemctl stop opennebula +systemctl stop opennebula-sunstone EOF +### Setup keepalived +scp etc/one/one-cluster.sh root@$play_host:/etc/one/ +envsubst < ./etc/keepalived/keepalived.conf.env | \ + ssh root@$play_host 'cat > /etc/keepalived/keepalived.conf' +ssh root@$play_host 'chmod 755 /etc/one/one-cluster.sh && systemctl restart keepalived' + # Setup onedns envsubst < ./etc/systemd/system/onedns.service.env | \ ssh root@$play_host 'cat > /etc/systemd/system/onedns.service' diff --git a/run.sh b/run.sh index c58053b..e2f8757 100755 --- a/run.sh +++ b/run.sh @@ -2,6 +2,18 @@ set -e -x +play_host=172.31.1.5 node_name=mature2 int_ip=192.168.5.12 ./general.sh +play_host=172.31.1.5 node_name=mature2 int_ip=192.168.5.12 ./opennebula.sh +play_host=172.31.1.5 node_name=mature2 int_ip=192.168.5.12 ./ceph.sh + +exit + +play_host=172.31.1.10 node_name=mature3 int_ip=192.168.5.13 ./general.sh +play_host=172.31.1.10 node_name=mature3 int_ip=192.168.5.13 ./opennebula.sh +play_host=172.31.1.10 node_name=mature3 int_ip=192.168.5.13 ./ceph.sh + +exit + play_host=172.31.1.9 node_name=ripper4 int_ip=192.168.5.14 ./general.sh play_host=172.31.1.9 node_name=ripper4 int_ip=192.168.5.14 ./opennebula.sh play_host=172.31.1.9 node_name=ripper4 int_ip=192.168.5.14 ./ceph.sh