my sql 5.6 master slave and master-master replication.step by step configuration instructions
DESCRIPTION
MySQL 5.6 With master-slave and master-master replication. Step by step configuration instructions.TRANSCRIPT
MySQL 5.6 master-slave and master-master replication. Step by step configuration instructions.
******************************************************************A MySQL server package (mysqlserver5.0.774.el5_5.4) is installed.
The current MySQL server package is provided by a differentvendor (CentOS) than MySQL AB, Sun Microsystems, Inc., or Oracle and/or its affiliates.Some files may be installed to different locations, including logfiles and the service startup script in /etc/init.d/.
Upgrading directly from MySQL 5.0 to MySQL 5.6 may notbe safe in all cases. A manual dump and restore using mysqldump isrecommended. It is important to review the MySQL manual's Upgradingsection for versionspecific incompatibilities.A manual upgrade is required. Ensure that you have a complete, working backup of your data and my.cnf files. Shut down the MySQL server cleanly Remove the existing MySQL packages. Usually this command will list the packages you should remove: rpm qa | grep i '^mysql'
You may choose to use 'rpm nodeps ev <packagename>' to remove the package which contains the mysqlclient shared library. The library will be reinstalled by the MySQLsharedcompat package. Install the new MySQL packages supplied by Oracle and/or its affiliates Ensure that the MySQL server is started Run the 'mysql_upgrade' program
This is a brief description of the upgrade process. Important detailscan be found in the MySQL manual, in the Upgrading section.
****************************************************************** Mysql 5.6 RPM Installation steps [root@test45 /]#rpm ivh MySQLserver5.6.131.linux_glibc2.5.x86_64.rpm [root@test45 /]#rpm ivh MySQLclient5.6.131.linux_glibc2.5.x86_64.rpm [root@test45 /]# rpm ivh MySQLdevel5.6.131.linux_glibc2.5.x86_64.rpm [root@test45 /]#service mysql restart
Note : if you get below error then
Starting MySQL ERROR! Couldn't find MySQL server (/var/lib/bin/mysqld_safe)
Starting MySQL ERROR! Couldn't find MySQL server (/var/lib/bin/mysqld_safe)
[root@test45 mysql]# service mysql restartShutting down MySQL.. SUCCESS! Starting MySQL ERROR! Couldn't find MySQL server (/var/lib/bin/mysqld_safe)
[root@test45 mysql]# mkdir /var/lib/bin
[root@test45 mysql]# service mysql restart ERROR! MySQL server PID file could not be found!Starting MySQL ERROR! Couldn't find MySQL server (/var/lib/bin/mysqld_safe)
[root@test45 /]# find -name mysqlmanager[root@test45 /]# find -name mysqld_safe./usr/bin/mysqld_safe
[root@test45 /]# cp ./usr/bin/mysqld_safe /var/lib/bin/.
[root@test45 mysql]# service mysql restartERROR! MySQL server PID file could not be found!Starting MySQL.. SUCCESS!
[root@test45 /]# service mysql status SUCCESS! MySQL running (5697)[root@test45 /]# rm -rf /usr/local/mysql/var/[MyNAS].pid
[root@test45 /]# !seservice mysql statusSUCCESS! MySQL running (5697)
Note: In Mysql5.6 A random root password has been set. You will find it in '/root/.mysql_secret'.
#vim /root/.mysql_secret Reset root password
#mysqladmin u root p'MUZOV9do' password *******
MySQL masterslave replication
Master 1/Slave 2 ip: 192.168.0.45Master 2/Slave 1 ip : 192.168.0.46
Create relication user on Master 1:
mysql> grant replication slave on *.* to 'replication'@192.168.0.46 identified by 'slave';
Master 1 changes to /etc/my.cnf:
Add in Below line
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock old_passwords=2 logbin binlogdodb= database name # input the database which should be replicated binlogignoredb=mysql binlogignoredb=test
serverid=2
[mysql.server] user=mysql basedir=/var/lib
[mysqld_safe] errlog=/var/log/mysqld.log pidfile=/var/run/mysqld/mysqld.pid
Slave 1 changes to /etc/my.cnf:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock old_passwords=1 serverid=2 [mysql.server] user=mysql basedir=/var/lib [mysqld_safe] errlog=/var/log/mysqld.log pidfile=/var/run/mysqld/mysqld.pid
On Master 1:
mysql> show master status;
+------------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------------+----------+--------------+------------------+ |mysqld-bin.000012 | 106 | adam | | +------------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
On Slave 1:
mysql> stop slave;
mysql> CHANGE MASTER TO MASTER_HOST='192.168.0.45', MASTER_USER='replication', MASTER_PASSWORD='password', MASTER_PORT=3306,MASTER_LOG_FILE='mysqldbin.000012 ', MASTER_LOG_POS=106, MASTER_CONNECT_RETRY=10;
mysql> start slave;
mysql> show slave statusG;
*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.0.45 Master_User: slave Master_Port: 3306 Connect_Retry: 10 Master_Log_File: mysqld-bin.000012 Read_Master_Log_Pos: 1368129 Relay_Log_File: mysqld-relay-bin.000005 Relay_Log_Pos: 605530 Relay_Master_Log_File: mysqld-bin.000012 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 1368129
Relay_Log_Space: 1367083 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 11 row in set (0.02 sec)
MySQL mastermaster replication
Create relication user on Slave 1:
mysql> grant replication slave on *.* to 'replication'@192.168.0.45 identified by 'slave';
Slave 1: changes to /etc/my.cnf:
Add in Below line
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock old_passwords=2 logbin binlogdodb= database name # input the database which should be replicated binlogignoredb=mysql binlogignoredb=test
serverid=2
[mysql.server] user=mysql basedir=/var/lib
[mysqld_safe]
errlog=/var/log/mysqld.log pidfile=/var/run/mysqld/mysqld.pid
On Slave 1:
mysql> show master status;
+------------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------------+----------+--------------+------------------+ |mysqld-bin.000018 | 303 | adam | | +------------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
On Master 1:
mysql> stop slave;
mysql> CHANGE MASTER TO MASTER_HOST='192.168.0.46', MASTER_USER='replication', MASTER_PASSWORD='password', MASTER_PORT=3306,MASTER_LOG_FILE='mysqldbin.000018 ', MASTER_LOG_POS=303, MASTER_CONNECT_RETRY=10;
mysql> start slave;
mysql> show slave statusG;
*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.0.46 Master_User: slave Master_Port: 3306 Connect_Retry: 10 Master_Log_File: mysqld-bin.000012 Read_Master_Log_Pos: 1368129 Relay_Log_File: mysqld-relay-bin.000005 Relay_Log_Pos: 605530 Relay_Master_Log_File: mysqld-bin.000012 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table:
Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 1368129 Relay_Log_Space: 1367083 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 11 row in set (0.02 sec)
P@W@n Kumar