主機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.