Operating System: Red Hat Enterprise Linux 6.6 x86_64
Server information:
Master.mysql.whh.org 192.168.255.1
Slave.mysql.whh.org 192.168.255.2
Master server configuration:
1-Edit the/etc/my.cnf file, set server Server-id to 1,id the last one of the server IP addresses is recommended.
2-Restart Services, service mysqld restart.
3-Set the user name and password to log on from the server and authorize.
Grant replication Slave,replication Client on * * to [e-mail protected] ' 192.168.255.2 ' identified by ' slave ';
Flush privileges;
\q
Slave Server configuration:
1-Use the username and password created on master on slave to connect to the MySQL database for verification.
Mysql-h 192.168.255.1-u Slave-p
2-Exit after successful verification.
3-Edit the/etc/my.cnf file, set server Server-id to 2,id the last one of the server IP addresses is recommended.
4-Connect the local MySQL database and configure the slave service.
Reset Master;
Change Master to
Master_host= ' 192.168.255.1 ',
Master_user= ' slave ',
master_password= ' slave ',
Master_log_file= ' mysql-bin.000001 ',
master_log_pos=0;
Slave start;
Show Slave Status\g
\q
Slave Server information:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" background:transparent url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat scroll center;border:1px solid rgb (221,221,221);" alt= "Spacer.gif"/>
Slave_io_running:yes
Slave_sql_running:yes
The two field information is yes, which indicates a successful master-slave configuration.
Test:
Create a database on the master server and then query on the slave server to see if the database you just created exists.
Description
1-The installation method before installation, the bin log is turned on by default, so the master and slave service MY.CNF configuration files are modified Server-id.
2-Because the server is just installed after MySQL is configured, the binary file name and POS can be written as mysql-bin.000001 and 0.
3-If the service runs for a while to simulate the situation, back up the data, then empty the database directory, then use the mysql_install_db
The script initializes the database.
This article is from the "whh881114" blog, make sure to keep this source http://whh881114.blog.51cto.com/9520067/1605245
02-mysql Master-slave replication (MySQL just installed)