频道栏目
首页 > 资讯 > Linux > 正文

创建ocfs2集群和增加节点

17-05-20        来源:[db:作者]  
收藏   我要投稿

创建ocfs2集群和增加节点。创建ocfs2 cluster 首先,在所有节点上要有一个共享的块设备。 具体可以通过不同机制来实现。例如,通过把一个节点的块设备以iscsi的形式让其他节点挂载;或者在FC-SAN架构下,通过配置盘阵,让不同的节点看到同一个块设备。当然,具体映射的linux设备名可能是不同的,例如在一个节点上是/dev/sdc,在另一个节点上是/dev/sde。 下面一个已经装好的例子 [root@tncloud10 ~]# mounted.ocfs2 -f Device Stack Cluster F Nodes /dev/sde1 o2cb tncloud06, tncloud10

[root@tncloud06 ~]# mounted.ocfs2 -f Device Stack Cluster F Nodes /dev/sdc1 o2cb tncloud06, tncloud10

第二,linux内核要支持ocfs。例如 # lsmod|grep ocfs ocfs2_dlmfs 27704 1 ocfs2_stack_o2cb 13279 1 ocfs2_dlm 229980 1 ocfs2_stack_o2cb ocfs2 1079135 3 ocfs2_stackglue 17171 3 ocfs2,ocfs2_stack_o2cb,ocfs2_dlmfs ocfs2_nodemanager 237661 12 ocfs2,ocfs2_stack_o2cb,ocfs2_dlmfs,ocfs2_dlm jbd2 102940 1 ocfs2 OCFS2有自己的集群服务结构,叫做O2CB,它包括: NM:节点管理器,它对cluster.conf文件中所有节点进行的监控。 HB:心跳服务(Heart beat service),他在节点离开或加入rac时提示up和down的消息。 TCP:控制节点间的通讯。 DLM:分布式锁管理器,它持续跟踪所有的锁,锁的所有者及状态。 CONFIGFS:用户配置文件系统驱动空间,挂节点是/config DLMFS:用户空间和内核空间DLM的接口。

值得注意的是,尽管linux支持ocfs2,但常见的linux发行版内核可能并没有编译ocfs2模块。笔者自行在centos7上编译了支持ocfs2的内核。 # uname -a Linux tncloud10 3.10.0-327.28.2.el7.tn.1.x86_64 #1 SMP Thu Aug 11 14:48:56 CST 2016 x86_64 x86_64 x86_64 GNU/Linux # cat /boot/config-3.10.0-327.28.2.el7.x86_64 |grep OCFS2 CONFIG_OCFS2_FS=m CONFIG_OCFS2_FS_O2CB=m CONFIG_OCFS2_FS_USERSPACE_CLUSTER=m CONFIG_OCFS2_FS_STATS=y CONFIG_OCFS2_DEBUG_MASKLOG=y # CONFIG_OCFS2_DEBUG_FS is not set

第三,安装ocfs2-tools用户工具。 # rpm -qa|grep ocfs ocfs2-tools-1.8.4-1.12.el7.x86_64 主要提供了以下工具 格式化工具 mkfs.ocfs2 集群管理工具 o2cb_ctl /etc/rc.d/init.d/o2cb /etc/rc.d/init.d/ocfs2 等等。 例如,查看ocfs2文件系统属性。 # tunefs.ocfs2 -Q "UUID = %U\nNumSlots = %N\nBlock size = %B bytes\nCluster size = %T bytes\nRoot directory block number = %R\nSystem directory block number = %Y\nFirst cluster group block number = %P\nVolume label = %V\nCompat flags = %M\nIncompat flags = %H\nRO Compat flags = %O\n" /dev/sdc1 UUID = B8F7C05388CD4814BEDD4AE2A1C0A001 NumSlots = 8 Block size = 4096 bytes Cluster size = 65536 bytes Root directory block number = 33 System directory block number = 34 First cluster group block number = 16 Volume label = Compat flags = backup-super strict-journal-super Incompat flags = sparse extended-slotmap inline-data metaecc xattr indexed-dirs refcount discontig-bg RO Compat flags = unwritten usrquota grpquota

第四,确保节点之间网络互通。

