How to activate a volume group exclusively on CentOS
Requirement Background: The shared disk must be activated exclusively on the CentOS dual-host. That is, the shared disk is only attached to one machine, and the other machine cannot be mounted at the same time, if necessary, you can manually switch and mount to another machine.
Implementation Method: relying on the rhcs cluster function, vgchange-a e is used for exclusive activation.
I. Environment preparation
# Cat/etc/redhat-release
CentOS release 6.6 (Final)
Vim/etc/hosts
192.168.58.20 vm-test01
192.168.58.21 vm-test02
Ii. Install the Cluster
1. Install software packages related to the rhcs Cluster
Yum install-y cluster-glue resource-agents pacemaker
Yum install-y luci ricci cman openais rgmanager lvm2-cluster gfs2-utils
2. Start the cluster service
Service luci start
Service ricci start
Service rgmanager start
Service cman start
If an error occurs when starting cman:
Starting cman... Xmlconfig cannot find/etc/cluster. conf [FAILED] is because the node has not been added to the cluster and no configuration file/etc/cluster. conf is generated.
Negligible
3. Set the cluster service to start automatically
Chkconfig luci on
Chkconfig ricci on
Chkconfig rgmanager on
Chkconfig cman on
4. Modify the ricci User Password
Use the passwd ricci command to set your ricci password to the root password.
3. Configure the Cluster
Ie log on to https: // 192.168.58.20: 8084
Create cluster
4. Create a volume group with a shared Disk
Pvcreate/dev/sdb
Vgcreate vgrhcs1/dev/sdb
Lvcreate-L 20 m-n lvtest1 vgrhcs1
Mkfs. ext3/dev/vgrhcs1/lvtest1
Mkdir/rhcs1
Synchronize volume group information on another node
Pvscan
Vgscan
Vgchange-a n vgrhcs1
Run the following command on both nodes:
Vim/etc/lvm. conf
Locking_type = 3
Add the cluster attribute of the node to the node activated by vg and run
Vgchange-a n vgrhcs1
Vgchange-c y vgrhcs1
5. Exclusively activate a volume group
Vgchange-a e vgrhcs1
Mount/dev/vgrhcs1/lvtest1/rhcs1 mount to ensure that the vg cannot be activated on any node.
Note: vgchange-a y vgxx indicates that the volume group is activated on all nodes.
Vgchange-a n vgxx indicates that the volume group is activated on all nodes.
Vgchange-a e vgxx indicates that the volume group is activated exclusively on a node.