reading: MySQL database is a functional not very powerful relational database management system, although the function is not perfect, but MySQL database with speed, adaptability, high reliability advantages to win the favor of the majority of users, see MySQL database performance, You should start from the configuration of MySQL database, the following is a detailed discussion of MySQL database master-slave configuration problem.
Server-id one can be set by itself, but try not to set it to 1, nor can it be duplicated from the server.
Requires two hosts, respectively, as primary and slave servers
Primary server ip:192.168.1.1
From server ip:192.168.1.2
First, the MySQL service is configured on two services respectively.
On the primary server:
# VIM/ETC/MY.CNF
Modify or add the following entries
Log-bin=master-bin
Log-bin-index=master-bin.index
server-id=11
Note: Server-id can be set on its own, but try not to set it to 1 or repeat it from the server.
Restart Service
# Service Mysqld Restart
Add replication (copy) account number: REPL
# MySQL
>grant REPLICATION SLAVE,
>replication CLIENT On * *
>to [email protected] ' 192.168.1.% '
>identified by ' Redhat ';
Note: * * represents any table in any database, ' 192.168.1.% ' indicates that only the primary high Access database for 192.168.1.0 network segments is allowed
>flush privileges;
>\q
On the from server side:
# VIM/ETC/MY.CNF
Modify or add the following entries:
Relay-log=relay-log-bin
Relay-log-index=slave-relay-bin.index
Server-id=22
Note: Server-id cannot be the same as the primary server
Restart MySQL Service
# Service Mysqld Restart
# MySQL
>change MASTER to
>master_host= ' 192.168.1.1 ', # #主服务器的IP
>master_port=3306, # #3306不能加引号, this trip is dispensable
>master_user= ' Repl ',
>master_password= ' redaht ';
>
>start SLAVE;
To this, the master-slave MySQL server configuration is complete!
Test:
Modify the database on the primary server, such as:
# MySQL
>creat DATABASE MyDB;
Viewing from the server side:
# MySQL
>show DATABASES;
There will also be an identical database named MyDB!
About MySQL database of the master and slave configuration of knowledge for everyone to introduce so much, I hope that we can have something to gain
-----Excerpt from Http://database.51cto.com/art/201104/255282.htm