Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize one-way synchronization in MySQL

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report