91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Mysql數據庫高可用

發布時間:2020-07-22 10:25:54 來源:網絡 閱讀:373 作者:左客 欄目:MySQL數據庫

Mysql數據庫高可用

Mysql(5.7.19)+keepalive(1.3.0)    +RHEL6.5

Mysql下載地址

https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

Keepalived地址

http://www.keepalived.org/software/keepalived-1.3.0.tar.gz

規劃如下


ip

端口

備注

Mysql1

172.25.254.120

3306


Mysql2

172.25.254.130

3306


keepalived

172.25.254.111



 

:首先搭建主主數據庫

拷貝壓縮包到系統/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 <<eof >/etc/my.cnf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

 

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

eof

 

 

ln -s /usr/local/mysql/bin/mysql /bin/mysql

cd bin/

service mysqld start

sed  -i '5askip-grant-tables' /etc/my.cnf

sed  -i '$a[mysql]' /etc/my.cnf

sed  -i '$asocket=/var/lib/mysql/mysql.sock' /etc/my.cnf

service mysqld restart

 

mysql   -e "update mysql.user set authentication_string=password('123456') where user='root' and Host='localhost';"

sed -i '/skip-grant-tables/d' /etc/my.cnf

service mysqld restart

 

mysql -uroot -p123456

SQL>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 #兩個id不一樣即可

service mysqld restart

 

至此兩個數據庫搭建完成

二:主主搭建

mysql -uroot -p123456#登陸數據庫

grant   replication    slave  on  *.*    to   slaveuser@"172.25.254.120"   identified by "123456";#130上配置

grant   replication    slave  on  *.*    to   slaveuser@"172.25.254.130"   identified by "123456";#120上配置

登陸測試是否成功

mysql> show master status\G;#分別查看兩個節點

****************** 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",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",master_log_pos=154;#120上操作

 

start   slave;#兩節點分別開啟

show  slave status\G;

Slave_IO_Running: YES

Slave_SQL_Running: YES

 

可以自己測試

三:keepalived搭建

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"#腳本文件

interval 5

}

vrrp_instance HA {

    state MASTER#BACKUP

    interface eth0

    virtual_router_id 51

    priority 100#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 #腳本文件

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


 

測試,與開機啟動不在次次試驗中,可自行測試


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

兴海县| 蒙自县| 长乐市| 台南县| 社会| 炉霍县| 紫金县| 南昌市| 崇明县| 库尔勒市| 扶绥县| 江源县| 历史| 鹰潭市| 富平县| 霍山县| 中方县| 东乡族自治县| 布拖县| 鞍山市| 珲春市| 治多县| 辽宁省| 锡林浩特市| 绵阳市| 嘉黎县| 镇远县| 丘北县| 宝鸡市| 中方县| 建始县| 绥滨县| 琼结县| 德化县| 富川| 贵港市| 高平市| 安化县| 穆棱市| 六盘水市| 嘉兴市|