In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Mysql database is highly available
Mysql (5.7.19) + keepalive (1.3.0) + RHEL6.5
Mysql download address
Https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
Keepalived address
Http://www.keepalived.org/software/keepalived-1.3.0.tar.gz
The plan is as follows
Ip
Port
Remarks
Mysql1
172.25.254.120
3306
Mysql2
172.25.254.130
3306
Keepalived
172.25.254.111
First, set up the master database.
Copy the compressed package to the system / mnt
Cd / mnt/
Tar xvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
Cp-a mysql-5.7.19-linux-glibc2.12-x86_64 / usr/local/mysql
Useradd mysql
Cd / usr/local/mysql/
Cd bin/
. / mysqld-- initialize
. / mysql_install_db-- user=mysql-- basedir=/var/lib/mysql-- datadir=/var/lib/mysql/data
Chown-R mysql/ var/lib/mysql/data/
. / mysqld_safe-- user=mysql
Cd..
Cp support-files/mysql.server / etc/init.d/mysqld
Rm-rf / etc/my.cnf
Cat set password = password ('123456')
Sed-I'/\ [mysqld\] $/ alog-bin=/var/lib/mysql/log-bin' / etc/my.cnf
Sed-I'/\ [mysqld\] $/ aserver_id=130' / etc/my.cnf # two id are different
Service mysqld restart
So far, the two databases have been built.
Two: the main building
Mysql-uroot-p12345 login database
Grant replication slave on *. * to slaveuser@ "172.25.254.120" identified by "123456"; configuration on
Grant replication slave on *. * to slaveuser@ "172.25.254.130" identified by "123456"; configuration on
Whether the login test is successful or not
Mysql > show master status\ Gposition # View the two nodes separately
* 1. Row * *
File: log-bin.000001
Position: 154
Change master to master_host= "172.25.254.120", master_user= "slaveuser", master_password= "123456", master_log_file= "log-bin.000001", operation on master_log_pos=154;#130
Change master to master_host= "172.25.254.130", master_user= "slaveuser", master_password= "123456", master_log_file= "log-bin.000001", operation on master_log_pos=154;#120
The two nodes of start slave;# are enabled respectively
Show slave status\ G
Slave_IO_Running: YES
Slave_SQL_Running: YES
You can test it yourself.
Three: keepalived building
Cd / mnt/
Tar xvf keepalived-1.3.0.tar.gz
Yum-y install gcc gcc-c++ openssl-devel
Cd keepalived-1.3.0
. / configure
Make & & make install
Mkdir / etc/keepalived
Cd / usr/local/etc/
Cp-a keepalived/keepalived.conf / etc/keepalived/
Cp sysconfig/keepalived / etc/sysconfig/
Cat / etc/keepalived/keepalived.conf
! Configuration File for keepalived
Global_defs {
Router_id
}
Vrrp_sync_group VGM {
Group {
HA
}
}
Vrrp_script check_mysql {
Script "/ root/check_mysql.sh" # script file
Interval 5
}
Vrrp_instance HA {
State MASTER# from BACKUP
Interface eth0
Virtual_router_id 51
Priority 10 is from 99.
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
172.25.254.111/24 dev eth0
}
Track_script {
Check_mysql
}
}
Cat / root/check_mysql.sh # script file
B = `ps aux | grep mysql | grep sqld | wc-l`
If [$b = = 0]
Then
Service mysqld restart
C = `ps aux | grep mysql | grep sqld | wc-l`
If [$c = = 0]
Then
Kill-9 `ps aux | grep keep | grep lived | awk'{print $2}'`
Fi
Fi
A = `ps aux | grep keep | grep lived | wc-l`
If [$a = = 0]
Then
Sleep 300
Reboot
Fi
Testing, and boot start is not in the second test, can be self-tested
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.