MySQL one-way synchronization implementation _ MySQL

Source: Internet
Author: User
One-way MySQL synchronization for bitsCN.com

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.

BitsCN.com
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.