1. Enable rsyncvietcrsyncd. conf on the database server to edit rsync and configure usrbinrsync -- daemon to start rsync2. stop crontab of the log Collection Server
1. Enable rsyncvi/etc/rsyncd. conf on the database server to edit rsync configuration/usr/bin/rsync -- daemon to start rsync2. stop crontab on the log collection server.
1. Enable rsync from the Database Server
Vi/etc/rsyncd. conf
Edit rsync Configuration
/Usr/bin/rsync -- daemon
Start rsync
2. Stop the crontab of the log Collection Server
/Etc/init. d/cron stop
3. Stop the primary database rsync
Ps aux | grep rsync
Kill process number
4. Stop the primary database crontab
/Etc/init. d/cron stop
6. Set a synchronization account from the database in the primary database
Grant replication slave on *. * TO 'name' @ 'IP' identified by 'Password ';
7. Edit master database configuration
Vi/etc/my. cnf
Add under mysqld
[Mysqld]
Log-bin =/home/mysql/log/mysql-bin.log
Server-id = 1
Restart mysql after Configuration
./Bin/mysqladmin-uroot-p shutdown
./Bin/mysqld_safe &
5. log on to the primary database and add a read-only lock.
Flush tables with read lock;
6. Obtain the binary log name and offset
Show master status;
7. Package the primary database files
Tar-cvf data.tar data
8. Restore read/write operations on the master server
Unlock tables;
9. The package is sent to the slave server.
Rsync-ua d name @ ip: modname
10. Stop the slave server mysql
./Bin/mysqladmin-uroot-p shutdown
11. Extract files from the server
Tar-xvf data.tar-C/home/mysql
12. Edit slave server configuration
Vi/etc/my. cnf
Add under mysqld
[Mysqld]
Server-id = 2
The server-id must not be the same as the server-id of the master server.
13. Use the -- skip-slave-start option to start the slave Database
./Bin/mysqld_safe -- skip-slave-start &
14. Configure slave database server to specify the users used for replication, the IP address and port of the master database server, and the log files and locations for starting replication.
CHANGE MASTER
MASTER_HOST = 'IP ',
MASTER_PORT = 3306,
MASTER_USER = 'name ',
MASTER_PASSWORD = 'Password ',
MASTER_LOG_FILE = 'Log name ',
MASTER_LOG_POS = location;
15. Start slave on the slave server
Start slave;
16. view the slave status
Show slave status \ G
,