Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ MySQL High Availability plan several options     - Related to optimize the use of Btrfs file system on SSD (Linux)

- Install OpenGL development environment in Fedora and Ubuntu (Linux)

- Quick Install software RAID on Linux (Linux)

- Django1.8 return json json string and the string contents of the received post (Programming)

- AIX system file security aspects (Linux)

- SQLite (Database)

- Single-node Hadoop environment to build (Server)

- Physical structure and process disk IO (Linux)

- Linux landing problem (Linux)

- Installation and use the telnet command under CentOS 6.x (Linux)

- User rights management system under Linux (Linux)

- 17 How to install the Ubuntu 14.04 and Linux Mint Kodi14 (XBMC) (Linux)

- File encryption and decryption of Linux security mechanisms (Linux)

- A process of how to get the current traffic in GNU Linux (Linux)

- Android Studio and Git Git configuration file status (Linux)

- To setup a ftp server under Linux (Server)

- Attic-- delete duplicate data backup program (Linux)

- Linux Shell Scripting Interview Question (Linux)

- How do you temporarily emptied Bash environment variable before running the command on Linux (Linux)

- ORA-30926 and MERGE tables empty the temporary occupation problem (Database)

  MySQL High Availability plan several options
  Add Date : 2018-11-21      
  Mysql-mmm is mysql master-master replication manager, the functions are:
High Availability (similar keepalived of vip floating technique)
The same time only one database write operation, to ensure consistency of the database.
Enhance slave to master, the continuation of dual master architecture
First to build a good database master master, master-slave architecture: Similar :( not described)
In each database to monitor the current situation to monitor synchronous machines:
Grant replivation client to 'user @' ip 'identified by' password 'Create a mmm-monitor accounts, mainly used for monitoring and synchronization
Grant super, replication client, process on *. * To 'user' @ 'ip' identified by 'password'
Create a mmm-agent accounts for a variety of client operations

The use of the epel way need to /etc/yum.repos.d/epel.repo in mirrorlist replaced baseurl

Mmm_common.conf configuration files: All configuration node are the same, including monitoring terminal

active_master_role writer

    cluster_interface eth0
    pid_path /var/run/mysql-mmm/mmm_agentd.pid
    bin_path / usr / libexec / mysql-mmm /
    replication_user ccd // synchronization account
    replication_password ccd
    agent_user ccd // bigger authority
    agent_password ccd

     mode master
     peer db2

  mode master
  peer db1

    hostsdb1, db2
    mode exclusive // ​​exclusive single write


    Hosts b1, db2
    ips // can have multiple ip, each database can have a separate vip
    mode balanced // read as load balancing

Modify file mmm_agent.conf different db value
Finally, configure the look mmm_mon.conf
Where major changes are:
Ping_ips to be true ip monitor host,
Monitor accounts to modify the database conferred
Monitor_assword password
Start the service in /etc/init.d/, enter the command in the monitoring server:
Mmm_control checks Check all database synchronization and operational conditions
Mmm_control show View vip bind situation similar ipvsadm
Mysql-mmm not suitable for high load mysql master-slave
Can be verified vip jump, but found reading ip also write data function. . . . If coupled with separate read and write, then you can achieve read vip does not have write capabilities
Mysql-proxy load balancing and separate read and write
The current version is mysql-proxy 0.8.5aplha
Before you install mysql-proxy will need to install lua
To the official website to download the source files lua
yum -y install readline-devel ncurses-devel
Install readline-devel and install ncurses-devel otherwise occur readline find no problem
tar zxvf luaxxxxx
make linux
make install
This time can be input into the compilation mode lua lua indicates the installation was successful
Install the required dependencies
yum install gcc * gcc-c ++ * autoconf * automake * zlib * libxml * ncurses-devel * libmcrypt * libtool * flex * pkgconfig *
Mysql-proxy to the official website to download the latest source file mysql-proxy
After the installation is very simple to use decompression
Add the mysql-proxy to the corresponding environment variable
export PATH = $ PATH: / usr / local / mysql-proxy
source / etc / profile
Modify mysql-proxy configuration files
Commonly used command parameters are as follows:
--daemon start in daemon mode
--admin-address =: 4401 is the default port 4401
See all -help command
-default-file can be configured startup configuration file
--proxy-backend-addresses = $ host: $ port multiple separated by commas
--proxy-address =: 3307
--proxy-backend-addresses =: 3306 mysql host port
--proxy-read-only-backend-address = xxx13306 read only mysql host port
- Proxy-read-only-backend-address = xxx23306 can specify multiple read-only mysql host port
--proxy-lua-script = / usr / local / xxx / rw-splitting.lua lua scripts to use the system only with the realization of separate read and write functions
Use the system comes with two parameters need to modify the script rw.split.lua
min_idle_connections = 1
max_idle_connections = 3
Startup script:
#! / Bin / bash
mode = $ 1
if [-z "$ mode"]; then
  mode = "start"