第五,在各个节点上,创建和编辑一个文件 /etc/ocfs2/cluster.conf 举例如下 #start cluster: heartbeat_mode = local node_count = 2 name = tncloud

node: number = 0 cluster = tncloud ip_port = 7777 ip_address = 10.10.150.6 name = tncloud06

node: number = 1 cluster = tncloud ip_port = 7777 ip_address = 10.10.150.10 name = tncloud10 #end

第六,启动ocfs2 clsuter。 # /etc/init.d/o2cb load # /etc/init.d/o2cb online # /etc/init.d/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 "tncloud": Online Heartbeat dead threshold: 61 Network idle timeout: 30000 Network keepalive delay: 2000 Network reconnect delay: 2000 Heartbeat mode: Local Checking O2CB heartbeat: Active 如果提示Checking O2CB heartbeat: Not active,说明还没挂载共享磁盘。

第七,挂载共享磁盘。 找一个节点,只需执行一次。 # mkfs.ocfs2 -C 64K -T vmstore -N 8 -J block64 --fs-feature-level=max-features /dev/sde1 -F 然后,在所有节点上mount。 # mount -t ocfs2 /dev/sdc1 /mnt/tncloud 成功mount之后,例如 [root@tncloud06 ~]# mount|grep ocfs2 ocfs2_dlmfs on /dlm type ocfs2_dlmfs (rw,relatime) /dev/sdc1 on /mnt/tncloud type ocfs2 (rw,relatime,_netdev,heartbeat=local,nointr,data=ordered,errors=remount-ro,atime_quantum=60,coherency=full,user_xattr,acl) 至此创建工作完成。

第八,如果写入/etc/fstab,必须加上_netdev选项,指示必须在网络可用情况下再进行mount。例如 UUID="b8f7c053-88cd-4814-bedd-4ae2a1c0a001" /mnt/tncloud ocfs2 _netdev,defaults 0 0

参考 http://www.cnblogs.com/shanno/p/3982195.html http://www.cnblogs.com/zhangpengme/archive/2011/12/29/2306362.html

增加ocfs2节点 第一,检查numslots是否满足增加节点的需求。确保cluster在线,执行 # tunefs.ocfs2 -Q "NumSlots = %N\n" /dev/sde1 NumSlots = 8 如果需要修改, # tunefs.ocfs2 -N device

增加节点分为两种情况,在线增加和离线增加。

在线增加新的ocfs2节点 使用o2cb_ctl 工具,在每个节点上执行: # o2cb_ctl -C -i -n NODENAME -t node -a number=NODENUM -a ip_address=IPADDR -a ip_port=IPPORT -a cluster=CLUSTERNAME man手册的例子 Add node10 to an online cluster: $ o2cb_ctl -C -i -n node10 -t node -a number=10 -a ip_address=192.168.1.10 -a ip_port=7777 -a cluster=mycluster 参数说明 -C Create an object in the OCFS2 Cluster Configuration。

表示创建一个新的对象。 -i Valid only with -C. When creating something (node or cluster), it will also install it in the live cluster. If the parameter is not specified, then only update the /etc/ocfs2/cluster.conf. 意思是不但更新cluster.conf,也同时更新clutser相关进程的内存数据。 -n object object is usually the node name or cluster name. In the /etc/ocfs2/cluster.conf file, it would be the value of the name parameter for any of the sections (cluster or node). 对于添加新的节点,-n参数是代表 node name。

-t type type can be cluster, node or heartbeat. 对于添加index节点,-t参数是node。 -a With -C, is in format "parameter=value", where the parameter is a valid parameter that can be set in the file /etc/ocfs2/cluster.conf. 指明各个属性值,例如ip_address=1.2.3.4。

离线cluster环境中增加新的节点 可以使用console,或者直接手动修改cluster.conf文件,然后通过console或者直接拷贝cluster.conf文件到所有的节点。 也可以使用o2cb_ctl,例如 # o2cb_ctl -C -n NODENAME -t node -a number=NODENUM -a ip_address=IPADDR -a ip_port=IPPORT -a cluster=CLUSTERNAME 离线环境不需要加参数“-i”。

相关TAG标签
上一篇:jQuery选择器之基本筛选选择器
下一篇:IntellijIdea创建Web项目入门(一)
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站