Difference between revisions of "VALT Warm Standby"
IVSWikiBlue (talk | contribs) |
IVSWikiBlue (talk | contribs) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 28: | Line 28: | ||
=Primary Server Config= | =Primary Server Config= | ||
− | Run {{Code Block - Mini | text = PrimaryServerConfig.sh}} on the primary server. Make sure to modify the variables at the top of the script to reflect your environment. Specifically the standbyip must be changed to the ip address of the standby server. | + | Run {{Code Block - Mini | text = <span class="code_file">PrimaryServerConfig.sh</span>}} on the primary server. Make sure to modify the variables at the top of the script to reflect your environment. Specifically the standbyip must be changed to the ip address of the standby server. |
The script will complete by providing the log file name and position. Make a note of these values as they will be needed to configure the standby server. | The script will complete by providing the log file name and position. Make a note of these values as they will be needed to configure the standby server. | ||
Line 35: | Line 35: | ||
=Standby Server Config= | =Standby Server Config= | ||
− | #Run {{Code Block - Mini | text = sudo -i}} | + | #Run {{Code Block - Mini | text = <span class="code_regex">sudo</span> <span class="code_option">-i</span>}} |
#:If you do not use this specific command portions of the script will not execute properly. | #:If you do not use this specific command portions of the script will not execute properly. | ||
− | #Run {{Code Block - Mini | text = VALTStandbyServerConfig.sh}} 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 = /usr/local/valt/bin/}} directory and set to executable. These scripts are provided below if the {{Code Block - Mini | text = VALTRedundancy.tar.gz | + | 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 46: | Line 46: | ||
# Update the shared DNS entry to reference the standby server. | # Update the shared DNS entry to reference the standby server. | ||
# Run the script by typing the following command: | # Run the script by typing the following command: | ||
− | #: {{Code Block - Mini | text = sudo /usr/local/valt/bin/failure.sh}} | + | #: {{Code Block - Mini | text = <span class="code_regex">sudo</span> <span class="code_filepath">/usr/local/valt/bin/</span><span class="code_file">failure.sh</span>}} |
<hr> | <hr> | ||
Line 54: | Line 54: | ||
# Update the variables in the script below to reflect the correct primary ip, slaveuser, and slavepassword. <em>(If this was not done during initial setup)</em> | # Update the variables in the script below to reflect the correct primary ip, slaveuser, and slavepassword. <em>(If this was not done during initial setup)</em> | ||
# Run the script by typing the following command: | # Run the script by typing the following command: | ||
− | #: {{Code Block - Mini | text = sudo /usr/local/valt/bin/restore.sh}} | + | #: {{Code Block - Mini | text = <span class="code_regex">sudo</span> <span class="code_filepath">/usr/local/valt/bin/</span><span class="code_file">restore.sh</span>}} |
}} | }} | ||
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.