主机1:server5.example.com 172.25.254.5html
主机2:server6.example.com 172.25.254.56
java
安装drbdnode
yum install gcc flex rpm-build kernel-devel -y rpmbuild ~ #在家目录生成 rpmbuild 编译所需路径 cp drbd-8.4.0.tar.gz rpmbuild/SOURCES/ tar zxf drbd-8.4.0.tar.gz cd drbd-8.4.0 ./configure --enable-spec --with-km rpmbuild -bb drbd.spec #编译生成 drbd rpm 包 rpmbuild -bb drbd-km.spec #编译 drbd 内核模块 cd ~/rpmbuild/RPMS/x86_64 rpm -ivh * 拷贝生成的 rpm 包到另外一主机,并安装软件包: scp ~/rpmbuild/RPMS/x86_64/* 172.25.254.6:/root
2.配置drbd.res文件 /etc/drbd/drbd.d
mysql
resource mysqldata { meta-disk internal; device /dev/drbd1; syncer { verify-alg sha1; } on server5.example.com { // 此处必须为主机名,解析里改也不行。切忌 disk /dev/vdb; /drbd要使用的存储磁盘 address 172.25.254.5:7789; } on server6.example.com { disk /dev/vdb; address 172.25.254.6:7789; } } 两台主机都执行的操做 drbdadm create-md mysqldata /etc/init.d/drbd start cat /proc/drbd 能够查看状态 下来在server5上将 server5 设置为 primary 节点,并同步数据:(在 demo 主机执行如下命令) drbdsetup /dev/drbd1 primary --force 在两台主机上查看同步状态: watch cat /proc/drbd 数据同步结束后建立文件系统: mkfs.ext4 /dev/drbd1 挂载文件系统: mount /dev/drbd1 /var/lib/mysql 而后在html里新的文件的都会保存 要在另外一台服务器同步 首先须要将server5上的/dev/drbd1 卸载 server5设置为secondary drbdadm secondary mysqldata server6上执行 drbdadm primary mysqldata drbdadm primary mysqldata mount /dev/drbd1 /var/lib/mysql 便可实现同步数据库操做
cs(connection state). Status of the network connection. See the section called “Connection states” for details about the various connection states.
ro(roles). Roles of the nodes. The role of the local node isdisplayed first, followed by the role of the partnernode shown after the slash. See the section called “Resource roles” for details about thepossible resource roles.
ds(disk states). State of the hard disks. Prior to the slash thestate of the local node is displayed, after the slashthe state of the hard disk of the partner node isshown. See the section called “Disk states” for details about the variousdisk states.
ns(network send). Volume of net data sent to the partner via thenetwork connection; in Kibyte.
nr(network receive). Volume of net data received by the partner viathe network connection; in Kibyte.
dw(disk write). Net data written on local hard disk; inKibyte.
dr(disk read). Net data read from local hard disk; in Kibyte.
al(activity log). Number of updates of the activity log area of the metadata.
bm(bit map). Number of updates of the bitmap area of the metadata.
lo(local count). Number of open requests to the local I/O sub-systemissued by DRBD.
pe(pending). Number of requests sent to the partner, but thathave not yet been answered by the latter.
ua(unacknowledged). Number of requests received by the partner via thenetwork connection, but that have not yet beenanswered.
ap(application pending). Number of block I/O requests forwarded to DRBD, butnot yet answered by DRBD.
ep(epochs). Number of epoch objects. Usually 1. Might increaseunder I/O load when using either thebarrier or the nonewriteordering method. Since 8.2.7.
wo(write order). Currently used write ordering method:b (barrier), f(flush),d(drain) or n(none). Since8.2.7.
oos(out of sync). Amount of storage currently out of sync; inKibibytes. Since 8.2.6.
StandAlone. No network configuration available. The resourcehas not yet been connected, or has beenadministratively disconnected (using drbdadm disconnect), or has dropped its connectiondue to failed authentication or split brain.
Disconnecting. Temporary state during disconnection. The nextstate is StandAlone.
Unconnected. Temporary state, prior to a connection attempt.Possible next states: WFConnection andWFReportParams.
Timeout. Temporary state following a timeout in thecommunication with the peer. Next state:Unconnected.
BrokenPipe. Temporary state after the connection to the peerwas lost. Next state: Unconnected.
NetworkFailure. Temporary state after the connection to thepartner was lost. Next state: Unconnected.
ProtocolError. Temporary state after the connection to thepartner was lost. Next state: Unconnected.
TearDown. Temporary state. The peer is closing theconnection. Next state: Unconnected.
WFConnection. This node is waiting until the peer node becomesvisible on the network.
WFReportParams. TCP connection has been established, this nodewaits for the first network packet from thepeer.
Connected. A DRBD connection has been established, datamirroring is now active. This is the normalstate.
StartingSyncS. Full synchronization, initiated by theadministrator, is just starting. The next possiblestates are: SyncSource or PausedSyncS.
StartingSyncT. Full synchronization, initiated by theadministrator, is just starting. Next state:WFSyncUUID.
WFBitMapS. Partial synchronization is just starting. Nextpossible states: SyncSource or PausedSyncS.
WFBitMapT. Partial synchronization is just starting. Nextpossible state: WFSyncUUID.
WFSyncUUID. Synchronization is about to begin. Next possiblestates: SyncTarget or PausedSyncT.
SyncSource. Synchronization is currently running, with thelocal node being the source ofsynchronization.
SyncTarget. Synchronization is currently running, with thelocal node being the target ofsynchronization.
PausedSyncS. The local node is the source of an ongoingsynchronization, but synchronization is currentlypaused. This may be due to a dependency on thecompletion of another synchronization process, ordue to synchronization having been manuallyinterrupted by drbdadm pause-sync.
PausedSyncT. The local node is the target of an ongoingsynchronization, but synchronization is currentlypaused. This may be due to a dependency on thecompletion of another synchronization process, ordue to synchronization having been manuallyinterrupted by drbdadm pause-sync.
VerifyS. On-line device verification is currently running,with the local node being the source ofverification.
VerifyT. On-line device verification is currently running,with the local node being the target ofverification.