Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL High Availability plan several options     - Java, on the dfile.encoding Systemproperty (Programming)

- Build and verify MongoDB3.0.7 version (shard + replica) Cluster (Database)

- HAProxy performance under high concurrency (Server)

- Merge Sort (Programming)

- Linux System Getting Started Learning: The Linux logrotate (Linux)

- To use slay kill user processes (Linux)

- Oracle Linux 5.9 configuration Xmanager (Linux)

- AIX system file security aspects (Linux)

- MySQL function: group_concat () function (Database)

- ssh port forwarding Comments (Server)

- Ubuntu 14.04 installed NVIDIA graphics driver (Linux)

- Thinking in Java study notes - initialization and cleanup (Programming)

- Redis is installed and set up Ubuntu 14.04 from the environment under the main ssdb (Server)

- How common Linux automation tasks (Server)

- Impact test noatime Linux file access time (Linux)

- Ubuntu 14.10 users to install Audio Recorder 1.5.7 (Linux)

- The most concise Systemd tutorial, just ten minutes (Linux)

- ImportTsv-HBase data import tool (Database)

- How to find the available network adapter on Ubuntu (Linux)

- Use Oracle Data Guard to complete cross-platform database migration cases (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


     ip 172.20.138.212
     mode master
     peer db2


  ip 172.20.138.209
  mode master
  peer db1


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

 

    Hosts b1, db2
    ips 172.20.138.250 // 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"
fi
case $ mode in
'Start')
  mysql-proxy --daemon --proxy-address =: 3307 --proxy-backend-addresses = 172.20.138.209: 3306; 172.20.138.212: 3306 --proxy-read-only-backend-addresses = 172.20.138.212: 3306 --proxy-lua-script = / usr / local / mysql-proxy / share / doc / mysql-proxy / rw-splitting.lua
  ;;
'Stop')
  killall mysql-proxy
  ;;
esac
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 = 172.20.138.209: 3306; 172.20.138.212: 3306
proxy-read-only-backend-addresses = 172.20.138.212: 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
TCP_CHECK {
Connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3306
}
 
Real server xxxx 3306 {
  Ditto
}
}
 
DR's real serverloop port need to bind vip address script:
#! / Bin / bash
SNS_VIP = 172.138.20.244
./etc/rc.d/init.d/functions
case "$ 1" in
start)
      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"
 
 
 
      ;;
 
stop)
 
      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
 
esac
 
exit 0
 
Authorized to connect to the remote host can log in via vip vip
Grant allprivileges to on *. * To xxxx identifiedby xxxxx
    Flushprivileges
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.
     
         
         
         
  More:      
 
- To teach you a trick to find the real IP address (Linux)
- Linux Getting Started tutorial: Experience QEMU virtual machine articles (Linux)
- To share Internet access through NAT mode under Virtual Linux VMware Workstation (Linux)
- Ubuntu users to install Gnome-Pie 0.6.5 (Linux)
- Linux SVN installation and configuration graphic tutorials (Server)
- CentOS install pip (Linux)
- PostgreSQL transaction model introduction (Database)
- Unsafe reboot start (Linux)
- Ubuntu 15.04 install Complete Guide (Linux)
- Linux and Windows virtual machine shared folders ---- Linux install VMware tools (Linux)
- C ++ complex class of operator overloading (Programming)
- Use Aptik Battery Monitor monitoring Ubuntu laptop battery usage (Linux)
- How to generate Linux, random password encryption or decryption (Linux)
- Analysis of MySQL High Availability (Database)
- To batch create users under Linux (Linux)
- Hadoop connection failed or stuck processing (Server)
- CentOS 5.3 under broadcom NIC dual activation issues (Linux)
- Linux AS4 VPN server in conjunction with a firewall perfect (Linux)
- How to configure Proftpd server on Fedora 22 (Server)
- MySQL common functions summary (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.