您好,登錄后才能下訂單哦!
小編給大家分享一下keepalived+ceph rbd如何配置nfs的高可用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
試驗(yàn)機(jī)器為ceph中的osd1和osd2主機(jī),ip分別為192.168.32.3、192.168.32.4,vip為192.168.32.5。
先創(chuàng)建一個(gè)rbd塊設(shè)備,然后在兩臺(tái)機(jī)器上導(dǎo)出此相同的塊:
[root@osd1 keepalived]# rbd ls test test.img [root@osd1 keepalived]# rbd showmapped id pool image snap device 0 test test.img - /dev/rbd0 [root@osd2 keepalived]# rbd showmapped id pool image snap device 0 test test.img - /dev/rbd0
然后將/dev/rbd0格式化后進(jìn)行掛載,如/mnt目錄。
從http://www.keepalived.org/download.html下載最新的keepalived 1.2.15版本,安裝比較簡(jiǎn)單,直接按照INSTALL的說(shuō)明進(jìn)行默認(rèn)安裝即可。為了方便管理keepalived服務(wù),需進(jìn)行以下操作:
cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/ mkdir /etc/keepalived cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ cp /usr/local/sbin/keepalived /usr/sbin/ chkconfig --add keepalived chkconfig keepalived on chkconfig --list keepalived
配置/etc/keepalived.conf。osd1的配置如下:
[root@osd1 keepalived]# cat keepalived.conf global_defs { notification_email { } router_id osd1 } vrrp_instance VI_1 { state MASTER interface em1 virtual_router_id 100 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.32.5/24 } }
osd2的配置如下:
[root@osd2 keepalived]# cat keepalived.conf global_defs { notification_email { # admin@example.com } #notification_email_from admin@example.com #smtp_server 127.0.0.1 #stmp_connect_timeout 30 router_id osd2 } vrrp_instance VI_1 { state BACKUP interface em1 virtual_router_id 100 priority 99 advert_int 1 authentication { auth_type PASS auth_pass 1111 } notify_master "/etc/keepalived/ChangeToMaster.sh" notify_backup "/etc/keepalived/ChangeToBackup.sh" virtual_ipaddress { 192.168.32.5/24 } }
在osd2寫(xiě)了兩個(gè)控制腳本,用于osd2的keepalived狀態(tài)改變時(shí)執(zhí)行。ChangeToMaster.sh:
[root@osd2 keepalived]# cat ChangeToMaster.sh #!/bin/bash service nfs start ssh lm "umount -f /mnt" ssh lm "mount -t nfs 192.168.32.5:/mnt /mnt"
ChangeToBackup.sh:
[root@osd2 keepalived]# cat ChangeToBackup.sh #!/bin/bash ssh lm "umount -f /mnt" ssh osd1 "service nfs stop" ssh osd1 "umount /mnt" ssh osd1 "rbd unmap /dev/rbd0" ssh osd1 "rbd map test/test.img" ssh osd1 "mount /dev/rbd0 /mnt" ssh osd1 "service nfs start" ssh lm "mount -t nfs 192.168.32.5:/mnt /mnt" service nfs stop umount /mnt rbd unmap /dev/rbd0 rbd map test/test.img mount /dev/rbd0
在ceph的一個(gè)節(jié)點(diǎn)利用rbd map一個(gè)塊設(shè)備,然后格式化并掛載在一個(gè)目錄,如/mnt。在此節(jié)點(diǎn)上安裝nfs的rpm包:
yum -y install nfs-utils
設(shè)置掛載目錄:
cat /etc/exports /mnt 192.168.101.157(rw,async,no_subtree_check,no_root_squash) /mnt 192.168.108.4(rw,async,no_subtree_check,no_root_squash)
啟動(dòng)并導(dǎo)出:
service nfs start chkconfig nfs on exportfs -r
客戶端查看一下:
showmount -e mon0 Export list for mon0: /mnt 192.168.108.4,192.168.101.157
然后掛載:
mount -t nfs mon0:/mnt /mnt
需要注意的是,NFS默認(rèn)是用UDP協(xié)議,如果網(wǎng)絡(luò)不穩(wěn)定,換成TCP協(xié)議即可:
mount -t nfs mon0:/mnt /mnt -o proto=tcp -o nolock
關(guān)閉osd1的網(wǎng)卡em1查看結(jié)果:
[root@osd1 keepalived]# ifdown em1 [root@osd1 keepalived]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: em1: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen 1000 link/ether c8:1f:66:de:5e:65 brd ff:ff:ff:ff:ff:ff
查看osd2的網(wǎng)卡:
[root@osd2 keepalived]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether c8:1f:66:f7:61:5d brd ff:ff:ff:ff:ff:ff inet 192.168.32.4/24 brd 192.168.32.255 scope global em1 valid_lft forever preferred_lft forever inet 192.168.32.5/24 scope global secondary em1 valid_lft forever preferred_lft forever inet6 fe80::ca1f:66ff:fef7:615d/64 scope link valid_lft forever preferred_lft forever
vip已經(jīng)漂移到osd2,查看客戶端掛載情況:
[root@lm /]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext4 454G 79G 353G 19% / tmpfs tmpfs 1.7G 4.6M 1.7G 1% /dev/shm 192.168.32.5:/mnt nfs 100G 21G 80G 21% /mnt
打開(kāi)osd1的網(wǎng)卡em1:
[root@osd1 keepalived]# ifup em1 Determining if ip address 192.168.32.3 is already in use for device em1... [root@osd1 keepalived]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether c8:1f:66:de:5e:65 brd ff:ff:ff:ff:ff:ff inet 192.168.32.3/24 brd 192.168.32.255 scope global em1 valid_lft forever preferred_lft forever inet 192.168.32.5/24 scope global secondary em1 valid_lft forever preferred_lft forever inet6 fe80::ca1f:66ff:fede:5e65/64 scope link valid_lft forever preferred_lft forever
osd2的em1:
[root@osd2 keepalived]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether c8:1f:66:f7:61:5d brd ff:ff:ff:ff:ff:ff inet 192.168.32.4/24 brd 192.168.32.255 scope global em1 valid_lft forever preferred_lft forever inet6 fe80::ca1f:66ff:fef7:615d/64 scope link valid_lft forever preferred_lft forever
現(xiàn)在的客戶端:
[root@lm /]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext4 454G 79G 353G 19% / tmpfs tmpfs 1.7G 4.6M 1.7G 1% /dev/shm 192.168.32.5:/mnt nfs 100G 21G 80G 21% /mnt [root@lm /]# ls /mnt 31.txt a.txt b.txt c.txt etc linux-3.17.4 linux-3.17.4.tar m2.txt test.img test.img2
也可以為ceph rbd的iscsi配置vip。
以上是“keepalived+ceph rbd如何配置nfs的高可用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。