Keep opennebula running on one host, fix /etc/timezone

master
Vitaliy Filippov 2020-03-16 21:08:52 +03:00
parent 5c4576a886
commit 105767ffd2
6 changed files with 45 additions and 11 deletions

View File

@ -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
}

17
etc/one/one-cluster.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

12
run.sh
View File

@ -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