OCFS2是oracle的SAN集群共享文件系统,全称是oracle cluster file system 2,为了在新封装的Fedora系统中增加ocfs2的支持,需要对内核进行重新编译。
背景
在实际的部署环境中,往往会由客户现场的设备,决定云平台的部署模式,目前主要在存储上遇到的问题就是如何利用用户环境中的SAN存储设备,并将SAN存储作为共享文件系统提供给虚拟机使用。目前所能选择的文件系统范围就十分狭窄了,使用的方式一般有三种:
- 将SAN磁盘挂载到服务器,作为本地盘使用
- 将SAN磁盘挂载到服务器,然后使用共享文件系统或分布式文件系统进行再次发布
- 使用集群共享文件系统直接使用SAN磁盘,作为共享磁盘使用
前两种都有一定的弊端,第一种会影响虚拟机的迁移和高可用能力,第二种情况如果使用共享文件系统例如NFS,会损失相当大的性能和造成单点故障。如果使用第二种的分布式文件系统再发布,也会造成性能的损失,并且目前分布式文件系统生产环境一般都是以3份的方式进行多份处理,实际的使用大小会变为原SAN文件系统的1/3。
综合以上弊端,我们选择使用集群共享文件系统,选择的余地就十分狭小,现有技术中,ocfs2是一种比较理想的选择。
安装
ocfs2在目前的内核版本中是默认关闭的,所以在想要使用ocfs2的情况下, 需要重新编译内核。
1 验证ocfs2是否已经安装
# modprobe ocfs2
modprobe: FATAL: Module ocfs2 not found in directory /lib/modules/5.7.6-201.fc32.x86_64
如果没有返回值,说明加载成功,我这里会报错说明内核中没有ocfs2的kmod
# lsmod |grep ocfs2 #
lsmod没有返回值,说明ocfs2的kmod没有加载
这种情况下就要开始编译内核进行支持了
2 下载kernel的源码包
先看一下当前的操作系统内核版本
[root@10 SPECS]# uname -a Linux 10.211.55.230 5.7.6-201.fc32.x86_64 #1 SMP Mon Jun 29 15:15:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
内核版本是5.7.6,进入到国内各大镜像站,可以下载到最新的kernel源码rpm包,以163的源为例:
http://mirrors.163.com/fedora/updates/32/Everything/SRPMS/Packages/k/
这个目录中是k开头的源码包
注: 如果这里的kernel版本比之前系统的版本高的话,也没有什么大问题,编译完成之后安装新的kernel相当于进行升级kernel,也没有什么大碍。
下载kernel-5.7.6-201.fc32.src.rpm, 放到fedora的目录下即可,这里示例是放在/root/目录下
3 构建编译环境
进入到root目录下,然后执行
rpm -ivh kernel-5.7.6-201.fc32.src.rpm
会发现在root目录下生成了一个rpmbuild的文件夹,这个就构建的环境
之后在安装编译时所需要的包:
yum install fedora-packager bison dwarves elfutils-devel flex m4 gcc make nss-tools openssl-devel perl-devel perl-generators pesign python3-devel
这里只是根据我的环境需要安装的包,在编译的开始阶段,如果有工具包遗失,系统会提示安装,我们再进行补充即可。编译环境就已经具备了。
4 更改kernel.spec配置文件
这里更改的原因其实主要是要将kernel的配置文件中的# CONFIG_OCFS2_FS is not set/
替换为CONFIG_OCFS2_FS=m
由于kernel的配置文件有很多,包括对不同的cpu架构,所以我们要在kernel.spec文件中使用命令行进行替换,kernel.spec在rpmbuild/SPEC/目录下。
编辑的行数在我这里是1608行左右,不同版本会有不同的变化,这里找到的主要依据是找到kernel中有对config文件进行循环操作的部分,比如:
%if %{with_gcov} for i in *.config do sed -i 's/# CONFIG_GCOV_KERNEL is not set/CONFIG_GCOV_KERNEL=y\nCONFIG_GCOV_PROFILE_ALL=y\n/' $i done %endif
在这些代码中的一个下面增加一个循环:
# enable GCOV kernel config options if gcov is on %if %{with_gcov} for i in *.config do sed -i 's/# CONFIG_GCOV_KERNEL is not set/CONFIG_GCOV_KERNEL=y\nCONFIG_GCOV_PROFILE_ALL=y\n/' $i done %endif for i in *.config do sed -i "s/# CONFIG_OCFS2_FS is not set/CONFIG_OCFS2_FS=m/" $i done
意思是在所有的config文件中将# CONFIG_OCFS2_FS is not set
替换成CONFIG_OCFS2_FS=m/
这样就修改完毕了
5 编译内核
# rpmbuild -ba kernel.spec
这个时间会相当的长,我大概用了2个小时左右编译完成,完成后会在/root/rpmbuild/RPMS/x86_64/目录下生成如下文件:
[root@10 x86_64]# ls kernel-5.7.6-201.fc32.x86_64.rpm kernel-core-5.7.6-201.fc32.x86_64.rpm kernel-debug-5.7.6-201.fc32.x86_64.rpm kernel-debug-core-5.7.6-201.fc32.x86_64.rpm kernel-debug-debuginfo-5.7.6-201.fc32.x86_64.rpm kernel-debug-devel-5.7.6-201.fc32.x86_64.rpm kernel-debuginfo-5.7.6-201.fc32.x86_64.rpm kernel-debuginfo-common-x86_64-5.7.6-201.fc32.x86_64.rpm kernel-debug-modules-5.7.6-201.fc32.x86_64.rpm kernel-debug-modules-extra-5.7.6-201.fc32.x86_64.rpm kernel-debug-modules-internal-5.7.6-201.fc32.x86_64.rpm kernel-devel-5.7.6-201.fc32.x86_64.rpm kernel-modules-5.7.6-201.fc32.x86_64.rpm kernel-modules-extra-5.7.6-201.fc32.x86_64.rpm kernel-modules-internal-5.7.6-201.fc32.x86_64.rpm
查看一下ocfs2是否打包成功:
[root@10 x86_64]# rpm -qpl kernel-modules-extra-5.7.6-201.fc32.x86_64.rpm |grep ocfs /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2 /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/cluster /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/cluster/ocfs2_nodemanager.ko.xz /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/dlm /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/dlm/ocfs2_dlm.ko.xz /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/dlmfs /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/dlmfs/ocfs2_dlmfs.ko.xz /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/ocfs2.ko.xz /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/ocfs2_stack_o2cb.ko.xz /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/ocfs2_stack_user.ko.xz /lib/modules/5.7.6-201.fc32.x86_64/extra/fs/ocfs2/ocfs2_stackglue.ko.xz
6 升级替换内核
将上述rpm copy到目标主机上,运行
# yum install kernel-5.7.6-201.fc32.x86_64.rpm kernel-modules-extra-5.7.6-201.fc32.x86_64.rpm
即可安装成功。
7 验证
[root@10 ~]# modprobe ocfs2 [root@10 ~]# lsmod |grep ocfs2 ocfs2 1134592 0 ocfs2_stackglue 20480 1 ocfs2 ocfs2_nodemanager 196608 1 ocfs2
说明安装成功。
ps
- 如果使用之前的ISO封装方法,默认是不安装kernel-modules-extra包的,使用这种方式的时候,需要在iso的repodata的xml中增加kernel-modules-extra,方法请参考Fedora Server定制化封装ISO(4)-定制额外安装包
Greetings! Very helpful advice in this particular article! Tanhya Jeramie Spielman
I could not refrain from commenting. Exceptionally well written. Micki Sawyer Eliot
It really is a lovely series. The characters are great and it just makes you feel good after watching it. Something we all need right now. They did an OVA film that I would love to see but it never got licensed outside of Japan. I would love to see that as well. Sydelle Arther Juna
Having read this I believed it was rather enlightening. I appreciate you finding the time and energy to put this information together. I once again find myself spending way too much time both reading and commenting. But so what, it was still worthwhile. Josefina Randal Tuppeny
One other thing is that an online business administration course is designed for learners to be able to smoothly proceed to bachelor degree programs. The Ninety credit education meets the lower bachelor college degree requirements so when you earn your associate of arts in BA online, you may have access to the most recent technologies on this field. Several reasons why students have to get their associate degree in business is because they can be interested in this area and want to receive the general schooling necessary prior to jumping to a bachelor college diploma program. Thanks for the tips you really provide in your blog. Amalee Gannon Juetta
Suscipit fuga quod unde molestias accusantium praesentium officia asperiores, ipsa itaque. Doloribus ipsum neque nihil magni labore. Voluptates at, temporibus quam eos iure ullam lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam modi laudantium, autem, quasi eligendi possimus suscipit fuga quod unde molestias accusantium praesentium officia asperiores, ipsa itaque. Doloribus ipsum neque nihil magni labore. Voluptates at, temporibus quam eos iure ullam lorem ipsum dolor sit amet, consectetur adipisicing elit. Eaque repellendus dolores nemo deleniti quaerat dicta delectus odit a perspiciatis similique necessitatibus, reiciendis possimus fugiat dolorem! Chloe Elliot Reiser
This is very nice article writing. I am satisfied at how nicely you had been able to make your points with this type of buzz and also enthusiasm. Really decent work. Sonni Andrey Lemal
After exploring a number of the blog articles on your site, I honestly appreciate your technique of writing a blog. I saved it to my bookmark site list and will be checking back in the near future. Take a look at my web site too and let me know your opinion. Gael Wells Tymothy
After I originally left a comment I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on each time a comment is added I get four emails with the same comment. There has to be a means you are able to remove me from that service? Many thanks! Dodie Johny Gilliette
Very good point which I had quickly initiate efficient initiatives without wireless web services. Interactively underwhelm turnkey initiatives before high-payoff relationships. Holisticly restore superior interfaces before flexible technology. Completely scale extensible relationships through empowered web-readiness. Erinn Quintin Maxey
Thank you ever so for you article post. Much thanks again. Keep writing. Pamela Martainn Rycca
I like this web blog veery much, Itss a rattling niche post to read and find information. Odele Kenn Bevvy
Great post! We are linking to this particularly great article on our website. Keep up the good writing. Karissa Abbe Emalee