吴猥琐是傻逼

OCFS2-O2CB服务

安装ocfs2-tools

# yum install ocfs2-tools

load并online O2CB服务

# service o2cb load
Loading filesystem "configfs": OK
Mounting configfs filesystem at /sys/kernel/config: OK
Loading stack plugin "o2cb": OK
Loading filesystem "ocfs2_dlmfs": OK
Creating directory '/dlm': OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK
# service o2cb online
Setting cluster stack "o2cb": OK
Checking O2CB cluster configuration : Failed

注意:当我们online o2cb服务时,会在检查o2cb集群配置处失败。解决方法:创建ocfs2集群配置

创建ocfs2集群配置

现在需要创建 /etc/ocfs2/cluster.conf 文件。使用 o2cb_ctl 命令可以更容易地完成这项工作。

# o2cb_ctl -C -n mycluster -t cluster -a name=mycluster

此处将集群命名为mycluster,在我们为集群添加节点前,集群不会知道关于节点的任何事情。接下来对集群添加节点。

向ocfs2集群配置添加节点

使用下面的命令来创建了两个节点。需要节点的IP,端口号,之前定义的集群名称以及节点的主机名

# o2cb_ctl -C -n hostname01 -t node -a number=0 -a ip_address=172.10.10.1 -a ip_port=11111 -a cluster=mycluster
# o2cb_ctl -C -n hostname02 -t node -a number=1 -a ip_address=172.10.10.2 -a ip_port=11111 -a cluster=mycluster

IP地址和端口号用来作为集群的心跳线,节点名用来在加入集群时验证集群成员,节点名需要匹配系统主机名

查看验证ocfs2集群配置

# cat /etc/ocfs2/cluster.conf
node:
name = hostname01
cluster = mycluster
number = 0
ip_address = 172.10.10.1
ip_port = 11111

node:
name = hostname02
cluster = mycluster
number = 1
ip_address = 172.10.10.2
ip_port = 11111

cluster:
name = mycluster
heartbeat_mode = local
node_count = 2
			
		

配置o2cb服务

# service o2cb configure
Configuring the O2CB driver.

This will configure the on-boot properties of the O2CB driver.
The following questions will determine whether the driver is loaded on
boot.  The current values will be shown in brackets ('[]').  Hitting
 without typing an answer will keep that current value.  Ctrl-C
will abort.

Load O2CB driver on boot (y/n) [n]: y
Cluster stack backing O2CB [o2cb]:
Cluster to start on boot (Enter "none" to clear) [ocfs2]: mycluster
Specify heartbeat dead threshold (>=7) [31]:
Specify network idle timeout in ms (>=5000) [30000]:
Specify network keepalive delay in ms (>=1000) [2000]:
Specify network reconnect delay in ms (>=2000) [2000]:
Writing O2CB configuration: OK
Setting cluster stack "o2cb": OK
Registering O2CB cluster "mycluster": OK
Setting O2CB cluster timeouts : OK

offline和online o2cb 服务

# service o2cb offline
Clean userdlm domains: OK
Stopping O2CB cluster prdcluster: Unregistering O2CB cluster "mycluster": OK
# service o2cb online
Setting cluster stack "o2cb": OK
Registering O2CB cluster "mycluster": OK
Setting O2CB cluster timeouts : OK

在所有节点重复以上操作!!!

注意:上述的所有操作必须毫无变化地在集群的所有节点上完成!在所有节点上都是 Registering O2CB cluster "mycluster":OK 的话,那么就可以往下继续了。

格式化共享磁盘

只需要在集群的其中一个节点上完成格式化即可,不必在其他的节点上再执行一次了

# mkfs.ocfs2 /dev/xvdb
mkfs.ocfs2 1.8.0
Cluster stack: classic o2cb
Label:
Features: sparse extended-slotmap backup-super unwritten inline-data strict-journal-super xattr indexed-dirs refcount discontig-bg
Block size: 4096 (12 bits)
Cluster size: 4096 (12 bits)
Volume size: 53687091200 (13107200 clusters) (13107200 blocks)
Cluster groups: 407 (tail covers 11264 clusters, rest cover 32256 clusters)
Extent allocator size: 8388608 (2 groups)
Journal size: 268435456
Node slots: 8
Creating bitmaps: done
Initializing superblock: done
Writing system files: done
Writing superblock: done
Writing backup superblock: 3 block(s)
Formatting Journals: done
Growing extent allocator: done
Formatting slot map: done
Formatting quota files: done
Writing lost+found: done
mkfs.ocfs2 successful

挂载ocfs2卷

# mount -t ocfs2 /dev/xvdb /d01/share

设置开机自动挂载

# cat /etc/fstab

#
 # /etc/fstab
 # Created by anaconda on Wed Feb 27 13:44:01 2013
 #
 # Accessible filesystems, by reference, are maintained under '/dev/disk'
 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
 #
 /dev/mapper/vg_system-lv_root /                       ext4    defaults        1 1
 UUID=4b397e61-7954-40e9-943f-8385e46d263d /boot                   ext4    defaults        1 2
 /dev/mapper/vg_system-lv_swap swap                    swap    defaults        0 0
 tmpfs                   /dev/shm                tmpfs   defaults        0 0
 devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
 sysfs                   /sys                    sysfs   defaults        0 0
 proc                    /proc                   proc    defaults        0 0
 /dev/xvdb        /d01/share        ocfs2    defaults    1 1

!!!mount操作需要在所有的节点上配置!!!

检查mount状态

# mount
 /dev/mapper/vg_system-lv_root on / type ext4 (rw)
 proc on /proc type proc (rw)
 sysfs on /sys type sysfs (rw)
 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
 tmpfs on /dev/shm type tmpfs (rw)
 /dev/xvda1 on /boot type ext4 (rw)
 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
 sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
 configfs on /sys/kernel/config type configfs (rw)
 ocfs2_dlmfs on /dlm type ocfs2_dlmfs (rw)
 /dev/xvdb on /d01/share type ocfs2 (rw,_netdev,heartbeat=local)

检查o2cb服务状态

最后检查o2cb服务,查看相关信息

# service o2cb status
 Driver for "configfs": Loaded
 Filesystem "configfs": Mounted
 Stack glue driver: Loaded
 Stack plugin "o2cb": Loaded
 Driver for "ocfs2_dlmfs": Loaded
 Filesystem "ocfs2_dlmfs": Mounted
 Checking O2CB cluster "prdcluster": Online
 Heartbeat dead threshold: 31
 Network idle timeout: 30000
 Network keepalive delay: 2000
 Network reconnect delay: 2000
 Heartbeat mode: Local
 Checking O2CB heartbeat: Active