设为首页 加入收藏

TOP

heartbeat+DRBD+mysql+LVS集群实战(一)
2015-11-21 02:04:14 】 浏览:7037
Tags:heartbeat DRBD mysql LVS 集群 实战

四台主机

主机名 IP地址 用途

dbm128 172.16.0.128 heartbeat+DRBD+MYSQL的primary节点

dbm129 172.16.0.129 heartbeat+DRBD+mysql 的secondary节点

dbs130 172.16.0.130 slave(mater_host=172.16.0.233)

dbs131 172.16.0.131 slave(mater_host=172.16.0.233)

配置前的准备

1.设置hostname及解析

编辑/etc/hosts文件,添加如下内容:

172.16.0.128 dbm128

172.16.0.129 dbm129

2.新增加一块/dev/sdb5硬盘存放DRBD数据(两台都增加)

命令如下:

[root@dbm128 ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

The number of cylinders for this disk is set to 6527.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

e

Partition number (1-4): 1

First cylinder (1-6527, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527):

Using default value 6527

Command (m for help): n

Command action

l logical (5 or over)

p primary partition (1-4)

l

First cylinder (1-6527, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527):

Using default value 6527

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

3.DRBD的部署(两台机器都这么做)

yum -y install gcc gcc-c++ kernel* 安装好后重启一下,免得后面出错

#wget http://oss.linbit.com/drbd/8.4/drbd-8.4.3.tar.gz

# tar zxvf drbd-8.4.3.tar.gz

# cd drbd-8.4.3

# ./configure --prefix=/ --with-km

#make

#make install

4. 加载安装DRDB模块

#modprobe drbd

机器重启后DRBD模块消失,需要写入/etc/rc.local开机自动执行

通过lsmod来检查是否已经执行成功

[root@dbm128 drbd-8.4.3]# lsmod | grep drbd

drbd 327968 0

5.编辑配置文件(两台配置一样dbm128,dbm129)

如果后面有问题要把LINUX防火墙关闭,或者把端口增加过去

[root@dbm128 drbd-8.4.3]# cat /etc/drbd.conf

global {usage-count yes;}

common{syncer{rate 200M;}}

resource r0{

protocol C;

net{

cram-hmac-alg sha1;

shared-secret "FooFunFactory";

}

disk{

on-io-error detach;

fencing resource-only;

}

startup{

wfc-timeout 120;

degr-wfc-timeout 120;

}

device /dev/drbd1;

on dbm128{

disk /dev/sdb5;

address 172.16.0.128:7789;

meta-disk internal;

}

on dbm129{

disk /dev/sdb5;

address 172.16.0.129:7789;

meta-disk internal;

}

}

6.启动DRBD(两台操作)

可通过如下命令启动DRBD

[root@dbm128 drbd-8.4.3]# drbdadm create-md all

[root@dbm128 drbd-8.4.3]# /etc/init.d/drbd start

[root@dbm128 drbd-8.4.3]# drbdadm -- --overwrite-data-of-peer primary all (这一步只在主服务器上做)

在主机上查看DRBD状态

[root@dbm128 ~]# cat /proc/drbd

version: 8.4.3 (api:1/proto:86-101)

GIT-hash: 89a294209144b68adb3ee85a73221f964d3ee515 build by root@dbm128, 2014-07-18 23:01:15

1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r---n-

ns:45789492 nr:0 dw:0 dr:45794304 al:0 bm:2794 lo:0 pe:3 ua:5 ap:0 ep:1 wo:f oos:6639292

[================>...] sync'ed: 87.4% (6480/51196)M

finish: 0:06:46 speed: 16,336 (18,732) K/sec

以上数据正在同步。下面同步完成

[root@dbm128 ~]# cat /proc/drbd

version: 8.4.3 (api:1/proto:86-101)

GIT-hash: 89a294209144b68adb3ee85a732

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MongoDBMapReduce实战<5) 下一篇CentOS6.5安装mysqlcluster7.3.7..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目