MySQL DRBD資料同步

來源:互聯網
上載者:User
文章目錄
  • 一、軟體包
一、軟體包

a) drbd-8.3.2.tar.gz(主備)

b) mysql-5.0.27.tar.gz(主備)

二、安裝步驟

a) Cd /var/local/software

b) Tar zxvf drbd-8.3.2.tar.gz

c) Cd drbd-8.3.2

d) Make

e) Make install

f) Insmod drbd/drbd.ko

g) Lsmod |grep drbd

h) Vi /etc/hosts

59.64.28.22 vm1

59.64.28.57 vm2

j) vi /etc/drbd.conf

global { usage-count yes; }

common { syncer { rate 10M; } }

resource r0 {

protocol C;

startup {

degr-wfc-timeout 120;

}

#disk {

# on-io-error detach;

#}

net {

cram-hmac-alg sha1;

shared-secret "FooFunFactory";

}

#syncer {

# rate 10M;

# al-extents 257;

#}

on vm1 {

device /dev/drbd0;

disk /dev/sda3;

address 59.64.28.22:7788;

meta-disk internal;

}

on vm2 {

device /dev/drbd0;

disk /dev/sda3;

address 59.64.28.57:7788;

meta-disk internal;

}

}

k) mkfs.ext3 /dev/sda3

l) dd if=/dev/zero of=/dev/sda3 bs=1M count=1

m) drbdadm create-md r0(主上執行)

n) /etc/init.d/drbd start

o) drbdsetup /dev/drbd0 primary –o

p) drbdadm primary r0

q) drbdadm secondary r0

r) mkdir /mnt/drdb

s) mount /dev/drbd0 /mnt/drbd

t) 注:備機DRBD裝置無法被掛載

u) 安裝MYSQL配置如下

./configure \

--prefix=/usr/local/mysql \

--localstatedir=/mnt/drbd/ \

--disable-maintainer-mode \

--with-mysqld-user=mysql \

--with-unix-socket-path=/tmp/mysql.sock \

--without-comment \

--without-debug \

--with-bench \

--with-mysqld-ldflags=-all-static \

--with-client-ldflags=-all-static

三、主備切換

a) service mysql stop

b) umount /dev/drb0;

c) /etc/init.d/drbd stop

d) drbdadm primary r0

e) mount /dev/drbd0 /mnt/drbd

f) drbdadm secondary r0

四、相關命令

a) /etc/init.d/drbd status //查看主同步情況

drbd driver loaded OK; device status:

version: 8.3.2 (api:88/proto:86-90)

GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by root@localhost.localdomain, 2010-11-24 19:22:37

m:res cs ro ds p mounted fstype

0:r0 Connected Primary/Secondary UpToDate/UpToDate C /mnt/drbd ext3

b) /etc/init.d/drbd status //查看備同步情況

drbd driver loaded OK; device status:

version: 8.3.2 (api:88/proto:86-90)

GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by root@localhost.localdomain, 2010-08-14 14:56:54

m:res cs ro ds p mounted fstype

0:r0 Connected Secondary/Primary UpToDate/UpToDate C

c) /etc/init.d/drbd start/stop/status

d) cat /proc/drbd

e) drbdsetup /dev/drbd1 primary –o

f) drbdadm create-md r0

g) dd if=/dev/zero of=/dev/sda2 bs=1M count=1

h) drbdadm secondary r0 

i) drbdadm primary r0

j) umount /dev/drbd0

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.