Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL multi-master-slave synchronization     - Chkconfig set boot start under Linux (Linux)

- stat - Get more information than ls (Linux)

- IBM Data Studio to create objects using ---- double quotes / sensitive issues and the table / column renaming (Database)

- Ubuntu Eclipse configuration Gtk + 2.0 libraries (Linux)

- Oracle11g CRS-0184 Problem Solving (Database)

- Installation on Ubuntu class Winamp audio player Qmmp 0.9.0 (Linux)

- JavaScript notes --Objects (Programming)

- Python method to traverse folders and file read and write (Programming)

- Spark read more HBase tables a RDD (Server)

- SVN hook code set to synchronize Web directory (Server)

- Android custom slideshow menu slidmenu (Programming)

- SQL in the specific internal Oracle process (Database)

- Linux Timing task Crontab command Detailed (Linux)

- Use OpenSSL carried BASE64 encoding and decoding (Linux)

- Sshuttle A VPN-based transparent proxy that uses ssh (Server)

- Spring use Cache (Programming)

- 64 Ubuntu 15.04 Linux kernel upgrade to Linux 4.1.0 (Linux)

- How to implement Linux host Telnet SSH password Free (Server)

- Difference Redhat5 and 6 YUM source configuration (Linux)

- Ubuntu and Archlinux install Notepadqq 0.50.2 (Linux)

 
         
  MySQL multi-master-slave synchronization
     
  Add Date : 2018-11-21      
         
       
         
  Experimental preparation: Hosts A and B as the primary, its IP address were 192.168.131.129 and 192.168.131.130, host C as a slave server, MySQL server from multiple instances in the configuration above, the IP address is 192.168.131.136, three servers Close all firewall and SELINUX, MySQL version is 5.6.26 for generic binary package

1. Host A and Host B master MySQL universal binary package installation and initialization

# Tar xf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

# Mv mysql-5.6.26-linux-glibc2.5-x86_64 / usr / local / mysql

# Useradd -M -s / sbin / nologin mysql

# Chown -R root: root / usr / local / mysql / *

# Chown -R mysql: mysql / usr / local / mysql / data /

# Yum -y install libaio

# Cd / usr / local / mysql / scripts /

# ./mysql_install_db --datadir = / Usr / local / mysql / data / --user = mysql --basedir = / usr / local / mysql /

# Cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

# Echo 'export PATH = $ PATH: / usr / local / mysql / bin' >> / etc / profile

# Source / etc / profile

# Vim /etc/my.cnf

[Mysqld]

datadir = / usr / local / mysql / data

socket = / tmp / mysql.sock

user = mysql

symbolic-links = 0

[Mysqld_safe]

log-error = / var / log / mysqld.log

pid-file = / var / run / mysqld / mysqld.pid

# Service mysqld start

#chkconfig mysqld on

# Ss -tunlp | grep 3306

# Mysqladmin -uroot password '123456' # Set Database Password

2, Host A and Host B configuration

A. Host A

# Vim /etc/my.cnf

server-id = 129

port = 3306

log-bin = mysql-bin

log-bin-index = mysql-bin.index

max-binlog-size = 100M

# Service mysqld restart

# Mysql -uroot -p

. Mysql> GRANT REPLICATION SLAVE ON * * TO 'wdd'@'192.168.131.136' IDENTIFIED BY '123456';

mysql> SHOW MASTER STATUS;

B. Host B

# Vim /etc/my.cnf

server-id = 130

port = 3306

log-bin = mysql-bin

log-bin-index = mysql-bin.index

max-binlog-size = 100M

# Service mysqld restart

# Mysql -u root -p

. Mysql> GRANT REPLICATION SLAVE ON * * TO 'wdd'@'192.168.131.136' IDENTIFIED BY '123456';

mysql> SHOW MASTER STATUS;

3, the host c install MySQL from multiple instances of the server

# Yum -y install libaio

# Tar xf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

# Mv mysql-5.6.26-linux-glibc2.5-x86_64 / usr / local / mysql

# Useradd -M -s / sbin / nologin mysql

# Mkdir / data / {3306,3307} -pv

# Chown -R mysql: mysql / data /

#vim /etc/my.cnf

