Difference between revisions of "VALT Warm Standby"
IVSWikiBlue (talk | contribs) |
IVSWikiBlue (talk | contribs) |
||
(One intermediate revision by the same user not shown) | |||
Line 39: | Line 39: | ||
#Run {{Code Block - Mini | text = <span class="code_file">VALTStandbyServerConfig.sh</span>}} on the standby server. Make sure to modify the variables at the top of the script to reflect your environment. Specifically the primaryip must be changed to the ip address of the primary server, the logfile and logpos variables must be set to the values output when running the script on the primary server. | #Run {{Code Block - Mini | text = <span class="code_file">VALTStandbyServerConfig.sh</span>}} on the standby server. Make sure to modify the variables at the top of the script to reflect your environment. Specifically the primaryip must be changed to the ip address of the primary server, the logfile and logpos variables must be set to the values output when running the script on the primary server. | ||
− | If using the VALTRedundancy.tar.gz package, the failure.sh and restore.sh scripts should automatically be copied to the {{Code Block - Mini | text = <span class="code_filepath">/usr/local/valt/bin/</span>}} directory and set to executable. These scripts are provided below if the {{Code Block - Mini | text = <span class="code_2">VALTRedundancy.tar.gz</span> | + | If using the VALTRedundancy.tar.gz package, the failure.sh and restore.sh scripts should automatically be copied to the {{Code Block - Mini | text = <span class="code_filepath">/usr/local/valt/bin/</span>}} directory and set to executable. These scripts are provided below if the {{Code Block - Mini | text = <span class="code_2">VALTRedundancy.tar.gz</span>}} package was not used. It is a good idea to update the variables in these scripts now so they are ready to be used in the event of a failover. |
<hr> | <hr> | ||
Line 63: | Line 63: | ||
# This script will configure an existing VALT server to function as a primary server. | # This script will configure an existing VALT server to function as a primary server. | ||
# You will need to run VALTStandbyServerConfig.sh on the warm standby server. | # You will need to run VALTStandbyServerConfig.sh on the warm standby server. | ||
− | standbyip=" | + | standbyip="ENTER_STANDBY_SERVER_IP" |
dbuser="ivsadmin" | dbuser="ivsadmin" | ||
− | dbpass=" | + | dbpass="admin51" |
slaveuser="ivs_user" | slaveuser="ivs_user" | ||
− | slavepassword=" | + | slavepassword="admin51" |
echo "WARNING: DO NOT RUN THIS SCRIPT MULTIPLE TIMES!!!" | echo "WARNING: DO NOT RUN THIS SCRIPT MULTIPLE TIMES!!!" | ||
Line 81: | Line 81: | ||
echo -e "ivsadmin ALL=(ALL) NOPASSWD: /usr/bin/rsync,/usr/bin/systemd-resolve" >> /etc/sudoers | echo -e "ivsadmin ALL=(ALL) NOPASSWD: /usr/bin/rsync,/usr/bin/systemd-resolve" >> /etc/sudoers | ||
− | + | if [ -s "/usr/local/valt/conf/valtconfig" ]; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | if [ -s "/usr/local/valt/conf/ | ||
then | then | ||
− | ipaddress=$(</usr/local/valt/conf/ | + | ipaddress=$(</usr/local/valt/conf/valtconfig) |
fi | fi | ||
sed -i "s|bind-address|#bind-address|g" /etc/mysql/mysql.conf.d/mysqld.cnf | sed -i "s|bind-address|#bind-address|g" /etc/mysql/mysql.conf.d/mysqld.cnf | ||
Line 95: | Line 89: | ||
echo -e "server-id\t\t= 1" >> /etc/mysql/mysql.conf.d/mysqld.cnf | echo -e "server-id\t\t= 1" >> /etc/mysql/mysql.conf.d/mysqld.cnf | ||
echo -e "log_bin\t\t\t= /var/log/mysql/mysql-bin.log" >> /etc/mysql/mysql.conf.d/mysqld.cnf | echo -e "log_bin\t\t\t= /var/log/mysql/mysql-bin.log" >> /etc/mysql/mysql.conf.d/mysqld.cnf | ||
− | echo -e "binlog_do_db\t\t= | + | echo -e "binlog_do_db\t\t= valt" >> /etc/mysql/mysql.conf.d/mysqld.cnf |
service mysql restart | service mysql restart | ||
− | sed -i "s| | + | ######sed -i "s|HOST|HOST: $ipaddress|g" /var/www/valt/.env.local##### |
iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT | iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT | ||
iptables -A OUTPUT -p tcp -m tcp --dport 22 -j ACCEPT | iptables -A OUTPUT -p tcp -m tcp --dport 22 -j ACCEPT | ||
Line 103: | Line 97: | ||
mysql --defaults-extra-file=/etc/mysql/debian.cnf -e "GRANT REPLICATION SLAVE ON *.* TO '$slaveuser'@'$standbyip' IDENTIFIED BY '$slavepassword';" | mysql --defaults-extra-file=/etc/mysql/debian.cnf -e "GRANT REPLICATION SLAVE ON *.* TO '$slaveuser'@'$standbyip' IDENTIFIED BY '$slavepassword';" | ||
mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "FLUSH PRIVILEGES;" | mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "FLUSH PRIVILEGES;" | ||
− | mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "USE | + | mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "USE valt;" |
mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "FLUSH TABLES WITH READ LOCK;" | mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "FLUSH TABLES WITH READ LOCK;" | ||
− | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf | + | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf valt -e "SHOW MASTER STATUS\G;" | grep File) |
sqlfile=${tmp1#*:} | sqlfile=${tmp1#*:} | ||
− | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf | + | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf valt -e "SHOW MASTER STATUS\G;" | grep Position) |
position=${tmp1#*:} | position=${tmp1#*:} | ||
sqlfile=$(echo $sqlfile | xargs) | sqlfile=$(echo $sqlfile | xargs) | ||
− | mysqldump --defaults-extra-file=/usr/local/valt/conf/sql.cnf --opt | + | mysqldump --defaults-extra-file=/usr/local/valt/conf/sql.cnf --opt valt > /usr/local/valt/backup/valt_sync.sql |
mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "UNLOCK TABLES;" | mysql --defaults-extra-file=/usr/local/valt/conf/sql.cnf -e "UNLOCK TABLES;" | ||
netfilter-persistent save | netfilter-persistent save | ||
Line 127: | Line 121: | ||
primaryuser="ivsadmin" | primaryuser="ivsadmin" | ||
− | primarypass=" | + | primarypass="admin51" |
− | primaryip=" | + | primaryip="ENTER_PRIMARY_SERVER_IP" |
slaveuser="ivs_user" | slaveuser="ivs_user" | ||
− | slavepassword=" | + | slavepassword="admin51" |
logfile="" | logfile="" | ||
logpos="" | logpos="" | ||
Line 148: | Line 142: | ||
ssh-keygen -t rsa -f /root/.ssh/id_rsa -q -N "" | ssh-keygen -t rsa -f /root/.ssh/id_rsa -q -N "" | ||
ssh-copy-id -i /root/.ssh/id_rsa.pub ivsadmin@$primaryip | ssh-copy-id -i /root/.ssh/id_rsa.pub ivsadmin@$primaryip | ||
− | rsync --rsync-path="sudo rsync" -avz ivsadmin@$primaryip:/usr/local/ | + | rsync --rsync-path="sudo rsync" -avz ivsadmin@$primaryip:/usr/local/valt/records/* /usr/local/valt/records/ |
− | (crontab -l ; echo -e '00 11 * * * rsync --rsync-path="sudo rsync" -avz ivsadmin@$primaryip:/usr/local/ | + | (crontab -l ; echo -e '00 11 * * * rsync --rsync-path="sudo rsync" -avz ivsadmin@$primaryip:/usr/local/valt/records/* /usr/local/valt/records/') | crontab - |
service apache2 stop | service apache2 stop | ||
service WowzaStreamingEngine stop | service WowzaStreamingEngine stop | ||
Line 163: | Line 157: | ||
mkdir /etc/apache2/ssl | mkdir /etc/apache2/ssl | ||
scp ivsadmin@$primaryip:/etc/apache2/ssl/* /etc/apache2/ssl | scp ivsadmin@$primaryip:/etc/apache2/ssl/* /etc/apache2/ssl | ||
− | scp ivsadmin@$primaryip:/etc/apache2/sites-enabled/ | + | scp ivsadmin@$primaryip:/etc/apache2/sites-enabled/valt.conf /etc/apache2/sites-enabled/ |
scp ivsadmin@$primaryip:/usr/local/WowzaStreamingEngine/conf/valtwowza.jks /usr/local/WowzaStreamingEngine/conf/ | scp ivsadmin@$primaryip:/usr/local/WowzaStreamingEngine/conf/valtwowza.jks /usr/local/WowzaStreamingEngine/conf/ | ||
− | scp ivsadmin@$primaryip:/var/www/ | + | scp ivsadmin@$primaryip:/var/www/valt/nodejs/* /var/www/valt/nodejs/ |
scp ivsadmin@$primaryip:/usr/local/WowzaStreamingEngine/java/lib/security/cacerts /usr/local/WowzaStreamingEngine/java/lib/security/ | scp ivsadmin@$primaryip:/usr/local/WowzaStreamingEngine/java/lib/security/cacerts /usr/local/WowzaStreamingEngine/java/lib/security/ | ||
scp ivsadmin@$primaryip:/usr/local/WowzaStreamingEngine/conf/VHost.xml /usr/local/WowzaStreamingEngine/conf/ | scp ivsadmin@$primaryip:/usr/local/WowzaStreamingEngine/conf/VHost.xml /usr/local/WowzaStreamingEngine/conf/ | ||
Line 186: | Line 180: | ||
echo -e "password=$primarypass" >> /usr/local/valt/conf/primary.cnf | echo -e "password=$primarypass" >> /usr/local/valt/conf/primary.cnf | ||
− | mysqldump --defaults-extra-file=/usr/local/valt/conf/standby.cnf --opt | + | mysqldump --defaults-extra-file=/usr/local/valt/conf/standby.cnf --opt valt > /usr/local/valt/backup/valt_orig.sql |
− | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "DROP DATABASE | + | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "DROP DATABASE valt;" |
− | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CREATE DATABASE | + | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CREATE DATABASE valt;" |
− | scp ivsadmin@$primaryip:/usr/local/valt/backup/ | + | scp ivsadmin@$primaryip:/usr/local/valt/backup/valt_sync.sql /usr/local/valt/backup/valt_sync.sql |
− | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf | + | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf valt < /usr/local/valt/backup/valt_sync.sql |
echo -e "server-id\t\t= 2" >> /etc/mysql/mysql.conf.d/mysqld.cnf | echo -e "server-id\t\t= 2" >> /etc/mysql/mysql.conf.d/mysqld.cnf | ||
echo -e "relay-log\t\t= /var/log/mysql/mysql-relay-bin.log" >> /etc/mysql/mysql.conf.d/mysqld.cnf | echo -e "relay-log\t\t= /var/log/mysql/mysql-relay-bin.log" >> /etc/mysql/mysql.conf.d/mysqld.cnf | ||
echo -e "log_bin\t\t\t= /var/log/mysql/mysql-bin.log" >> /etc/mysql/mysql.conf.d/mysqld.cnf | echo -e "log_bin\t\t\t= /var/log/mysql/mysql-bin.log" >> /etc/mysql/mysql.conf.d/mysqld.cnf | ||
− | echo -e "binlog_do_db\t\t= | + | echo -e "binlog_do_db\t\t= valt" >> /etc/mysql/mysql.conf.d/mysqld.cnf |
service mysql restart | service mysql restart | ||
mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CHANGE MASTER TO MASTER_HOST='$primaryip',MASTER_USER='$slaveuser', MASTER_PASSWORD='$slavepassword', MASTER_LOG_FILE='$logfile', MASTER_LOG_POS= $logpos;" | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CHANGE MASTER TO MASTER_HOST='$primaryip',MASTER_USER='$slaveuser', MASTER_PASSWORD='$slavepassword', MASTER_LOG_FILE='$logfile', MASTER_LOG_POS= $logpos;" | ||
Line 203: | Line 197: | ||
chmod +x /usr/local/valt/bin/restore.sh | chmod +x /usr/local/valt/bin/restore.sh | ||
fi | fi | ||
+ | |||
</pre> | </pre> | ||
}} | }} | ||
Line 261: | Line 256: | ||
systemctl disable valtcontrols | systemctl disable valtcontrols | ||
systemctl disable WowzaStreamingEngine | systemctl disable WowzaStreamingEngine | ||
− | rsync --rsync-path="sudo rsync" -avz /usr/local/ | + | rsync --rsync-path="sudo rsync" -avz /usr/local/valt/records/* ivsadmin@10.111.3.73:/usr/local/valt/records/ |
− | mysqldump --defaults-extra-file=/usr/local/valt/conf/standby.cnf --opt v3 > /usr/local/valt/backup/ | + | mysqldump --defaults-extra-file=/usr/local/valt/conf/standby.cnf --opt v3 > /usr/local/valt/backup/valt.sql |
− | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf -e "DROP DATABASE | + | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf -e "DROP DATABASE valt;" |
− | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf -e "CREATE DATABASE | + | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf -e "CREATE DATABASE valt;" |
− | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf | + | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf valt < /usr/local/valt/backup/valt.sql |
− | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf | + | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf valt -e "FLUSH TABLES WITH READ LOCK;" |
− | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf | + | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf valt -e "SHOW MASTER STATUS\G;" | grep File) |
sqlfile=${tmp1#*:} | sqlfile=${tmp1#*:} | ||
− | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf | + | tmp1=$(mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf valt -e "SHOW MASTER STATUS\G;" | grep Position) |
position=${tmp1#*:} | position=${tmp1#*:} | ||
sqlfile=$(echo $sqlfile | xargs) | sqlfile=$(echo $sqlfile | xargs) | ||
− | mysqldump --defaults-extra-file=/usr/local/valt/conf/primary.cnf --opt | + | mysqldump --defaults-extra-file=/usr/local/valt/conf/primary.cnf --opt valt > /usr/local/valt/backup/valt_sync.sql |
− | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf | + | mysql --defaults-extra-file=/usr/local/valt/conf/primary.cnf valt -e "UNLOCK TABLES;" |
− | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "DROP DATABASE | + | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "DROP DATABASE valt;" |
− | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CREATE DATABASE | + | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CREATE DATABASE valt;" |
− | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf | + | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf valt < /usr/local/valt/backup/valt_sync.sql |
mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CHANGE MASTER TO MASTER_HOST="\'"$primaryip"\'", MASTER_USER="\'"$slaveuser"\'", MASTER_PASSWORD="\'"$slavepassword"\'", MASTER_LOG_FILE="\'"$sqlfile"\'", MASTER_LOG_POS = $position;" | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "CHANGE MASTER TO MASTER_HOST="\'"$primaryip"\'", MASTER_USER="\'"$slaveuser"\'", MASTER_PASSWORD="\'"$slavepassword"\'", MASTER_LOG_FILE="\'"$sqlfile"\'", MASTER_LOG_POS = $position;" | ||
mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "START SLAVE;" | mysql --defaults-extra-file=/usr/local/valt/conf/standby.cnf -e "START SLAVE;" |
Latest revision as of 08:26, 24 October 2023
⚠DISCLAIMER: This is not a step by step instruction. This article assumes the reader has a working understanding of the VALT application and how to modify the configuration files. This procedure should only be completed by an IVS support engineer. This may be incorporated into the command line menu in the future.