Mysql server master/slave data synchronization bitsCN.com
Master-slave data synchronization for Mysql servers
Example: use server A as the Master server, and use server B1 and server B2 as the Slave server (Slave ),
How can we synchronize data from the master server to the slave server? let's take a look.
Master:
Modify the configuration file:/etc/my. cnf
[Root
.
| '-- Data
'-- 3307
'-- Data
4 directories, 0 files
1.5 authorize mysql users and groups to access the data file directory
Chown-Rmysql: mysql/data/3306
Chown-Rmysql: mysql/data/3307
1.6 create the 3306,330 7my. cnf configuration file
Vim/data/3306/my. cnf
Vim/data/3307/my
control costs, you may consider deploying a physical server with superior performance in a remote data center, or even multiple instances in addition to the Cabinet;
• MMO/MMORPG in the traditional Game industry, and Web Game, each server corresponds to a database, and may do a lot of data query and Data Correction Work ,, to reduce the probability of failures during maintenance, you may also use multi-instance deployment to allocate databases by partition;
4. Conventions
1. store all the insta
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql/ -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306[root@mysql mysql-5.5.32]# make make install
6. Create a multi-instance data
and rename it my. cnf.
> Mkdir var
> Mv share/mysql/my-medium.cnf my. cnf
6. Configure my. cnf
Configure the items in the installed directory.
The changes are as follows:
[Client]
# Password = your_password
Port = 3306
Socket =/tmp/mysql3306.sock
# The MySQL server
[
, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), and PERFSCHEMA (Performance Schema ).
-DMYSQL_DATADIR = dir_name
Set the mysql database file directory
-DMYSQL_TCP_PORT = port_num
Set the listening port of the mysql server. the default value is 3306.
-DENABLE_DOWNLOADS = bool
Whether to download optional files. For example, if this option is enabled (set to 1), cmake dow
# MySQL user executable file directory./Include/MySQL # MySQL C header file directory./INFO # MySQL information file directory./Lib/MySQL # MySQL library file directory./Libexec # mysql
data
/Usr/local/mysql # chgrp-R mysql
--------------------------------------------------------------------------------
8. create and modify/etc/my. cnf as needed. refer to the configuration:
[Mysqld]
# Set the default value to the INNODB table and support transactions:
Default-storage-engine = INNODB
# Set the default character set UTF-8:
Character-set-server =
I haven't written anything for a long time. On these days of work, I got some methods to install Mysql. This method can install multiple Mysql on a Linux service at the same time.
The source code of mysql. the serial number is mysql-5.0.20a.tar.gz. Of course, the other code can be used only for testing. Red Hat Linux a
transactions and roll back uncommitted transactions !)
-- Copy-backCopy the backup data back to the datadir of the server. It depends on the datadir parameter in my. cnf. In addition, the datadir directory must be empty during restoration and the mysql database must be shuffled!
-- No-timestampInnobackupex -- defaults-file =/etc/my. cnf -- user = root -- no-time
/# initialize mysql
4) Configure my. cnf
$ sudo vi /usr/local/mysql/my.cnf
This example only ensures normal operation, so you can configure the following three items.
basedir = /usr/local/mysql datadir = /data/mysql port = 3306
Create a soft connection my.
MySQL has the following common backup solutions: mysqldump + binloglvm + binlogxtrabackup. In this example, the data in the database is empty. Next start mkdiroptbackup # create Backup Directory mkdir-pdata3309 {data, binlog} cdusrlocalmysqlscriptsmysql_install_db -- usermysql-
MySQL has the following common backup solutions: mysqldump + binlog lvm + binlog xtrabackup. In this example, the data in the datab
Innodb does not have such restrictions, so the proportion of Innodb table types in the database is greater, it is more advantageous. In actual application, the innobackupex method is generally used directly. There are three main operation methods, as described in the Manual:
Usage:
Innobackup [-- sleep = MS] [-- compress [= LEVEL] [-- include = REGEXP] [-- user = NAME]
[-- Password = WORD] [-- port = PORT] [-- socket = SOCKET] [-- no-timestamp]
[-- Ibbackup = IBBACKUP-BINARY] [-- slave-info] [-
need master-slave replication, it will end here. You can skip it later. All the changes in A can be automatically synchronized to B, but the changes to B cannot be synchronized to. Because it is unidirectional. If bidirectional synchronization is required, A copy from B to A is required.
Basically the same as above: Let's briefly introduce:
1. create a user in B;
2. open/etc/my. cnf and enable binarylog of B:
Note the newly added part in the r
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.