Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL multi-master-slave synchronization     - Docker + Nginx + Tomcat7 simple load balancing configuration (Server)

- CentOS7 virtual machine starts appear Permission denied (Linux)

- Redis Linux system installation guide (Database)

- Source install Python3.4 on CentOS (Linux)

- Usage logs Python library (Programming)

- PostgreSQL use pgpool achieve high availability (Database)

- Python cause yum upgrade error (Linux)

- The default permissions for files and directories under Linux computing (Linux)

- Ubuntu deployed under regular tasks with crontab (Linux)

- Ubuntu How to install screen recording tool Simple Screen Recorder 0.3.1 (Linux)

- Ubuntu 14.04 installed Nvidia CUDA 7.5 and build Python Theano deep learning development environment (Linux)

- Linux system security configuration Collection (Linux)

- Build the first ASP.NET 5 Web project in Mac OS X Yosemite 10.10.3 (Server)

- System Security: Build Linux with LIDS steel castle (Linux)

- Oracle Linux 7.1 install Oracle 12C RAC (Database)

- Zabbix configuration of SNMP (Server)

- Practical top command (Linux)

- PF_RING 6.0.2 compiled and installed on Redhat 6.3 x86_64 (Linux)

- Linux installation beautify early experience (Linux)

- Under CentOS yum install Nginx smooth switch mounted to Tengine (Server)

 
         
  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:      
 
- Zabbix Agent for Linux Installation and Configuration (Server)
- PHP loop reference caused strange problems (Programming)
- Start Linux ISO image directly from the hard disk (Linux)
- Cobbler automatic mass deployment of CentOS 6 and CentOS 7 (Linux)
- Flask installation environment (Linux)
- Unix system security configuration (Linux)
- Actual SSH port forwarding (Linux)
- Java memory-mapped file MappedByteBuffer (Programming)
- Restore Oracle Database Cold backup and database reconstruction emca (Database)
- using the ssh command to check the socket / Network Connections (Linux)
- Hadoop 2.6.0 standalone configuration and pseudo-distributed configuration under Ubuntu 14.04 (Server)
- 64 Ubuntu 15.04 Linux kernel upgrade to Linux 4.1.0 (Linux)
- Installation on the way to the root source Ubuntu Server 14.04 LTS version Odoo8.0 (Server)
- Ubuntu 12.04 configure NVIDIA CUDA 5.5 Record (Linux)
- Under CentOS yum install Nginx smooth switch mounted to Tengine (Server)
- Based Corosync + Pacemaker + DRBD + LNMP Web server to achieve high availability cluster (Server)
- Experience RHEL7 new features (Linux)
- Ubuntu 12.04 installation NVIDIA GTX750 graphics driver (Linux)
- Oracle Database Delete Delete million or more common method of heap table data (Database)
- Linux find command usage summary (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.