Instance Host:
Dbasky = 192.168.1.120
Dbaskyback = 192.168.1.121
Objective: To synchronize data in the test database of the dbasky host on the dbaskyback host
Install mysql
[Root @ dbasky] # wget ftp://ftp.cronyx.ru/pub/FreeBSD/ports/distfiles/mysql-5.0.45.tar.gz
[Root @ dbasky] # cd/usr/local/mysql-5.0.45
[Root @ dbasky] # groupadd mysql
[Root @ dbasky] # useradd-g mysql
[Root @ dbasky] # mkdir/opt/mysql-data
[Root @ dbasky] # CFLAGS = "-O3" CXX = gcc CXXFLAGS = "-O3-felide-constructors
-Fno-exceptions-fno-rtti ". /configure -- prefix =/usr/local/mysql -- enable-character er -- with-charset = utf8 -- with-extra-charsets = gbk, gb2312, latin1 -- localstatedir =/opt/mysql-data -- with-mysqld-user = mysql -- enable-large-files -- with-big-tables -- without-debug -- enable-thread-safe -client -- with-fast-mutexes -- with-innodb
[Root @ dbasky] # make
[Root @ dbasky] # make install
[Root @ dbasky] # cd/etc
[Root @ dbasky] # rz my. cnf
[Root @ dbasky] # chown-R mysql.
[Root @ dbasky] # chgrp-R mysql.
[Root @ dbasky] # chown-R mysql/opt/mysql-data
[Root @ dbasky] # chgrp-R mysql/opt/mysql-data
[Root @ dbasky] # bin/mysql_install_db -- user = mysql
[Root @ dbasky] # chown-R root.
[Root @ dbasky] # bin/mysqld_safe -- user = mysql &
[Root @ dbasky] # cd/usr/local/mysql
[Root @ dbasky] # echo "PATH =/usr/local/mysql/bin: $ PATH">/etc/profile
[Root @ dbasky] # echo "export PATH">/etc/profile
[Root @ dbasky] # echo "alias vi =" vim "">/etc/profile
[Root @ dbasky] # echo "/usr/local/mysql/lib/mysql">/etc/ld. so. conf. d/mysql. conf
On the dbasky Machine
Create a user
Mysql> create database test;
Mysql> grant all on *. * to xu@192.168.1.121 identified by 123456;
[Root @ dbasky] # vi/etc/my. cnf
Server-id = 1 # master
Log-bin =/var/log/mysql. log
Add
Binlog-do-db = test # Name of the database to be synchronized
Restart mysql
Use mysql> show master status to view
On the dbaskyback Machine
Dbaskyback # vi/etc/my. cnf
Server-id = 2 # slave
Master-host = 192.168.1.120
Master-user = xu
Masters-password = 123456
Master-port = 3306
Master-connect-retry = 60 # reset at 60 seconds
Replicate-do-db = test
Use mysql> show slave status to check the synchronization status. If there is an error, you can see it.