[Mysqld_multi]

mysqld = / usr / local / mysql / bin / mysqld_safe

mysqladmin = / usr / local / mysql / bin / mysqladmin

# User = mysql

# Password = 123456

log = / data / multi.log

[Mysqld129]

port = 3306

pid-file = / data / 3306 / mysql.pid

datadir = / data / 3306 / data

socket = / data / 3306 / mysql.sock

server-id = 136

user = mysql

[Mysqld130]

port = 3307

pid-file = / data / 3307 / mysql.pid

datadir = / data / 3307 / data

socket = / data / 3307 / mysql.sock

server-id = 136

user = mysql

1. # / usr / local / mysql / scripts / mysql_install_db --user = mysql --datadir = / data / 3306 / data --basedir = / usr / local / mysql /

2. # / usr / local / mysql / scripts / mysql_install_db --user = mysql --datadir = / data / 3307 / data --basedir = / usr / local / mysql /

3. # mysqld_multi --defaults-file = / etc / my.cnf start 129

# Mysqld_multi --defaults-file = / etc / my.cnf start 130

4. # mysqld_multi --defaults-extra-file = / etc / my.cnf report

5. # ss -tunlp | grep 330

Note: For security should set a password for the MySQL instance, the following command

# Mysqladmin -uroot -S /data/3306/mysql.sock password '123456'

# Mysqladmin -uroot -S /data/3307/mysql.sock password '123456'

4. Host c multi-instance trial operation

A. # mysql -uroot -S /data/3306/mysql.sock

mysql> CHANGE MASTER TO

MASTER_HOST = '192.168.131.129',

MASTER_USER = 'wdd',

MASTER_PASSWORD = '123456',

MASTER_LOG_FILE = 'mysql-bin.000004',

MASTER_LOG_POS = 120;

mysql> START SLAVE;

mysql> SHOW SLAVE STATUS;

B. # mysql -u root -S /data/3307/mysql.sock

mysql> CHANGE MASTER TO

MASTER_HOST = '192.168.131.130',

MASTER_USER = 'wdd',

MASTER_PASSWORD = '123456',

MASTER_LOG_FILE = 'mysql-bin.000003',

MASTER_LOG_POS = 331;

mysql> START SLAVE;

mysql> SHOW SLAVE STATUS;

5, the test

A. Log Host A

mysql> create database wdd;

mysql> SHOW DATABASES;

B. Host B Login

mysql> create database info;

mysql> show databases;

C. See MySQL instance, the instance 129 and 130

Example 129

# Mysql -uroot -S /data/3306/mysql.sock

mysql> START SLAVE;

Examples 130

# Mysql -u root -S /data/3307/mysql.sock

mysql> show databases;

Note: MySQL multi-instance login, in fact, do not need to specify the port, which means you can omit the -p option, even with the -p option, you can also optionally specify the port, which means you can easily write a port number, as long as the socket is not change, then the login is still the same MySQL instance.
     
         
       
         
  More:      
 
- Python 3.5 will support Async / Await Asynchronous Programming (Programming)
- Create several practical points of high security PHP site (Linux)
- Red Hat Enterprise Linux configuration VNC multi-user access methods (Linux)
- Ubuntu 14.10 / 14.04 how to install Quick Start tool Mutate 2.2 (Linux)
- Oracle 12c users create (Database)
- To install the Contiki development toolchain on Ubuntu (Linux)
- RHEL / CentOS / Fedora Install Nagios 4.0.1 (Linux)
- ORA-01000 Solution (Database)
- Linux Learning Notes: Users and Groups (Linux)
- Introduction and MongoDB CRUD (Database)
- Linux IPTables anti-DDOS attack Shell Scripting (Linux)
- Parse Server supports iOS and Android push messaging (Programming)
- Linux environment variable settings and save places (Linux)
- To install Redis under Linux (Database)
- Linux command to view the system status (Linux)
- Ubuntu 15.10 under Python + Apache + CGI fully configured (Server)
- Depth Java Singleton (Programming)
- xCAT line installation on CentOS 6.X (Linux)
- Good wireless network security information spread in the air (Linux)
- Linux gprof oprofiling and performance testing tools (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.