MySQL Heartbeat+drbd高可用
来源:互联网 发布:mac 安装软件如何卸载 编辑:程序博客网 时间:2024/04/29 08:51
MySQL Heartbeat+drbd高可用环境
--具体的配置信息如下所示:角色 ip地址 主机名字 server-id primary 心跳及传输IP:192.168.0.51 data-1 1 管理及对外IP:10.0.0.51 VIP:10.0.0.151standby 心跳及传输IP:192.168.0.52 data-2 1 管理及对外IP:10.0.0.51 VIP:10.0.0.152
Heartbeat安装配置
http://blog.csdn.net/lt53130640688/article/details/50149425
(1)关闭防火墙(两节点执行) chkconfig iptables off service iptables stop service iptables status setenforce 0 sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config(2)修改hosts解析文件(两节点执行) vi /etc/hosts data-1 192.168.0.51 data-2 192.168.0.52(4)添加主机路由(两节点分别执行) --一节点(192.168.0.51) route add -host 192.168.0.52 dev eth1 echo 'route add -host 192.168.0.52 dev eth1'>>/etc/rc.local route -n --二节点(192.168.0.52) route add -host 192.168.0.51 dev eth1 echo 'route add -host 192.168.0.51 dev eth1'>>/etc/rc.local route -n(5)下载epel包,yum安装heartbeat(两节点执行) --保留rpm包配置 /etc/yum.conf --163yum源:wget http://mirrors.163.com/.help/CentOS6-Base-163.repo wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm yum install -y heartbeat*(6)修改配置文件(两节点执行) --配置文件模板路径:/usr/share/doc/heartbeat-3.0.4/ 配置: cd /usr/share/doc/heartbeat-3.0.4 cp ha.cf authkeys haresources /etc/ha.d/ --**ha.cf参数配置** debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local1 keepalive 2 deadtime 30 warntime 10 initdead 60 #bcast eth0 # Linux #mcast eth0 225.0.0.1 694 1 0 #ucast eth0 192.168.1.2 #使用多播, mcast eth1 225.0.0.18 694 1 0 auto_failback on node data-1 node data-2 --**authkeys参数配置(sha1安全级别最高)** auth 1 1 sha1 43432eeffe03ffi9ekfk0efe000efe0ff0fef0 --**haresources参数配置(资源配置)资源可传递start stop 参数即可** data-1 IPaddr::10.0.0.151/24/eth0 data-2 IPaddr::10.0.0.152/24/eth0(7)启动和关闭heartbeat服务 service heartbeat start service heartbeat stop service heartbeat status service heartbeat reload --chkconfig heartbeat off|on(8)heartbeat资源接管 --完全释放 /usr/share/heartbeat/hb_standby --完全接管 /usr/share/heartbeat/hb_takeover --接管本地 /usr/share/heartbeat/hb_takeover local
drbd安装配置
http://blog.csdn.net/lt53130640688/article/details/50150135
存储分区
(1)使用fdisk或者parted分区 fdisk -l fdisk /dev/sdb partprobe ##分区信息写入磁盘 ##或者采用parted分区,超过2T必须用partprobe分区 parted /dev/sdb mklabel gpt parted /dev/sdb mkpart primary 0 4800000 #4.9T parted /dev/sdb mkpart primary 4800001 5800001 parted /dev/sdb mkpart primary 5800002 5804098 parted /dev/sdb p(2)数据文件盘格式化 mkfs.ext4 /dev/sdb1 #mkfs.ext4 ##备节点不需要格式化 #状态分区不要格式化(大小范围:1-2G) [root@data-2 ~]# mount /dev/sdb2 /mnt mount: you must specify the filesystem type
drbd安装
(1)设置环境变量 export LC_ALL=C(2)编译安装drbd软件 wget http://oss.linbit.com/drbd/8.4/drbd-8.4.4.tar.gz tar xf drbd-8.4.4.tar.gz cd drbd-8.4.4 ./configure --prefix=/application/drbd8.4.4 --with-km --with-heartbeat --sysconfdir=/etc/ make KDIR=/usr/src/kernels/$(uname -r)/ make install lsmod |grep drbd modprobe drbd ##重启失效,加载到内核中 lsmod |grep drbd echo "modprobe drbd" >>/etc/rc.local ##开机自动加载 #yum install kernel-devel -y(3)yum安装drbd软件 [root@data-1 /]# rpm -ivh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm [root@data-2 /]# yum install drbd kmod-drbd84
drbd配置
--模板路径[root@data-1 drbd8.4.4]# ll /etc/drbd.d/total 4-rw-r--r-- 1 root root 1836 Dec 1 10:52 global_common.conf--配置文件(两节点)[root@data-1 etc]# vi /etc/drbd.conf global { usage-count no;}common { syncer { rate 1000M; verify-alg crc32c; }}resource data { protocol C; disk { on-io-error detach; } on data-1 { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.51:7788; meta-disk /dev/sdb2[0]; } on data-2 { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.52:7788; meta-disk /dev/sdb2[0]; }}
drbd初始化与启动
drbdadm --helpdrbdadmin create-md data(1)初始化 [root@data-1 ~]# drbdadm create-md data Writing meta data... initializing activity log NOT initializing bitmap New drbd meta data block successfully created.(2)创建目录 mkdir -p /application/drbd8.4.4/var/run/drbd(3)启动资源data drbdadm up data --查看同步状态 [root@data-1 ~]# cat /proc/drbd version: 8.4.4 (api:1/proto:86-101)GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@data-1, 2015-12-01 10:52:04 0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r----- ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:6297452(4)将第一个节点置为primary drbdadm -- --overwrite-data-of-peer primary data(5)查看同步完成状态 [root@data-1 data]# cat /proc/drbd version: 8.4.4 (api:1/proto:86-101)GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@data-1, 2015-12-01 10:52:04 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:6297520 nr:0 dw:72 dr:6298459 al:3 bm:385 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0(6)磁盘挂载(仅primary节点),Secondary挂载需要先drbdadm down data -->mount /dev/sdb1 /data mount /dev/drbd0 /data
MySQL编译安装
http://blog.csdn.net/lt53130640688/article/details/49659289
--MySQL参数不能有调用主机名的yum install ncurses-devel -ytar xf cmake-2.8.8.tar.gz cd cmake-2.8.8./configure gmakegmake installgroupadd mysqluseradd mysql -s /sbin/nologin -M -g mysqltar zxf mysql-5.5.32.tar.gzcd mysql-5.5.32cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \-DMYSQL_DATADIR=/application/mysql-5.5.32/data \-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_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=0make && make installln -s /application/mysql-5.5.32 /application/mysqlecho 'export PATH=/application/mysql/bin:$PATH' >>/etc/profiletail -1 /etc/profilesource /etc/profilecd /rz -yunzip -o data.zip chmod -R 1777 /tmpchown -R mysql.mysql /datafind /data/ -type f -name "mysql"|xargs chmod +x find /data/ -type f -name "mysql"|xargs ls -lfind /data/ -type f -name "mysql"|xargs dos2unixcd /application/mysql/scripts/./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/ --user=mysqlcd /data/3306/./mysql startnetstat -lntup/application/mysql/bin/mysqladmin -u root password '123456' -S /data/3306/mysql.sock cd /data/3306/./mysql stopnetstat -lntup
高可用集群配置
--两节点执行,启动drbddrbdadm up data--主节点执行,主节点挂载磁盘mount /dev/drbd0 /data--两节点执行,MySQL初始化,删除备节点/data下内容,或者备节点不初始化mkdir -p /data/3306/datachown mysql.mysql /data/3306/datacd /application/mysql/scripts/./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3306/data/ --user=mysql--两节点执行,拷贝mysql启动脚本cp /data/3306/mysql /etc/init.d/--两节点执行,修改heartbeat资源参数配置[root@data-1 resource.d]# vi /etc/ha.d/haresources data-1 IPaddr::10.0.0.151/24/eth0 drbddisk::data Filesystem::/dev/drbd0::/data::ext4 mysqldata-2 IPaddr::10.0.0.152/24/eth--两节点执行,关闭开机自启动服务chkconfig mysql offchkconfig drbd offchkconfig heartbeat offchkconfig --list|grep heartbeatchkconfig --list|grep mysqlchkconfig --list|grep drbd--主节点执行,关闭mysql服务,解除磁盘挂载,重启heartbeat服务service mysql stopservice heartbeat stopservice heartbeat start--备节点启动heartbeatservice heartbeat start--查看主节点各服务状态[root@data-1 resource.d]# ip addr|grep eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 10.0.0.51/24 brd 10.0.0.255 scope global eth0 inet 10.0.0.151/24 brd 10.0.0.255 scope global secondary eth0[root@data-1 resource.d]# mount/dev/drbd0 on /data type ext4 (rw)[root@data-1 resource.d]# netstat -lntActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN --备节点,其他服务无[root@data-2 /]# ip addr|grep eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 10.0.0.52/24 brd 10.0.0.255 scope global eth0 inet 10.0.0.152/24 brd 10.0.0.255 scope global secondary eth0
主备切换
--主节点,service heartbeat stop--查看备节点服务状态[root@data-2 /]# ip addr|grep eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 10.0.0.52/24 brd 10.0.0.255 scope global eth0 inet 10.0.0.152/24 brd 10.0.0.255 scope global secondary eth0 inet 10.0.0.151/24 brd 10.0.0.255 scope global secondary eth0 [root@data-2 /]# mount|grep data/dev/drbd0 on /data type ext4 (rw) [root@data-2 /]# cat /proc/drbd version: 8.4.4 (api:1/proto:86-101)GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@data-2, 2015-12-01 10:52:04 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:1348 nr:1492 dw:2840 dr:18339 al:9 bm:5 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 [root@data-2 /]# netstat -lntup|grep 3306tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 10082/mysqld --启动主节点heartbeat服务,资源重新回到主节点 [root@data-1 resource.d]# service heartbeat start[root@data-1 resource.d]# netstat -lntup|grep 3306tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 17887/mysqld [root@data-1 resource.d]# mount |grep data/dev/drbd0 on /data type ext4 (rw) [root@data-1 resource.d]# cat /proc/drbd version: 8.4.4 (api:1/proto:86-101)GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@data-1, 2015-12-01 10:52:04 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:1812 nr:1536 dw:3368 dr:25317 al:10 bm:5 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0[root@data-1 resource.d]# ip addr|grep eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 10.0.0.51/24 brd 10.0.0.255 scope global eth0 inet 10.0.0.151/24 brd 10.0.0.255 scope global secondary eth0--一节点服务器宕机,资源同样自动切换
0 0
- MySQL Heartbeat+drbd高可用
- DRBD+Heartbeat+Mysql高可用环境部署
- 构建MySQL+DRBD+heartbeat高可用
- MySQL+DRBD+heartbeat高可用方案
- Heartbeat+DRBD+MySQL高可用方案
- 高可用集群架构DRBD+HEARTBEAT+MYSQL
- drbd+nfs+heartbeat高可用
- MySQL+Heartbeat+DRBD构建高可用MySQL环境
- MySQL+Heartbeat+DRBD构建高可用MySQL环境
- Mysql+Heartbeat+Drbd搭建mysql的高可用
- MySQL高可用介绍4-Mysql主从同步+DRBD+heartbeat
- Mysql+Heartbeat+Drbd生产环境高可用部署若干问题解惑
- centos6 drbd heartbeat mysql高可用搭建与压测
- mysql高可用探究(五)Heartbeat+DRBD+mysql高可用方案
- HEARTBEAT+DRBD+NFS 高可用共享搭建
- nfs高可用架构之DRBD+heartbeat
- nfs+drbd+heartbeat实现高可用文件系统
- Heartbeat+DRBD+MySQL高可用架构方案与实施过程细节 【转】
- CC2541 indicate
- 安卓开发所遇问题笔记
- ios 获取屏幕的属性和宽度
- 3ds max 2015 安装方法
- Machine Learning week 9 quiz: Recommender Systems
- MySQL Heartbeat+drbd高可用
- MFC字体大小修改
- matlab图像几何操作
- 《leetCode》:Word Search II-------hard
- 五、如何让类对象只在栈(堆)上分配空间?
- 浅学设计模式之策略<Strategy>模式及在android中的使用
- google material design (2-1)
- 【leetcode】String to Integer (atoi)
- “南大软院大神养成计划“_第十七天的学习“