MYSQL5.7.22 原始碼安裝 主從搭建 + KEEPALIVED高可用
作業系統版本
CENTOS7.6
MYSQL5.7.22
啥?為啥我的作業系統木有iso的安裝映象,哎算了,不能弄本地yum源,那就弄個網路的吧。只不過預設的用不了,那就自己動手豐衣足食
cd /etc/yum.repos.d/
mkdir bak
cp *.repo bak/
# wget
-bash: wget: 未找到命令
WTF?原來是
原本的CentOS-Base.repo已被刪除,所以沒辦法安裝wget命令,所以用curl -O來獲取
#curl -O
vi CentOS7-Base-163.repo
替換一些東西,不然可能無法使用
:%s#$releasever#7#g
yum list
OK!YUM源搞定了,下面開始搭建MYSQL
一、MYSQL原始碼安裝
(兩個節點都安裝,步驟一樣的)
安裝環境:
作業系統CENTOS7.6
NODE1 主機名 tsdb1 IP地址 192.168.159.4
NODE2 主機名 tsdb2 IP地址 192.168.159.5
1、安裝依賴
yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl
2、建立使用者和組
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
3、下載5.7.22原始碼包
4、解壓tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
cd /opt/
tar -xvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
mv /opt/mysql-5.7.22-linux-glibc2.12-x86_64/ /opt/mysql-5.7.22
5、安裝
mkdir /data/mysql5.7.22/data/ -p
cd /data/mysql5.7.22
chown -R mysql:mysql ./
/opt/mysql-5.7.22/bin/mysqld --initialize --user=mysql --basedir=/data/mysql5.7.22
--datadir=/data/mysql5.7.22/data/ --lc_messages_dir=/opt/mysql-5.7.22/share/ --lc_messages=en_US
2019-05-25T13:01:50.716538Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-05-25T13:01:51.897953Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-05-25T13:01:52.039050Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-05-25T13:01:52.116959Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 43c9f84c-7eed-11e9-a241-fefcfe4975bb.
2019-05-25T13:01:52.118956Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-05-25T13:01:52.119626Z 1 [Note] A temporary password is generated for root@localhost: kar)*.OtV4F)
安裝速度賊快,刷~~~的一下就完事了。
kar)*.OtV4F)
這個是自動生成的臨時密碼
(如果看到有報這個錯的直接安裝就好)
bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解決方法: yum install -y libaio //安裝後再去初始化就OK了)
#將mysql/目錄下除了data/目錄的所有檔案,改回root使用者所有
chown -R root .
#mysql使用者只需作為mysql5.7.22/data/目錄下所有檔案的所有者
chown -R mysql data
5.複製啟動檔案
cd /opt/mysql-5.7.22
cp /opt/mysql-5.7.22/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp /opt/mysql-5.7.22/bin/my_print_defaults /usr/bin/
mkdir /data/mysql5.7.22/bin
cp /opt/mysql-5.7.22/bin/* /data/mysql5.7.22/bin/
6.修改啟動指令碼
vi /etc/init.d/mysqld
#修改項:
basedir=/data/mysql5.7.22/
datadir=/data/mysql5.7.22/data/
port=3306
#加入環境變數,編輯 /etc/profile,這樣可以在任何地方用mysql命令了
vi /etc/profile
#新增mysql路徑,加入下面內容,按ESC-->:wq儲存
export PATH=$PATH:/data/mysql5.7.22/bin
source /etc/profile
7.修改mysql配置項(第一次啟動這樣配置)
vi /etc/my.cnf
[mysqld]
basedir=/data/mysql5.7.22
datadir=/data/mysql5.7.22/data
[mysqld_safe]
log-error=/var/log/mysqld.log
8.啟動mysql
service mysqld start
有遇到無法啟動的情況,第一是將配置檔案修改成上面簡單的方式,第二是刪除data目錄下的檔案,重新初始化。
mysql -uroot -pkar)*.OtV4F)
遇到無法啟動報錯的情況,例如:
2019-12-31T07:49:42.258557Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2019-12-31T07:49:42.259636Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-12-31T07:49:42.259803Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2019-12-31T07:49:42.260385Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-12-31T07:49:42.260446Z 0 [Note] IPv6 is available.
2019-12-31T07:49:42.260462Z 0 [Note] - '::' resolves to '::';
2019-12-31T07:49:42.260487Z 0 [Note] Server socket created on IP: '::'.
2019-12-31T07:49:42.261927Z 0 [Note] InnoDB: Loading buffer pool(s) from /data/mysql/mysql/ib_buffer_pool
2019-12-31T07:49:42.262277Z 0 [Note] InnoDB: Buffer pool(s) load completed at 191231 15:49:42
2019-12-31T07:49:42.264556Z 0 [Warning] Failed to open optimizer cost constant tables
2019-12-31T07:49:42.264839Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2019-12-31T07:49:42.264937Z 0 [ERROR] Aborting
(遇到這個報錯問題,有可能是因為安裝目錄設定不對導致的,我試過自己重新安裝
一個測試庫,然後沒有按筆記上的目錄設定,自己設定了新的不同的目錄)
登陸後第一件事是先修改密碼,否則敲啥命令都報錯,老老實實改密碼
進入mysql修改初始密碼,修改遠端連線的使用者許可權問題
alter user 'root'@'localhost' identified by 'TaB)*.Wtf4F)';
flush privileges; #重新整理許可權
mysql -uroot -pTaB)*.Wtf4F)
use mysql;
update user set host = '%' where user ='root';
flush privileges;
如果遇到報錯1:
Starting MySQL.Logging to '/data/mysql5.7.22/data/mysqld.log'.
ERROR! The server quit without updating PID file (/data/mysql5.7.22/data//lcdb2.pid).
cd /data/mysql5.7.22/data/
chown -R mysql.mysql .
如果遇到報錯2:
[root@lcdb1 data]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
alter user 'root'@'%' identified by '****';
flush privileges;
mysql -uroot -p"****"
use mysql;
update user set host = '%' where user ='root';
flush privileges;
如果遇到報錯3:
mysql> alter user 'root'@'%' identified by '****';
ERROR 1820 (HY000): Unknown error 1820
SET PASSWORD = PASSWORD('****');
flush privileges;
select user,host,authentication_string from mysql.user;
create user 'root'@'%' identified by '****';
grant all privileges on *.* to 'root'@'%';
flush privileges;
如果遇到報錯4:
[root@lcdb1 data]# mysql -uroot -p"****" -h192.168.159.4
mysql: [Warning] Using a password on the command line interface can be insecure.
touch /etc/my.password
vi /etc/my.password
[client]
user=root
password="****"
host=127.0.0.1
使用以下命令登入可以消除[Warning]
mysql --defaults-extra-file=/etc/my.password
CENTOS7.6版本開機不會自啟動,需修改許可權
chmod +x /etc/rc.d/rc.local
主從搭建
主庫配置
vi /etc/my.cnf
[mysqld]
server-id=101
datadir=/data/mysql5.7.22/data/
socket=/tmp/mysqld.sock
user=mysql
log-bin=/data/mysql5.7.22/data/mysql-bin.log
log-bin-index=/data/mysql5.7.22/data/mysql-bin.index
expire_logs_days=7
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
####Parameter configuration######
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_format="MIXED"
max_allowed_packet = 4M
net_buffer_length = 8K
key_buffer_size=384M
query_cache_type=0
query_cache_size=0
tmp_table_size=512
innodb_buffer_pool_size = 512M
innodb_log_buffer_size=8M
sort_buffer_size=1024
read_buffer_size=1024
read_rnd_buffer_size=768
join_buffer_size=2048
thread_stack=256
binlog_cache_size=128
thread_cache_size=128
table_open_cache = 384
max_connections = 512
innodb_flush_log_at_trx_commit = 2
default-time_zone = '+8:00'
innodb_flush_log_at_trx_commit=2
sync_binlog=0
wait_timeout=500
innodb_flush_log_at_trx_commit=2
sync_binlog=0
#########slow log######
slow_query_log=1
slow_query_log_file=/data/mysql5.7.22/mysql.slow
long_query_time=2
[mysqld_safe]
log-error=/data/mysql5.7.22/data/lcdb1.log
重啟
service mysqld restart
主庫配置同步使用者
grant replication slave on *.* to 'Master-slave'@'192.168.159.5' identified by 'TaB)*.Wtf4F)';
flush privileges;
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 | 601 | Master-slave | mysql | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
從庫配置(其實就是server-id修改一下比主庫數字大即可)
vi /etc/my.cnf
[mysqld]
server-id=102
datadir=/data/mysql5.7.22/data/
socket=/tmp/mysqld.sock
user=mysql
log-bin=/data/mysql5.7.22/data/mysql-bin.log
log-bin-index=/data/mysql5.7.22/data/mysql-bin.index
expire_logs_days=30
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
####Parameter configuration######
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_format="MIXED"
max_allowed_packet = 4M
net_buffer_length = 8K
key_buffer_size=384M
query_cache_type=0
query_cache_size=0
tmp_table_size=512
innodb_buffer_pool_size = 512M
innodb_log_buffer_size=8M
sort_buffer_size=1024
read_buffer_size=1024
read_rnd_buffer_size=768
join_buffer_size=2048
thread_stack=256
binlog_cache_size=128
thread_cache_size=128
table_open_cache = 384
max_connections = 512
innodb_flush_log_at_trx_commit = 2
default-time_zone = '+8:00'
innodb_flush_log_at_trx_commit=2
sync_binlog=0
wait_timeout=500
innodb_flush_log_at_trx_commit=2
sync_binlog=0
#########slow log######
slow_query_log=1
slow_query_log_file=/data/mysql5.7.22/mysql.slow
long_query_time=2
[mysqld_safe]
log-error=/data/mysql5.7.22/data/lcdb2.log
重啟
service mysqld restart
在主庫查詢ID號和日誌檔案號
show master status;
再登陸從庫
從庫
mysql> CHANGE MASTER TO MASTER_HOST='192.168.159.4',MASTER_USER='Master-slave',MASTER_PASSWORD='TaB)*.Wtf4F)',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000002',MASTER_LOG_POS=601,MASTER_CONNECT_RETRY=10;
start slave;
檢視
show slave status \G
這裡有些地方還有疑惑,比如我在配置檔案增加以下資訊會無法啟動資料庫
[mysqld_safe]
log-error=/data/mysql5.7.22/log/tsdb1_error.log
pid-file=/data/mysql5.7.22/data/tsdb1.pid
啟動會遇到報錯
service mysqld start
Starting MySQL. ERROR! The server quit without updating PID file (/data/mysql5.7.22/data//tsdb1.pid).
一直查資料無法解決
以上都是我根據各種網上資料加上自己遇到的問題,總結修改後的,只作為寫給自己的筆記,方便下次搭建的時候檢視,只不過那個設定只給自己看的功能不見了。
注意一個問題,在生產環境,要注意時區問題
[mysqld]
default-time_zone = '+8:00'
使用北京時間的時區
error 1045密碼錯誤
select * from mysql.user where user='root';
use mysql;
update user set authentication_string=password('123456') where user='root' and host='localhost';
update user set authentication_string=password('123456') where user='root' and host='%';
flush privileges;
error 1086密碼過期
use mysql;
update user set password_expired="N" where user="root";
flush privileges;
主從切換
mysql主從關係中,如果master當機了,則要提升slave為主,
等原來的主庫恢復之後,則要把老的主庫變為從庫,
這樣才能盡最大可能的保證應用層面的業務高可用性和資料的完整性。
## mysql主從切換為從主:
從庫變主庫
將要由現在的從庫切換為主庫:
show processlist;# 確保Slave has read all relay log;
STOP SLAVE IO_THREAD
show slave status \G;檢查IO及SQL執行緒是否正常,如果為NO表明同步不一致
stop slave;
reset master;
reset slave all;(看版本號)
grant replication slave on *.* repl@'IP' identified by '密碼';
show master status;#記住這裡列出的log_file和log_pos資訊
------------------------------------------------------------------------------
## 主庫變從庫
將要由現在的主庫切換成從庫
Reset master;(新的slave,老的master)
Reset slave;
change master to master_host="IP",
master_port=3306,
master_user="repl",
master_password="密碼",
master_log_file="...",#上一步中列出的log_file
master_log_pos="...";#上一部中列出的log_pos
start slave;
show slave status\G;
目前只是基礎搭建,還有很多最佳化的引數沒有驗證測試,後續再補上
補充一下:
MYSQL還有一個和效能有關的關鍵引數,生產環境遇到的一個效能問題
innodb_flush_log_at_trx_commit
該引數控制重做日誌寫入磁碟的過程。我們知道 InnoDB 使用“Write Ahead Log”策略來避免資料丟失問題,即依靠重做日誌來保證資料能在丟失後進行恢復。因此,InnoDB 重做日誌的持久化非常重要。
該引數的有效值有 0、1、2:
0:事務提交時,不將重做日誌緩衝寫入磁碟,而是依靠 InnoDB 的主執行緒每秒執行一次重新整理到磁碟。因此如果 MySQL 發生當機,那麼就有可能丟失一部分事務。
1:事務提交時,會將重做日誌緩衝寫入磁碟,並且立即重新整理(fsync())。注意,因為作業系統的“延遲寫”特性,此時的刷入只是寫到了作業系統的緩衝區中,因此執行同步操作才能保證一定持久化到了硬碟中。
2:事務提交時,會將重做日誌緩衝寫入磁碟,但是不會立即進行重新整理操作,因此只是寫到了作業系統的緩衝區。此時若作業系統發生當機而沒有即使的同步,也可能會丟失一部分資料。
可以看到,只有1才能真正地保證事務的永續性,但是由於重新整理操作 fsync() 是阻塞的,直到完成後才返回,我們知道寫磁碟的速度是很慢的,因此 MySQL 的效能會明顯地下降。如果不在乎事務丟失,,0和2能獲得更高的效能。
sync_binlog
該引數控制著二進位制日誌寫入磁碟的過程。
該引數的有效值為0 、1、N:
0:預設值。事務提交後,將二進位制日誌從緩衝寫入磁碟,但是不進行重新整理操作(fsync()),此時只是寫入了作業系統緩衝,若作業系統當機則會丟失部分二進位制日誌。
1:事務提交後,將二進位制檔案寫入磁碟並立即執行重新整理操作,相當於是同步寫入磁碟,不經過作業系統的快取。
N:每寫N次作業系統緩衝就執行一次重新整理操作。
二進位制日誌檔案涉及到資料的恢復,以及想在主從之間獲得最大的一致性,那麼應該將該引數設定為1,但同時也會造成一定的效能損耗。
通常,會將這兩個引數都設定成1來保證資料的安全,但是如果在某些情況下效能更重要,那麼可以考慮將其設為其他值來獲得最大的效能。
設定為1,最安全,但是有較大的效能損失;
設定為0,效率最高,但是最不安全;
設定為2,只要作業系統不崩潰,資料不會丟失;
一般有主從架構可設定為(主主架構也可以,或者對資料安全要求不高),這樣設定的好處是提高IO效能,面對大併發也有一定的效能提升
innodb_flush_log_at_trx_commit=2
sync_binlog=0
遇到報錯:
service mysqld start
Starting MySQLCouldn't find MySQL server (/data/mysql5.7.22/bin/mysqld_safe)[失敗]
檢查bin
cp /opt/mysql5.7.22/bin/* /data/mysql5.7.22/bin/
遇到報錯2:
service mysqld start
Starting MySQL.Logging to '/data/mysql5.7.22/data/mysqld.log'.
ERROR! The server quit without updating PID file (/data/mysql5.7.22/data//lcdb2.pid).
切換到資料庫資料目錄
cd /data/mysql5.7.22/data/
chown -R mysql.mysql .
遇到報錯3:
主從搭建報錯,從庫發現
Slave_IO_Running: Connecting
檢查 主伺服器檢視主從同步帳號,已設定登入ip為%
mysql> select user,host from mysql.user;
+---------------+-----------------+
| user | host |
+---------------+-----------------+
| repl_user | % |
遇到報錯4:
Slave_IO_Running: NO
檢查資料庫資料目錄下的檔案是否都是mysql許可權 ,如果沒有
chown -R mysql.mysql .
檢查防火牆iptables 和 getenforce
遇到報錯5:
遇到報錯:
2021-08-26T09:02:07.121168Z 0 [ERROR] Can't find error-message file '/data/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2021-08-26T09:02:07.122505Z 0 [ERROR]
2021-08-26T09:02:07.122523Z 0 [ERROR] Aborting
log-error 路徑設定不對,有目錄沒建立或者許可權之類的
keepalived搭建
安裝包:(rpm在某些版本作業系統需要用到)
keepalived-1.4.2.tar.gz
libnfnetlink-1.0.0-1.el6.x86_64.rpm
libnfnetlink-devel-1.0.0-1.el6.x86_64.rpm
libnl-devel-1.1.4-2.el6.x86_64.rpm
安裝包下載地址:
keepalived-1.4.2.tar.gz
http://rpmfind.net/linux/RPM/centos/6.10/x86_64/Packages/libnfnetlink-devel-1.0.0-1.el6.x86_64.html
http://rpmfind.net/linux/RPM/centos/6.10/x86_64/Packages/libnl-devel-1.1.4-2.el6.x86_64.html
安裝keepalived
tar zxvf keepalived-1.4.2.tar.gz
cd keepalived-1.4.2
./configure
遇到以下報錯
!!! OpenSSL is not properly installed on your system. !!!
!!! Can not include OpenSSL headers files.
解決方法:
yum -y install openssl-devel
如果./configure遇到以下報錯
no acceptable C compiler found in $PATH
就要安裝gcc, yum -y install gcc
make
make install
mkdir /etc/keepalived
cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/sbin/keepalived /usr/sbin/
master的keepalived配置檔案如下
vi /etc/keepalived/keepalived.conf
global_defs {
router_id MySQL-HA
}
vrrp_script check_run {
script "/data/mysql/mysql_check.sh"
interval 60
}
vrrp_sync_group VG1 {
group {
VI_1
}
}
vrrp_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 51
priority 100
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1234
}
track_script {
check_run
}
notify_master /data/mysql/master.sh
notify_stop /data/mysql/stop.sh
virtual_ipaddress {
192.168.159.100
}
}
slave的keepalived配置檔案如下:
mkdir /etc/keepalived
vi /etc/keepalived/keepalived.conf
global_defs {
router_id MySQL-HA
}
vrrp_script check_run {
script "/data/mysql/mysql_check.sh"
interval 60
}
vrrp_sync_group VG1 {
group {
VI_1
}
}
vrrp_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 51
priority 90
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1234
}
track_script {
check_run
}
notify_master /data/mysql/master.sh
notify_stop /data/mysql/stop.sh
virtual_ipaddress {
192.168.159.100
}
}
Mysql_check.sh \ master.sh \ stop.sh指令碼
vi mysql_check.sh
#!/bin/bash
export PATH=$PATH:/data/mysql5.7.22/bin
count=1
while true
do
mysql -uroot -p"YF_f#_Zs6dVBrnwE" -h192.168.135.206 -e "show status;" > /dev/null 2>&1
i=$?
ps aux | grep mysqld | grep -v grep > /dev/null 2>&1
j=$?
if [ $i = 0 ] && [ $j = 0 ]
then
exit 0
else
if [ $i = 1 ] && [ $j = 0 ]
then
exit 0
else
if [ $count -gt 5 ]
then
break
fi
let count++
continue
fi
fi
done
/usr/bin/systemctl stop keepalived
vi master.sh
#!/bin/bash
export PATH=$PATH:/data/mysql5.7.22/bin
Master_Log_File=$(mysql -uroot -p"YF_f#_Zs6dVBrnwE" -h192.168.135.206 -e "show slave status\G" | grep -w Master_Log_File | awk -F": " '{print $2}')
Relay_Master_Log_File=$(mysql -uroot -p"YF_f#_Zs6dVBrnwE" -h192.168.135.206 -e "show slave status\G" | grep -w Relay_Master_Log_File | awk -F": " '{print $2}')
Read_Master_Log_Pos=$(mysql -uroot -p"YF_f#_Zs6dVBrnwE" -h192.168.135.206 -e "show slave status\G" | grep -w Read_Master_Log_Pos | awk -F": " '{print $2}')
Exec_Master_Log_Pos=$(mysql -uroot -p"YF_f#_Zs6dVBrnwE" -h192.168.135.206 -e "show slave status\G" | grep -w Exec_Master_Log_Pos | awk -F": " '{print $2}')
i=1
while true
do
if [ $Master_Log_File = $Relay_Master_Log_File ] && [ $Read_Master_Log_Pos -eq $Exec_Master_Log_Pos ]
then
echo "ok"
break
else
sleep 1
if [ $i -gt 60 ]
then
break
fi
continue
let i++
fi
done
mysql -uroot -p"YF_f#_Zs6dVBrnwE" -h192.168.135.206 -e "stop slave;"
mysql -uroot -p"YF_f#_Zs6dVBrnwE" -h192.168.135.206 -e "show master status;" > /tmp/master_status_$(date "+%y%m%d-%H%M").txt
vi stop.sh
#!/bin/bash
export PATH=$PATH:/data/mysql5.7.22/bin
M_File1=$(mysql --defaults-extra-file=/etc/my.password -e "show master status\G" | awk -F': ' '/File/{print $2}')
M_Position1=$(mysql --defaults-extra-file=/etc/my.password -e "show master status\G" | awk -F': ' '/Position/{print $2}')
sleep 1
M_File2=$(mysql --defaults-extra-file=/etc/my.password -e "show master status\G" | awk -F': ' '/File/{print $2}')
M_Position2=$(mysql --defaults-extra-file=/etc/my.password -e "show master status\G" | awk -F': ' '/Position/{print $2}')
i=1
while true
do
if [ $M_File1 = $M_File2 ] && [ $M_Position1 -eq $M_Position2 ]
then
echo "ok"
break
else
sleep 1
if [ $i -gt 60 ]
then
break
fi
continue
let i++
fi
done
在作業系統為CENTOS7.6版本,啟動KEEPALIVED命令有變化
systemctl start keepalived
systemctl stop keepalived
KEEPALIVED如果無法啟動,注意group V1要一致,且同網段不能用相同的group(多個KEEPALIVED叢集)
如果還是無法啟動,注意,mysql_check.sh master.sh stop.sh幾個指令碼里面,是否設定了環境變數(export PATH=$PATH:/data/mysql5.7.22/bin)
主備切換:
發生故障主備切換後,
原主庫mysql服務停止,keepalived服務停止,原從庫升級為主庫,
原主庫恢復故障後,啟動MYSQL服務,啟動KEEPALIVED服務,重新配置原從庫為現從庫,即恢復原主從結構。
停止原從庫KEEPALIVED服務,啟動原從庫KEEPALIVED服務。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28371090/viewspace-2738415/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MYSQL5.7.22 原始碼安裝 主從搭建MySql原始碼
- MYSQL5.6.40原始碼安裝 主從搭建 主主搭建MySql原始碼
- Nginx+Keepalived 主備高可用 安裝與配置Nginx
- POSTGRESQL10.3原始碼安裝主從搭建 pgpoolii + keepalive 高可用(未成功,實驗中)SQL原始碼
- MySQL叢集搭建(6)-雙主+keepalived高可用MySql
- POSTGRESQL10.8原始碼安裝主從搭建SQL原始碼
- POSTGRESQL10.3原始碼安裝主從搭建SQL原始碼
- mysql高可用衡搭建(Keepalived)MySql
- Haproxy+Keepalived高可用環境部署梳理(主主和主從模式)模式
- MySQL主主模式+Keepalived高可用MySql模式
- [Mysql高可用]——雙主互備+keepalivedMySql
- MySQL進階:主主複製+Keepalived高可用MySql
- MySQL高可用架構之Keepalived+主從架構部署MySql架構
- LVS+Keepalived 高可用環境部署記錄(主主和主從模式)模式
- mysql5.6主主複製及keepalived 高可用MySql
- Linux原始碼安裝RabbitMQ高可用叢集Linux原始碼MQ
- 【工具-Nginx】從入門安裝到高可用叢集搭建Nginx
- mysql+keepalived 雙主熱備高可用MySql
- Keepalived 高可用
- MySQL主主複製+Keepalived打造高可用MySQL叢集MySql
- MySQL 高可用性—keepalived+mysql雙主MySql
- postgresql10主從+keepalived高可用自動切換(切換關鍵在指令碼)SQL指令碼
- 基於 HAProxy + KeepAlived 搭建 RabbitMQ 高可用叢集MQ
- Keepalived+Nginx高可用叢集搭建筆記Nginx筆記
- mysql主主複製+keepalived 打造高可用mysql叢集薦MySql
- PostgreSQL repmgr高可用叢集+keepalived高可用SQL
- MySQL 高可用性之 Keepalived 雙主熱備MySql
- 搭建高可用kubernetes叢集(keepalived+haproxy)
- nginx+keepalived高可用Nginx
- Keepalived 高可用詳解
- mysql高可用之keepalivedMySql
- MySQL主從配置及haproxy和keepalived搭建MySql
- 使用Keepalived實現Nginx的雙機主備高可用Nginx
- Mysql+Keepalived雙主熱備高可用操作記錄MySql
- Redis高可用方案:使用Keepalived實現主備雙活Redis
- CentOS6下OpenLDAP+PhpLdapAdmin基本安裝及主從/主主高可用模式部署記錄CentOSLDAPHP模式
- MySQL主主+Keepalived+LVS高可用(二):單點寫入MySql
- rpm 安裝5.6 MySql主從搭建MySql