歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> CentOS獨占激活卷組的方法

CentOS獨占激活卷組的方法

日期:2017/3/6 9:50:24   编辑:學習Linux

CentOS獨占激活卷組的方法


CentOS獨占激活卷組的方法


需求背景:需要在CentOS的雙機實現共享盤獨占激活,即共享盤只掛載在其中一台機器,另一個機器不能同時掛載,必要時候可進行手工切換掛載到另一台機器。

實現方法:依賴rhcs集群功能,利用vgchange -a e的方式獨占激活

一、環境准備


# cat /etc/redhat-release
CentOS release 6.6 (Final)

vim /etc/hosts

192.168.58.20 vm-test01
192.168.58.21 vm-test02


二、安裝集群

1、安裝rhcs集群相關軟件包

yum install -y cluster-glue resource-agents pacemaker
yum install -y luci ricci cman openais rgmanager lvm2-cluster gfs2-utils



2、 啟動集群服務


service luci start
service ricci start
service rgmanager start
service cman start


啟動cman如出現錯誤:
Starting cman… xmlconfig cannot find /etc/cluster/cluster.conf [FAILED] 是因為節點還沒有加入集群,沒有產生配置文件/etc/cluster/cluster.conf
可忽略


3、 設置集群服務自啟動


chkconfig luci on
chkconfig ricci on
chkconfig rgmanager on
chkconfig cman on




4、 修改ricci用戶密碼

使用 passwd ricci 命令將用戶 ricci 密碼設定為 root 的密碼


三、配置集群


ie登錄 https://192.168.58.20:8084


create cluster


四、用共享盤創建卷組
pvcreate /dev/sdb
vgcreate vgrhcs1 /dev/sdb
lvcreate -L 20m -n lvtest1 vgrhcs1
mkfs.ext3 /dev/vgrhcs1/lvtest1
mkdir /rhcs1


在另一個節點同步卷組信息
pvscan
vgscan
vgchange -a n vgrhcs1


在兩個節點均執行:
vim /etc/lvm/lvm.conf
locking_type = 3


在vg激活的節點,增加節點的cluster屬性,執行
vgchange -a n vgrhcs1
vgchange -c y vgrhcs1

五、獨占激活卷組

vgchange -a e vgrhcs1
mount /dev/vgrhcs1/lvtest1 /rhcs1 mount上以後才能保證在任何節點都不能去激活該vg


注:vgchange -a y vgxx 表示在所有節點激活卷組

vgchange -a n vgxx表示在所有節點去激活卷組

vgchange -a e vgxx 表示在一個節點獨占激活卷組

http://xxxxxx/Linuxjc/1134091.html TechArticle

Copyright © Linux教程網 All Rights Reserved