case $ mode in
  mysql-proxy --daemon --proxy-address =: 3307 --proxy-backend-addresses = 3306; 3306 --proxy-read-only-backend-addresses = 3306 --proxy-lua-script = / usr / local / mysql-proxy / share / doc / mysql-proxy / rw-splitting.lua
  killall mysql-proxy
exit 0
Or use the configuration method to start
Vim /etc/mysql-proxy.cnf
admin-username = ccd
admin-password = ccd
daemon = true
keepalive = true
proxy-backend-addresses = 3306; 3306
proxy-read-only-backend-addresses = 3306
proxy-lua-script = / usr / local / proxy-mysql / share / doc / mysql-proxy / rw-splitting.lua
admin-lua-script = / usr / local / proxy-mysql / share / doc / mysql-proxy / admin-sql.lua
log-file = /usr/local/proxy-mysql/cn.log
log-level = debug
Modify the corresponding scripts to:
Mysql-proxy -defaults-file = / etc / mysql-proxy.cnf
For the test database can use the tool to test sysbench
Keepalived use mysql to achieve the main active / active high availability from
Keepalived.conf configuration file:
Vrrp_instatance HA_1 {
State BACKUP # configured as a slave, it can also be a master
Interface eth0
Virtual_router_id 80 // master-slave configuration requires the same virtual routing identifier
Different configurable priority Priority 100 #
Advert_int 1 # Check the synchronization between the primary and secondary cycle configuration
Authenication {
Auth_type PASS
Auth_pass 1111
Virtual_ipaddress {
    vip / 24 dev eth0
Virtual_server xxxxxx 3306 {
Delay_loop 2
lb_algo wrr // lvs WRR algorithm
lb_kind DR // lvs model for DR mode
protocol TCP
reall_server xxxx 3306 {
weight 1
Connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3306
Real server xxxx 3306 {
DR's real serverloop port need to bind vip address script:
#! / Bin / bash
case "$ 1" in
      ifconfig lo: 0 $ SNS_VIP netmask255.255.255.255 broadcast $ SNS_VIP
      / Sbin / route add -host $ SNS_VIP dev lo: 0
      echo "1"> / proc / sys / net / ipv4 / conf / lo / arp_ignore
      echo "2"> / proc / sys / net / ipv4 / conf / lo / arp_announce
      echo "1"> / proc / sys / net / ipv4 / conf / all / arp_ignore
      echo "2"> / proc / sys / net / ipv4 / conf / all / arp_announce
      sysctl -p> / dev / null 2> & 1
      echo "RealServer Start OK"
      ifconfig lo: 0 down
      route del $ SNS_VIP> / dev / null2> & 1
      echo "0"> / proc / sys / net / ipv4 / conf / lo / arp_ignore
      echo "0"> / proc / sys / net / ipv4 / conf / lo / arp_announce
      echo "0"> / proc / sys / net / ipv4 / conf / all / arp_ignore
      echo "0"> / proc / sys / net / ipv4 / conf / all / arp_announce
      echo "RealServer Stoped"
      echo "Usage: $ 0 {start | stop}"
      exit 1
exit 0
Authorized to connect to the remote host can log in via vip vip
Grant allprivileges to on *. * To xxxx identifiedby xxxxx
You can achieve high availability mysql database
There are two ways to use keepalived one for keepalived plus scripts vip switch, the other is keepalived + lvs way to achieve high availability database.
- Calculate CPU utilization (Linux)
- Python calls the API interface in several ways (Programming)
- Iptables in Ubuntu (Linux)
- Ubuntu 15.10 / 14.04 install subtitling software Aegisub (Linux)
- After reloading the cinder-volume OpenStack not start properly (Server)
- Java string equal size comparison (Programming)
- Linux md5sum verify file integrity (Linux)
- Use OpenSSL for RSA encryption and decryption (Linux)
- Compile and install Ubuntu Linux 4.0.5 kernel, network and fix vmware kernel module compilation error (Linux)
- Linux at command (Linux)
- Ubuntu 12.04 commonly use shortcuts finishing Share (Linux)
- ActiveMQ5.11.1 and JDK version matching relation (Linux)
- Puppet subcommands Introduction (Server)
- phpinfo (): like phpinfo as a Python script (Programming)
- Java thread pool: ExecutorService, Executors (Programming)
- Linux System Getting Started Tutorial: mounted directly in Linux LVM partition (Linux)
- RealVNC Server 5.2.3 Installation and Configuration In Fedora (Server)
- Introduction to Linux system process monitoring tools (Linux)
- stat Usage: Get permission to file the corresponding figures (Linux)
- Changes in C # asynchronous programming model (Programming)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.