MySQL Master Slave Repliaction
MySQL Master Slave Repliaction
failover
we have added three spread disk on the vm that we use to create separate directory for the following
mysql backup
also make sure to disable selinuix
once we have setup the separate mount point for the three directory we will now proceed with the
installation
the installation file itself will be compressed , we can use tar -xf to extract the file
now snice we found everything is working fine and we are able to install rpm packages on system, lets
continue installing the reset of the rpm package
note: you need to install the rpm in the order as showing in below command because some rpm
packages relay on the other for dependency
before we start the services for MySQL we need to update config for MySQL to point binlog and MySQL
data to new mount point we created
vi /etc/my.cnf
update datadir and and add log-bin and update it with binlog diretcory
you need to update owner of the directory we have setup for MySQL with MySQL user
chown -R mysql:mysql mysqldata/ chown -R mysql:mysql mysqlbinlog/ chown -R
mysql:mysql mysqlbackup/
update host file db01& db02
using any note editing tool and update the host file we hostname and ip of both DB
vi /etc/hosts
log_bin_trust_function_creators =1
lower_case_table_name=1
performance_schema_consumer_events_statements_history_long = ON
performance_schema=ON
performance-schema-instrument='statement/%=ON'
performance-schema-consumer-statements-digest=ON
innodb_monitor_enable=all
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/mysqldata
socket=/var/lib/mysql/mysql.sock
log-bin=/mysqlbinlog/mysql-bin.log
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
bind-address=0.0.0.0
server-id = 1
log_bin_trust_function_creators =1
lower_case_table_names=1
performance_schema_consumer_events_statements_history_long = ON
performance_schema=ON
performance-schema-instrument='statement/%=ON'
performance-schema-consumer-statements-digest=ON
innodb_monitor_enable=all
innodb_buffer_pool_size=2G
~
set password='password';
exit and login again with root using the password you setup
give the necessary grants for repl user for replication prepose
grant replication slave,backup_admin,clone_admin on *.* to 'repl'@'%';
grant select on performance_schema.* to 'repl'@'%';
to save time we will copy the my.cnf file from db01 to db02 using scp
next we will just update server-id in my.cnf file to unique one than one setup in db01
vi /etc/my.cnf
set password='password';
install plugins on db02 for cloning
now clone the instance using the below command inside mysql console
so the log file is 000007 and postion is 573 this information is important when we start the replica
START REPLICA;
before that obtain the log position from the new primary node (old slave)
stop replica
start replica ;
error is clear you may start testing replication