/etc/my. cnf and provide the following configuration
Log_bin = index
Server_id = 1
Authorize on the master server
# Mysql> grant replication slave, replication client on user @ '192. 168.1.142 'identified by "192 ";
# Mysql> flush privileges;
2. Configure mysql slave Serv
MySQL primary master replication +lvs+keepalived for MySQL high availabilityMySQL replication can ensure the redundancy of the data and read and write separation to share the system pressure, if the primary master replication can also be good to avoid the primary node single
sides, resulting in master-slave Replication failure. For example, if you copy an ID of 100 to the slave end on the master end, And the slave end already has the ID = 100 record for some reason, during the INSERT operation, the primary key will be repeated and insertion will fail. Skip this error. The method is as follows:
1: Stop the SLAVE Service
Mysql> stop slave;
2: set the number of skipped events
on the in the MySQL configuration file on master: [Mysqld] Rpl_semi_sync_master_enabled=1 rpl_semi_sync_master_timeout=10000 "Additional configuration required for asynchronous replication is omitted here" can use The SQL command dynamically enables semi-synchronous replication. mysql> set global rpl_semi_sync_mas
Start
# PS grep |grep mysqld //You should see data for two groups of MySQL services
"7" for login issues with two MySQL services Login Two MySQL, can be via port: # mysql-h127.0.0.1-p3306 //Large p specify port, login another with-p3307;h to specify host, because is ho
interfering with the primary server. The primary server can continue processing updates during the backup process.
MySQL uses 3 threads to perform replication functions (of which 1 are on the primary server and two on the server). When the start slave is issued, an I/O thread is created from the server to connect to the primary server and have the primary serve
-slave synchronization, which can be summarized as follows: 1. On the primary server, you must turn on the binary logging mechanism and configure a separate ID 2. On each slave server, configure a unique ID to create an account that specifically replicates the primary server data 3. Log the location information of the binaries on the primary server before starting the replication process 4. If you already have data in the database before you
master to its own trunk logs. First, slave starts a worker thread--i/o thread. The I/O thread opens a normal connection on master and then starts Binlog dump process. Binlog dump process reads the event from the binary log of master, and if it has been followed by master, it sleeps and waits for master to produce a new event. The I/O thread writes these events to the relay log. The SQL slave thread (SQL slave thread) handles the last step of the process. The SQL thread reads events from the log
-slave replication?
1. The master server/slave server settings increase robustness. When the master server encounters a problem, you can switch to the slave server as a backup.
2. By splitting the customer query load between the master server and slave server, a better customer response time can be obtained. But do not perform updates on the Master/Slave servers at the same time, which may cause conflicts.
3. Another advantage of using
copy account on the main library)
Master_port = 3306;
Start slave;To see if replication is starting to work:
Mysql> show slave status \g;1. Row ***************************Slave_io_state:waiting for Master to send eventMaster_host:localhostMaster_user:replicationmaster_port:3307Connect_retry:60master_log_file:mysql-bin.000001read_master_log_pos:622
to test5;
Conn test5/test5
Create table test5 (aa int primary key );
The statement used in MYSQL is as follows: -- the first step has been executed.
Mysql> create database oggtest;
Mysql> use oggtest;
Mysql> grant all privileges on *. * to 'root' @ '% 'identified by '123 ';
Mysql
exit due to an error.
Now you have obtained a data snapshot and a binary log since the snapshot was created, which records any changes to the database. Note that MySQL Data Files (*. MYD, *. MYI and *. frm) depend on the file system. Therefore, you cannot transfer files only, for example, from Solaris to Linux. If you are in a heterogeneous server environment, you will have to use the mysqldump utility or other custom scripts to get data snapshots.
S
Mysql multi-instance installation and master-slave replication Configuration1. mysql multi-instance installation1) configuration file# Cat/etc/my. cnf. multi[Mysqld_multi]Mysqld =/usr/bin/mysqld_safe // mysqld pathMysqladmin =/usr/bin/mysqladmin // mysqladmin pathUser = root // user[Mysqld1] // 1 indicates that the first database instance is identified. The follo
] #mysqldump-uroot-p--all-databases >/data/all.sql6. Ensure that data is exported without data insertion, and then view the main library statusShow master status;7. After exporting the data, unlock the main library and resume the writable;Unlock tables;8. SCP the backed-up exported data to the slave databasescp/data/all.sql [Email protected]:/data/Slave configuration from Library1. Set the server-ID value and close the Binlog function parameter database server-id is unique within the master-slav
- # Row Save affects record data + # Mixed in front of two combinations -Binlog_format=Mixed 2, Slave end 1 # Stop Master-
slave synchronization 2 mysql> stop slave;
3
4 # Reconnect Time
-out when the connection is disconnected 5 mysql> to Master_connect_retry=;
6
7 # Turn on master
-Slave synchronization 8 mysql>
, it reads only the contents of master.info, not the option values in MY.CNF.To use different option values, you can either remove Master.info and restart Slave, or use the change MASTER to statement (recommended) to reset option values.4. Start a thread from the serverCopy CodeThe code is as follows: Mysqld_safe–user=mysql–skip-slave-start (
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.