Create a user:
the Create the User 'user' @ 'Host' identified by '123'
Authorization:
Grant permission on level (global, database level, table level and column-level) to 'user' @ 'Host' identified by 'password';
REVOKE
privileges the flush
MySQL -u user -p password -h host port -P
(master operation on the host) main
1. Close firewall
-service iptables STOP
the setenforce 0
2. installation MySQL client and server
yum -y install mysql mysql-server
3. start MySQL service
service mysqld start
chkconfig mysqld oN
4. change the profile, open the binary log
vim /etc/my.cnf
increase in the content mysqld:
Server-the above mentioned id = 1
log-bin = MySQL-bin
save and exit the restart MySQL
mysqld restart Service
5. log on to the local mysql, privileges to authorized synchronization logs from (slave) host
. * * Grant Replication Slave to ON 'tom'@'192.168.189.%' IDENTIFIED by '123';
the flush privileges;
6. The binary log and view position
MySQL> Show Master Status;
+ -------- ---------- + ---------- + -------------- + ------------- + -----
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+ ------------------ + ---------- + ---- + ------------------ + ----------
| MySQL-bin.000001 | 331 | | |
+ -------- ---------- + ---------- + -------------- + ------------- + -----
. 1 in Row SET (0.00 sec)
primary (master) configuration is completed
from the operation (slave) host
1. Close firewall
-service iptables STOP
the setenforce 0
2. installation MySQL client and server
yum -y install mysql Server-MySQL
3. MySQL service start
Start mysqld Service
chkconfig mysqld ON
4. change the profile, open relay log
/etc/my.cnf vim
increase in the content mysqld:
Server-the above mentioned id = 2
Relay Relay-log = MySQL-
saving exit to restart the MySQL
service mysqld restart
Log local mysql, binary log master synchronization operation
mysql> stop slave; \\ stop slave synchronization
MySQL> Change to master
-> MASTER_HOST = '192.168.189.120', \\ IP address of the master host
-> master_user = 'tom', \\ login account master host
-> master_password = '123', login password \\
-> master_log_file = 'mysql-bin.000001 ', \\ binary log file
-> master_log_pos = 331;
mysql> start slave; \\ open slave synchronization
show slave status \ G; view status
Note the following states are two threads to Yes, the configuration was successful
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
test
create a database on the primary, in the view can successfully synchronize both success!