스토리지 이중화 다른 서버와 동기화 되어 한쪽 디스크가 죽으면 다른쪽 서버 살려서 사용
<server 1>
[root@server1 ~]# cat /etc/hosts
192.168.10.200 server1.example.com
192.168.10.252 server2.example.com
[root@server1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 2G 0 part /boot
├─sda2 8:2 0 50G 0 part /var
├─sda3 8:3 0 5G 0 part /home
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 4G 0 part [SWAP]
└─sda6 8:6 0 39G 0 part /
sdb 8:16 0 2G 0 disk
└─sdb1 8:17 0 2G 0 part
sr0 11:0 1 1024M 0 rom
[root@server1 temp]# dnf -y install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
[root@server1 temp]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@server1 temp]# dnf search drbd
[root@server1 temp]# dnf -y install drbd90-utils kmod-drbd90
[root@server1 temp]# dnf -y install policycoreutils-python-utils-2.9-9.el8.noarch
[root@server1 temp]# semanage permissive -a drbd_t
[root@server1 temp]# semanage permissive -l | grep drbd_t
drbd_t [root@server1 temp]# semanage permissive -l
Builtin Permissive Types
Customized Permissive Types
drbd_t
[root@server1 temp]# firewall-cmd --permanent --zone=public --add-port=6996-7800/tcp
[root@server1 temp]# firewall-cmd --reload
[root@server1 temp]# firewall-cmd --list-all
[root@server1 temp]# cd /etc/drbd.d/
[root@server1 drbd.d]# mv global_common.conf global_common.backup
global {
usage-count yes;
}
common {
net {
protocol C;
}
}
[root@server1 drbd0]# cat /etc/drbd.d/dr0.res
resource dr0 {
on server1.example.com {
device /dev/drbd0;
disk /dev/sdb1;
meta-disk internal;
address 192.168.10.200:7789;
}
on server2.example.com {
device /dev/drbd0;
disk /dev/sdb1;
meta-disk internal;
address 192.168.10.252:7789;
}
}
[root@server1 drbd.d]# cat /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";
[root@server1 drbd.d]# drbdadm create-md dr0
initializing activity log
initializing bitmap (64 KB) to all zero
Writing meta data...
New drbd meta data block successfully created.
[root@server1 drbd.d]# systemctl start drbd
[root@server1 drbd.d]# systemctl enable drbd
[root@server1 drbd.d]# systemctl status drbd
[root@server1 drbd.d]# drbdadm primary --force dr0
--== Thank you for participating in the global usage survey ==--
The server's response is:
you are the 441th user to install this version
[root@server1 drbd.d]# drbdadm status dr0
dr0 role:Primary
disk:UpToDate
server2.example.com role:Secondary
peer-disk:UpToDate
[root@server1 drbd.d]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 2G 0 part /boot
├─sda2 8:2 0 50G 0 part /var
├─sda3 8:3 0 5G 0 part /home
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 4G 0 part [SWAP]
└─sda6 8:6 0 39G 0 part /
sdb 8:16 0 2G 0 disk
└─sdb1 8:17 0 2G 0 part
└─drbd0 147:0 0 2G 0 disk
sr0 11:0 1 1024M 0 rom
[root@server1 drbd.d]# cat /proc/drbd
version: 9.0.25-2 (api:2/proto:86-117)
GIT-hash: 0c392d83236898cce84cf8829235551173d5c1b9 build by akemi@Build64R8, 2020-11-08 02:16:35
Transports (api:16): tcp (9.0.25-2)
[root@server1 drbd.d]# mkfs.xfs /dev/drbd0 //primary 서버에서만 해줌
meta-data=/dev/drbd0 isize=512 agcount=4, agsize=131002 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=524007, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@server1 drbd.d]# mkdir /drbd0
[root@server1 drbd.d]# mount /dev/drbd0 /drbd0
[root@server1 drbd.d]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 957M 0 957M 0% /dev
tmpfs tmpfs 975M 0 975M 0% /dev/shm
tmpfs tmpfs 975M 8.8M 967M 1% /run
tmpfs tmpfs 975M 0 975M 0% /sys/fs/cgroup
/dev/sda6 xfs 39G 1.7G 38G 5% /
/dev/sda2 xfs 50G 593M 50G 2% /var
/dev/sda3 xfs 5.0G 68M 5.0G 2% /home
/dev/sda1 xfs 2.0G 176M 1.9G 9% /boot
tmpfs tmpfs 195M 0 195M 0% /run/user/0
/dev/drbd0 xfs 2.0G 47M 2.0G 3% /drbd0
##################################################
< server2 >
[root@server2 ~]# cat /etc/hosts
192.168.10.200 server1.example.com
192.168.10.252 server2.example.com
[root@server2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 2G 0 part /boot
├─sda2 8:2 0 50G 0 part /var
├─sda3 8:3 0 5G 0 part /home
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 4G 0 part [SWAP]
└─sda6 8:6 0 39G 0 part /
sdb 8:16 0 2G 0 disk
└─sdb1 8:17 0 2G 0 part
sr0 11:0 1 1024M 0 rom
[root@server2 temp]# dnf -y install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
[root@server2 temp]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@server2 temp]# dnf search drbd
[root@server2 temp]# dnf -y install drbd90-utils kmod-drbd90
[root@server2 temp]# dnf -y install policycoreutils-python-utils-2.9-9.el8.noarch
[root@server2 temp]# semanage permissive -a drbd_t
[root@server2 temp]# firewall-cmd --permanent --add-port=6996-7800/tcp
[root@server2 temp]# firewall-cmd --reload
[root@server2 temp]# firewall-cmd --list-all
[root@server2 temp]# mv /etc/drbd.d/global_common.conf /etc/drbd.d/global_common.backup
[root@server2 temp]# vi /etc/drbd.d/global_common.conf
global {
usage-count yes;
}
common {
net {
protocol C;
}
}
[root@server2 drbd.d]# vi dr0.res
resource dr0 {
on server1.example.com {
device /dev/drbd0;
disk /dev/sdb1;
meta-disk internal;
address 192.168.10.200:7789;
}
on server2.example.com {
device /dev/drbd0;
disk /dev/sdb1;
meta-disk internal;
address 192.168.10.252:7789;
}
}
[root@server2 drbd.d]# drbdadm create-md dr0
initializing activity log
initializing bitmap (64 KB) to all zero
Writing meta data...
New drbd meta data block successfully created.
[root@server2 drbd.d]# systemctl start drbd
[root@server2 drbd.d]# systemctl enable drbd
[root@server2 drbd.d]# systemctl status drbd
[root@server2 drbd.d]# drbdadm status dr0
--== Thank you for participating in the global usage survey ==--
The server's response is:
you are the 442th user to install this version
dr0 role:Secondary
disk:UpToDate
server1.example.com role:Secondary
peer-disk:UpToDate
[root@server2 drbd.d]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 2G 0 part /boot
├─sda2 8:2 0 50G 0 part /var
├─sda3 8:3 0 5G 0 part /home
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 4G 0 part [SWAP]
└─sda6 8:6 0 39G 0 part /
sdb 8:16 0 2G 0 disk
└─sdb1 8:17 0 2G 0 part
└─drbd0 147:0 0 2G 0 disk
sr0 11:0 1 1024M 0 rom
[root@server2 drbd.d]# mkdir /drbd0
##############################################3
<test>
server1 에서...
[root@server1 drbd0]# touch file{1..10}
[root@server1 drbd0]# ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9
[root@server1 drbd0]#
[root@server1 /]# umount /drbd0
[root@server1 /]# drbdadm secondary dr0
[root@server1 /]# drbdadm status
dr0 role:Secondary
disk:UpToDate
server2.example.com role:Secondary
peer-disk:UpToDate
server2 에서...
[root@server2 drbd.d]# drbdadm status
dr0 role:Secondary
disk:UpToDate
server1.example.com role:Primary
peer-disk:UpToDate
[root@server2 drbd.d]# drbdadm primary dr0
[root@server2 drbd.d]# drbdadm status
dr0 role:Primary
disk:UpToDate
server1.example.com role:Secondary
peer-disk:UpToDate
[root@server2 drbd.d]# mount /dev/drbd0 /drbd0
[root@server2 drbd.d]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 957M 0 957M 0% /dev
tmpfs tmpfs 975M 0 975M 0% /dev/shm
tmpfs tmpfs 975M 8.7M 967M 1% /run
tmpfs tmpfs 975M 0 975M 0% /sys/fs/cgroup
/dev/sda6 xfs 39G 1.7G 38G 5% /
/dev/sda2 xfs 50G 594M 50G 2% /var
/dev/sda3 xfs 5.0G 68M 5.0G 2% /home
/dev/sda1 xfs 2.0G 176M 1.9G 9% /boot
tmpfs tmpfs 195M 0 195M 0% /run/user/0
/dev/drbd0 xfs 2.0G 47M 2.0G 3% /drbd0
[root@server2 drbd.d]# cd /drbd0
[root@server2 drbd0]# ls -als
total 0
0 drwxr-xr-x. 2 root root 137 Jan 3 10:27 .
0 dr-xr-xr-x. 19 root root 249 Jan 3 10:16 ..
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file1
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file10
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file2
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file3
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file4
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file5
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file6
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file7
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file8
0 -rw-r--r--. 1 root root 0 Jan 3 10:27 file9
[root@server2 drbd0]#
'linux' 카테고리의 다른 글
centos 8 - gluster (0) | 2021.01.06 |
---|---|
centos 8 - pacemaker + iscsi + gfs2 shared storage 이중화 (0) | 2021.01.05 |
centos 8 - pacemaker (0) | 2021.01.03 |
centos - keepalived (링크 이중화 vrrp) (0) | 2021.01.03 |
centos - multipath + iscsi 설정 (0) | 2021.01.02 |