https://www.globo.tech/learning-center/setup-drbd-9-ubuntu-16/
CONDICIÓ D'INICI
2 maquines debian8
1 disc /dev/sdb1 secundari per montar el drbd
afegir als dos servidors el reconeixement per nom
root@drbd1:~# more /etc/hosts
127.0.0.1 localhost
# 127.0.1.1 drbd1.ies-sabadell.cat drbd1
192.168.0.180 drbd0.ies.cat drbd0
192.168.0.181 drbd1.ies.cat drbd1
INSTAL·LAR
apt-get update
sudo apt-get install -y drbd8-utils
sudo apt-get install -y drbd8-utils
ACONSEGUIR LA SINCRONITZACIÓ DE TEMPS
apt-get install -y ntp
creació d'una partició del mateix tamany a les dos màquines
fdisk /dev/sdb
n nova partició
p primaria
w write canvis
dd if=/dev/zero of=/dev/sdb1
als dos servidors també creem el recurs r0 associat a la partició creada i tot al fitxer /etc/drbd.conf
root@drbd1:~# more /etc/drbd.conf
# You can find an example in /usr/share/doc/drbd.../drbd.conf.example
# include "drbd.d/global_common.conf";
# include "drbd.d/*.res";
global { usage-count no; }
common { protocol C; }
resource r0 {
on drbd1 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.0.181:7788;
meta-disk internal;
}
on drbd0 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.0.180:7788;
meta-disk internal;
}
}
carregar el modul
modprobe drbd
crear el dispositiu mirror
drbdadm create-md r0
Then simply bring the mirror device online with this command.
drbdadm up r0
Per veure l'estat del drbd
drbd-overview cat /etc/drbd
els dos nodes son inicialment secundaris o pasius. Forçar un d'ells a ser primary
drbdadm -- --overwrite-data-of-peer primary r0/0
Finalment formatejar i montar la unitat de disc
sudo mkfs.ext4 /dev/drbd0
sudo mkdir -p /var/www/html
sudo mount /dev/drbd0 /var/www/html
In order to upgrade, do the following:
apt install software-properties-common
then
sudo add-apt-repository ppa:linbit/linbit-drbd9-stack
Finally, perform apt-get update so that Debian will recognize the updated repository. After that, you can run the apt-get upgrade to upgrade DRBD to version 9.
apt-get update
apt-get upgrade
No he aconseguir passar a la versió 9, no em troba drbd per la debian
aquest és l'error
W: No s'ha pogut obtenir http://ppa.launchpad.net/linbit/linbit-drbd9-stack/ubuntu/dists/jessie/main/binary-amd64/Packages 404 Not Found
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
ns:0 nr:851152 dw:34403500 dr:0 al:0 bm:286 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
SI PARO ARA drbd0
root@drbd1:~# drbd-overview cat /etc/drbd
0:r0/0 WFConnection Secondary/Unknown UpToDate/DUnknown
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
0: cs:WFConnection ro:Secondary/Unknown ds:UpToDate/DUnknown C r-----
ns:0 nr:851152 dw:34403500 dr:0 al:0 bm:286 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
SI TORNO A ENCENDRE drbd0
els dos en secundary fins que sincronitzi
root@drbd1:~# drbd-overview cat /etc/drbd
0:r0/0 SyncTarget Secondary/Secondary Inconsistent/UpToDate
[>....................] sync'ed: 0.1% (4944/4944)Mfinish: 0:52:44 speed: 1,260 (1,260) want: 1,360 K/sec
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
0: cs:SyncTarget ro:Secondary/Secondary ds:Inconsistent/UpToDate C r-----
ns:0 nr:857404 dw:34409752 dr:0 al:0 bm:286 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:5058416
[>....................] sync'ed: 0.3% (4936/4944)Mfinish: 0:39:31 speed: 2,084 (2,084) want: 3,040 K/sec
root@drbd1:~#
continua
root@drbd1:~# drbd-overview cat /etc/drbd
0:r0/0 SyncTarget Secondary/Secondary Inconsistent/UpToDate
[============>.......] sync'ed: 65.9% (1688/4944)Mfinish: 0:00:49 speed: 34,856 (25,460) want: 36,920 K/sec
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
0: cs:SyncTarget ro:Secondary/Secondary ds:Inconsistent/UpToDate C r-----
ns:0 nr:4262360 dw:37814708 dr:0 al:0 bm:511 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:1653460
[============>.......] sync'ed: 67.5% (1612/4944)Mfinish: 0:00:46 speed: 35,064 (25,648) want: 38,520 K/sec
se disparó consumo de red y uso de disco
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
ns:0 nr:5915820 dw:39468168 dr:0 al:0 bm:613 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
root@drbd1:~# drbd-overview cat /etc/drbd
0:r0/0 Connected Secondary/Secondary UpToDate/UpToDate
MISSATGES DEL SYSLOG
May 22 00:14:48 drbd1 kernel: [83618.112489] block drbd0: helper command: /sbin/drbdadm before-resync-target minor-0
May 22 00:14:48 drbd1 kernel: [83618.113577] block drbd0: helper command: /sbin/drbdadm before-resync-target minor-0 exit code 0 (0x0)
May 22 00:14:48 drbd1 kernel: [83618.113586] block drbd0: conn( WFSyncUUID -> SyncTarget ) disk( Outdated -> Inconsistent )
May 22 00:14:48 drbd1 kernel: [83618.113591] block drbd0: Began resync as SyncTarget (will sync 5064668 KB [1266167 bits set]).
May 22 00:17:01 drbd1 CRON[2464]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
May 22 00:17:49 drbd1 kernel: [83800.029781] block drbd0: Resync done (total 181 sec; paused 0 sec; 27980 K/sec)
May 22 00:17:49 drbd1 kernel: [83800.029787] block drbd0: updated UUIDs 716CEB055F69D08C:0000000000000000:82078DA323F1657E:82068DA323F1657F
May 22 00:17:49 drbd1 kernel: [83800.029792] block drbd0: conn( SyncTarget -> Connected ) disk( Inconsistent -> UpToDate )
May 22 00:17:49 drbd1 kernel: [83800.030037] block drbd0: helper command: /sbin/drbdadm after-resync-target minor-0
May 22 00:17:49 drbd1 kernel: [83800.031152] block drbd0: helper command: /sbin/drbdadm after-resync-target minor-0 exit code 0 (0x0)
FINALMENT HE TINGUT QUE FER
root@drbd0:~# mount /dev/drbd0 /var/www/html
mount: /dev/drbd0 is write-protected, mounting read-only
mount: mount /dev/drbd0 on /var/www/html failed: El tipus de mitjà no és và lid
root@drbd0:~# drbdadm -- --overwrite-data-of-peer primary r0
POSAR DRBD0 COM A PRIMARY
root@drbd0:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:5064668 nr:0 dw:0 dr:5066084 al:0 bm:327 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
root@drbd0:~# mount /dev/drbd0 /var/www/html
ja ho puc montar , miro en drbd1
root@drbd1:/var# mount /dev/drbd0 /var/www/html
mount: /dev/drbd0 is write-protected, mounting read-only
mount: mount /dev/drbd0 on /var/www/html failed: El tipus de mitjà no és và lid
com es secondary, només de lectura.
EL SEGÜENT ARTICLE SERÀ , sobre el drbd montarem una ip flotant amb heartbeat
https://www.globo.tech/learning-center/high-availability-heartbeat-drbd-ubuntu-16/
Cap comentari:
Publica un comentari a l'entrada