Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL High Availability plan several options     - Python decorators to learn and practice the actual usage scenarios (Programming)

- Install the latest development version of Wine on RedHat and Debian-based systems (Linux)

- C ++ free store and heap (Programming)

- Use small network command to check whether PC Security (Linux)

- Two classic macro definition under Linux (Linux)

- Ubuntu 14.04 after the restart the default maximum screen brightness solutions (Linux)

- Use mysqldump MySQL database backup - Linux Shell Scripting (Database)

- How to install new fonts on Ubuntu 14.04 and 14.10 (Linux)

- Linux centos rm directory does not prompt (Linux)

- CentOS 7.0 local address and configure yum source address priority (Linux)

- Use chattr and lsattr command to manage linux files and directory attributes (Linux)

- Linux server startup and logon security settings (Linux)

- Wildcards and special symbols usage comments under Linux (Linux)

- Linux Command-line MySQL summary (Database)

- JavaScript file loader LABjs API Explanation (Programming)

- RabbitMQ Getting Started Tutorial (Linux)

- Vim Getting Started Tutorial (Linux)

- How to contribute code to the GNU Project (Linux)

- Linux cron job (Linux)

- Linux Detailed instructions alias settings (Linux)

 
         
  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 install Google Chrome browser under Ubuntu 14.04 LTS (Linux)
- The next key to install Linux bash script PowerShell (Linux)
- Production Environment MongoDB Fragmentation and Cluster Solution (Database)
- Linux operating system set up to effectively prevent ARP attacks (Linux)
- CentOS 6.5 Linux System Customization and Packaging Quick Implementation Script (Linux)
- Java application server WildFly (Server)
- Retro terminal in Linux (Linux)
- Linux, ls command to achieve (Linux)
- SA weak password security system of the security risks posed (Linux)
- Copy Recovery using RMAN repository development environment (Database)
- grep, egrep and regular expressions (Linux)
- AFNetworking + Nginx HTTPS communication server + (Server)
- Ubuntu 14.04 LTS NTFS partition can not access solution (Linux)
- Install Firefox 28 on Ubuntu, Linux Mint (Linux)
- OpenSIPS offline messaging feature set (Server)
- Linux Getting Started tutorial: Experience VirtualBox Virtual Machine chapter (Linux)
- grep command Detailed and relevant examples (Linux)
- Linux smart small switch rfkill (Linux)
- Ubuntu 14.04 Docker installation (Linux)
- B-tree - ideas and implementation of C language code (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.