Heartbeat+drbd+mysql

Source: Internet
Author: User
Tags chmod stop script

Configuring heartbeat to take over the DRBD service

configure heartbeat to take over the DRBD service (continuation of the heartbeat and DRBD post content)1, both ends are confirmed to be established.Data Directory2, turn off the DRBD service, shut down the heartbeat service, turn off all from startup3, both ends are configured haresources data-1-1IPADDR::192.168.0.191/ -/eth0 drbddisk::d ata filesystem::/dev/drbd0::/data::ext3 Boot Sequence1, start the master and backup DRBD in turn2, DRBD host3, start the primary and standby heartbeat, start the main side automatically mount Drbd0 to/Data
The status is as follows when startup is complete
[email protected]/]# CAT/PROC/DRBD
Version:8.4.9-1 (api:1/proto:86-101)
git-hash:9976da086367a2476503ef7f6b13d4567327a280 build by [email protected], 2016-12-13 18:38:15
0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r-----
ns:340 nr:16 dw:356 dr:3646 al:2 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
[email protected]/]# IP Addr | grep 191
inet 192.168.0.191/24 BRD 192.168.0.255 scope Global secondary eth0
[[email protected] ~]# DF
Filesystem 1k-blocks used Available use% mounted on
/dev/sda2 5916420 4207616 1401604 76%/
Tmpfs 502384 0 502384 0%/dev/shm
/DEV/SDA1 194241 36262 147739 20%/boot
/dev/drbd0 1011928 47696 912828 5%/data

[Email protected] ~]# CAT/PROC/DRBD
Version:8.4.9-1 (api:1/proto:86-101)
git-hash:9976da086367a2476503ef7f6b13d4567327a280 build by [email protected], 2016-12-13 18:38:15
0:cs:connected ro:secondary/primary ds:uptodate/uptodate C r-----
Ns:16 nr:340 dw:356 dr:1364 al:1 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

Install MySQL

#InstallCMakeTar-ZXVF cmake-2.8.0.Tar. GZCD CMake-2.8.0./Configuregmake&& GmakeInstallCD.. #InstallncursesYum InstallNcurses-devel-y#InstallMySQL5.5.49useradd MySQL-s/bin/nologin-Mmkdir/DataChown-R Mysql.mysql/DataTarXF mysql-5.5. the.Tar. GZCD MySQL-5.5. theCMake-dcmake_install_prefix=/usr/local/mysql5.5.49  -dmysql_datadir=/Data-dmysql_unix_addr=/usr/local/mysql5.5.49/tmp/Mysqld.sock-ddefault_charset=UTF8-ddefault_collation=Utf8_general_ci-dextra_charsets= All-denabled_local_infile=1  -dwith_innobase_storage_engine=1  -dwithout_federated_storage_engine=1  -dwith_blackhole_storage_engine=1  -dwithout_example_storage_engine=1  -dwithout_partition_storage_engine=1  -dwith_fast_mutexes=1  -dwith_zlib=bundled-denabled_local_infile=1  -dwith_readline=1  -dwith_embedded_server=1  -dwith_debug=0; Make&& Make Install#init MySQLLN-s/usr/local/mysql5.5.49/usr/local/MySQL/bin/CP/usr/local/mysql/support-files/my-small.cnf/etc/my.cnfEcho 'export Path=/usr/local/mysql/bin: $PATH'>>/etc/Profilesource/etc/ ProfileChown-R mysql.mysql/usr/local/MySQLchmod-R1777/TMPCD/usr/local/mysql/scripts =======>the spare side ignores this step./mysql_install_db--basedir=/usr/local/mysql--datadir=/data/--user=mysql =======>the spare side ignores this stepCP/usr/local/mysql5.5.49/support-files/mysql.server/etc/init.d/mysqldchmod+x/etc/init.d/mysqld/etc/init.d/mysqld Start =======>the spare side ignores this step netstat-lntup |grep 3306=======> The backup side ignores this step


[[email protected] scripts]# MySQLConfirm MySQL Installation OK
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.5.49 Source Distribution

Copyright (c), Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
mysql> CREATE DATABASE DRBD; #用来确认备端
Query OK, 1 row affected (0.06 sec)

Configure heartbeat to take over MySQL

 both ends configured haresources[[email protected] -1-1 ~]# cat/etc/ha.d/ haresources data-1-1IPADDR::192.168.0.191/ -/eth0 drbddisk::d ata filesystem::/dev/drbd0::/data::ext3 mysqld[[email protected] -1-2 ~]# cat/etc/ha.d/ haresources data-1-1IPADDR::192.168.0.191/ -/eth0 drbddisk::d ata filesystem::/dev/drbd0::/Data::ext3 mysqldDescription
Data-1-1 Host Name
Ipaddr::192.168.0.191/24/eth0 Heartbeat configuration IP script, equals/etc/ha.d/resource.d/ipaddr 192.168.0.191/24/eth0 start/stop
Drbddisk::d ATA starts the data resource defined by DRBD, equal to/etc/ha.d/resource.d/drbddisk data Stop/start
FILESYSTEM::/DEV/DRBD0::/DATA::EXT3 attach drbd0 device to/data/directory, same principle
MYSQLD MySQL service start-stop script equals/etc/init.d/mysqld start/stop
to test
[[email protected] ~]#/etc/init.d/heartbeat stop#主端停止heartbeat, look at the backup situation.
Stopping high-availability Services:done.
[[email protected] ~]# DF #确认/data Mounted
Filesystem 1k-blocks used Available use% mounted on
/dev/sda2 5916420 4243564 1365656 76%/
Tmpfs 502384 0 502384 0%/dev/shm
/DEV/SDA1 194241 36263 147738 20%/boot
/dev/drbd0 1011928 47692 912832 5%/data
[email protected] ~]# IP Addr | grep 191 #确认vip漂移
inet 192.168.0.191/24 BRD 192.168.0.255 scope Global secondary eth0

[[email protected] ~]# mysql-u root-e "show databases;" grep drbd #确认数据库及数据
Drbd

[email protected] ~]# CAT/PROC/DRBD #接管drbd, become primary
Version:8.4.9-1 (api:1/proto:86-101)
git-hash:9976da086367a2476503ef7f6b13d4567327a280 build by [email protected], 2016-12-13 18:38:15
0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r-----
ns:612 nr:42460 dw:43072 dr:17959 al:8 bm:0 lo:2 pe:0 ua:0 ap:2 ep:1 wo:f oos:0

[[email protected] ~]#/etc/init.d/heartbeat start detection ditto, back cut normal

Management essentials

1 , Heartbeat DRBD MySQL is set to non-boot 2 , master and standby to start DRBD in turn, and place the master 3, the main standby start heartbeat,heartbeat will start VIP, Mount DRBD device, start MySQL

Heartbeat+drbd+mysql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.