How to realize one-way synchronization in MySQL
This article shows you how to achieve one-way synchronization in MySQL, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Instance CVM:
Dbasky=192.168.1.120
Dbaskyback=192.168.1.121
Purpose: the host of dbaskyback synchronizes the data on the test library of dbasky host.
Install mysql
[root@dbasky] # wget
[root@dbasky] # cd / usr/local/mysql-5.0.45
[root@dbasky] # groupadd mysql
[root@dbasky] # useradd-g mysql 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-assembler-- 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
Establish a user
Mysql > create database test
Mysql > grant all on *. * to identified by 123456
[root@dbasky] # vi / etc/my.cnf
Server-id=1 # is master
Log-bin=/var/log/mysql/mysql.log
Add
Binlog-do-db=test # name to be synchronized
Restart
Use mysql > show master status to view
On the dbaskyback machine
Dbaskyback#vi / etc/my.cnf
Server-id=2 # is slave
Master-host=192.168.1.120
Master-user=xu
Master-password=123456
Master-port=3306
Master-connect-retry=60 # reset every 60 seconds
Replicate-do-db=test
Use mysql > show slave status to see the synchronization, and you can see if there are any errors.
The above is how to achieve one-way synchronization in MySQL. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.