下载源码
https://github.com/markfasheh/ocfs2-tools/releases
下载解压到目录 ocfs2-tools-1.86
确保源码能在系统上编译过;
使用编译驱动的环境,centos8.1
进入源码目录
执行 ./autogen.sh
需要安装 rpm包 libuuid-devel libaio-devel readline-devel glib2-devel
然后执行下make,无误后进行下一步
参考源码路径下:
vendor/common/ocfs2-tools.spec-generic
我简单修改了下参考spec如下
#
# Spec file for ocfs2-tools
#
# Macros
# This one is hardcoded because, well, it belongs there
%define _prefix /usr
# Because RPM is dumb
%define _unpackaged_files_terminate_build 0
# Because RH defines lib64 on ppc32 builds
%ifarch ppc
%define brokenrhlibdir /usr/lib
%else
%define brokenrhlibdir %{_libdir}
%endif
%define build_ocfs2console 0
%define compile_py 0
%define systemd_enabled 1
%if %{build_ocfs2console}
%define compile_py python3
%endif
Summary: Tools for managing the Oracle Cluster Filesystem 2
Name: ocfs2-tools
Version: 1.8.6
Release: 1
License: GPL
Group: System Environment/Kernel
Source: ocfs2-tools-1.8.6.tar.gz
URL: http://oss.oracle.com/projects/ocfs2-tools/
Distribution: Oracle
Vendor: Oracle
Packager: nobody <nobody@oracle.com>
Exclusiveos: Linux
Requires: bash, which, coreutils, e2fsprogs, glib2 >= 2.2.3, util-linux >= 2.12j
BuildRequires: e2fsprogs-devel, glib2-devel >= 2.2.3, python36-devel >= 3.6, util-linux >= 2.12j
BuildRoot: %{_tmppath}/ocfs2-tools-1-8.6-root
%if !%{build_ocfs2console}
Obsoletes: ocfs2console
%endif
%description
Tools to manage Oracle Cluster Filesystem 2 volumes.
%if %{build_ocfs2console}
%package -n ocfs2console
Summary: GUI frontend for OCFS2 management
Group: System Environment/Kernel
Requires: e2fsprogs, glib2 >= 2.2.3, vte >= 0.11.10, python >= 3.6, ocfs2-tools = %{version}
AutoReqProv: No
%description -n ocfs2console
GUI frontend for management and debugging of Oracle Cluster Filesystem 2
volumes.
%endif
%package -n ocfs2-tools-devel
Summary: Headers and static archives for ocfs2-tools
Group: Development/Libraries
Requires: e2fsprogs-devel, glib2-devel >= 2.2.3, ocfs2-tools = %{version}
AutoReqProv: No
%description -n ocfs2-tools-devel
ocfs2-tools-devel contains the libraries and header files needed to
develop ocfs2 filesystem-specific programs.
%prep
%setup -n ocfs2-tools-%{version}
%build
%configure --disable-debug --enable-dynamic-ctl --prefix=/usr --mandir=/usr/share/man --libdir=%{brokenrhlibdir}
make
%install
%if %{systemd_enabled}
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
cp -f vendor/common/o2cb.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
cp -f vendor/common/ocfs2.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
mkdir -p $RPM_BUILD_ROOT/sbin
cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/sbin
cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/sbin
%else
mkdir -p $RPM_BUILD_ROOT/etc/init.d
cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/etc/init.d/o2cb
cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/etc/init.d/ocfs2
%endif
if [ -f /etc/redhat-release ]
then
# Red Hat chkconfig is completely and utterly broken
perl -p -i -e 'BEGIN() { $k=0;} if (/^###/) { $k++ } elsif ($k == 1) { printf "#"};' $RPM_BUILD_ROOT/etc/init.d/o2cb
perl -p -i -e 'BEGIN() { $k=0;} if (/^###/) { $k++ } elsif ($k == 1) { printf "#"};' $RPM_BUILD_ROOT/etc/init.d/ocfs2
fi
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
cp -f vendor/common/o2cb.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/o2cb
make DESTDIR="$RPM_BUILD_ROOT" install
%if %{compile_py}
%{__python} -c "import compileall; compileall.compile_dir('$RPM_BUILD_ROOT/%{brokenrhlibdir}/python3.6/site-packages/ocfs2interface', ddir='%{brokenrhlibdir}/python3.6/site-packages/ocfs2interface')"
%endif
%clean
rm -rf "$RPM_BUILD_ROOT"
%post
%if !%{systemd_enabled}
/sbin/chkconfig --add o2cb >/dev/null
/sbin/chkconfig --add ocfs2 >/dev/null
%else
# clean up start/kill entry in /etc/rc*.d/ when upgrade.
if [ -f /etc/init.d/o2cb ]; then
/sbin/chkconfig --del o2cb >/dev/null
fi
if [ -f /etc/init.d/ocfs2 ]; then
/sbin/chkconfig --del ocfs2 >/dev/null
fi
%endif
%preun
%if !%{systemd_enabled}
if [ $1 = 0 ]; then # execute this only if we are NOT doing an upgrade
/sbin/chkconfig --del ocfs2 >/dev/null
/sbin/chkconfig --del o2cb >/dev/null
fi
%endif
%files
%defattr(-,root,root)
%doc COPYING CREDITS MAINTAINERS
/sbin/fsck.ocfs2
/sbin/mkfs.ocfs2
/sbin/mounted.ocfs2
/sbin/tunefs.ocfs2
/sbin/debugfs.ocfs2
/sbin/o2cb_ctl
/sbin/o2cb
/sbin/mount.ocfs2
/sbin/o2image
/sbin/o2cluster
/sbin/ocfs2_hb_ctl
%if %{systemd_enabled}
/sbin/o2cb.init
/sbin/ocfs2.init
/usr/lib/systemd/system/o2cb.service
/usr/lib/systemd/system/ocfs2.service
%else
/etc/init.d/o2cb
/etc/init.d/ocfs2
%endif
/usr/bin/o2info
/usr/sbin/o2hbmonitor
%config(noreplace) /etc/sysconfig/o2cb
/usr/share/man/man8/debugfs.ocfs2.8.gz
/usr/share/man/man8/fsck.ocfs2.8.gz
/usr/share/man/man8/fsck.ocfs2.checks.8.gz
/usr/share/man/man8/mkfs.ocfs2.8.gz
/usr/share/man/man8/tunefs.ocfs2.8.gz
/usr/share/man/man8/mount.ocfs2.8.gz
/usr/share/man/man8/mounted.ocfs2.8.gz
/usr/share/man/man8/o2cb_ctl.8.gz
/usr/share/man/man8/o2cb.8.gz
/usr/share/man/man8/ocfs2_hb_ctl.8.gz
/usr/share/man/man8/o2image.8.gz
/usr/share/man/man7/o2cb.7.gz
/usr/share/man/man1/o2info.1.gz
/usr/share/man/man8/o2hbmonitor.8.gz
/usr/share/man/man5/ocfs2.cluster.conf.5.gz
/usr/share/man/man5/o2cb.sysconfig.5.gz
/usr/share/man/man7/ocfs2.7.gz
/usr/share/man/man8/o2cluster.8.gz
%if %{build_ocfs2console}
%files -n ocfs2console
%defattr(-,root,root)
%{brokenrhlibdir}/python3.6/site-packages/ocfs2interface
/usr/sbin/ocfs2console
/usr/share/man/man8/ocfs2console.8.gz
%endif
%files -n ocfs2-tools-devel
%defattr(-,root,root)
%{brokenrhlibdir}/*.a
%{brokenrhlibdir}/pkgconfig/*.pc
%{_includedir}/ocfs2-kernel
%{_includedir}/o2cb
%{_includedir}/o2dlm
%{_includedir}/ocfs2
%changelog
* Thu Jun 18 2015 Junxiao Bi <junxiao.bi@oracle.com>
- Add systemd support
* Thu Jan 27 2005 Manish Singh <manish.singh@oracle.com>
- Add ocfs2console
* Fri Jan 21 2005 Manish Singh <manish.singh@oracle.com>
- Initial rpm spec
编写build脚本
自己写的脚本,比较简陋
#!/bin/bash
rm -rf rpmbuild
mkdir rpmbuild
cd rpmbuild
mkdir -p BUILD BUILDROOT RPMS SOURCES SPECS SRPM
cd ../
cd ../
tar czvf ocfs2-tools-1.8.6.tar.gz ocfs2-tools-1.8.6
cd ocfs2-tools-1.8.6
mv ../ocfs2-tools-1.8.6.tar.gz rpmbuild/SOURCES/
dir=`pwd`
echo $dir
rpmbuild --bb ocfs2-tools.spec --define "_topdir $dir/rpmbuild"
执行脚本前, make clean 下
将ocfs2-tools.spec 拷贝到源码目录;
执行./build.sh 如下
会报如下错
^~~~~~~~~~~~~~~~~~~~~~~~
op_query.c:341:2: error: format not a string literal and no format arguments [-Werror=format-security]
fprintf(stdout, fmt);
^~~~~~~
cc1: some warnings being treated as errors
make[1]: *** [../Postamble.make:40: op_query.o] Error 1
make[1]: Leaving directory '/root/test/ocfs2-tools-1.8.6/rpmbuild/BUILD/ocfs2-tools-1.8.6/tunefs.ocfs2'
make: *** [Postamble.make:54: tunefs.ocfs2] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.zYBmXE (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.zYBmXE (%build)
解决方法参考
https://github.com/markfasheh/ocfs2-tools/pull/41
高版本gcc检查更严格,可以屏蔽掉这个错误;
在Preamble.make 中31 行添加
31 CFLAGS += -pipe -Wno-format-security -D_DEFAULT_SOURCE=1
执行 ./build.sh
在rpmbuild/RPMS/x86_64目录下生成如下rpm
ocfs2-tools-1.8.6-1.x86_64.rpm ocfs2-tools-debugsource-1.8.6-1.x86_64.rpm
ocfs2-tools-debuginfo-1.8.6-1.x86_64.rpm ocfs2-tools-devel-1.8.6-1.x86_64.rpm
需要在ocfs2集群每个节点上安装 ocfs2-tools-1.8.6-1.x86_64.rpm 这个rpm包
查看rpm包含的文件
[root@localhost x86_64]# rpm -qpl ocfs2-tools-1.8.6-1.x86_64.rpm
/etc/sysconfig/o2cb
/sbin/debugfs.ocfs2
/sbin/fsck.ocfs2
/sbin/mkfs.ocfs2
/sbin/mount.ocfs2
/sbin/mounted.ocfs2
/sbin/o2cb
/sbin/o2cb.init
/sbin/o2cb_ctl
/sbin/o2cluster
/sbin/o2image
/sbin/ocfs2.init
/sbin/ocfs2_hb_ctl
/sbin/tunefs.ocfs2
/usr/bin/o2info
/usr/lib/.build-id
/usr/lib/.build-id/09
/usr/lib/.build-id/09/66b8ed58c278c31d5cb52b8dc29978a94ae963
/usr/lib/.build-id/0d
/usr/lib/.build-id/0d/503f5c9f55616711cb48b50f88018643d86e0d
/usr/lib/.build-id/67
/usr/lib/.build-id/67/91abd49db15bf76dd517ea3c3bd808479c5eb5
/usr/lib/.build-id/74
/usr/lib/.build-id/74/c209dea374fbb0046299c3b0ab21cd0350d523
/usr/lib/.build-id/7b
/usr/lib/.build-id/7b/21823469fb73f5d2c7f6540d7bd21eed215746
/usr/lib/.build-id/80
/usr/lib/.build-id/80/c3acb5e468dd8f62c7411a2c8dfdaf71c2e943
/usr/lib/.build-id/8e
/usr/lib/.build-id/8e/371817caeb4fc7b2c1fba44c4ee123ae97abbb
/usr/lib/.build-id/9f
/usr/lib/.build-id/9f/3054dcf861b09035d3b43d61027419d841acb6
/usr/lib/.build-id/a3
/usr/lib/.build-id/a3/22eef605b18e43d4804fd76468fd01372e661a
/usr/lib/.build-id/c2
/usr/lib/.build-id/c2/645a4cc69047a1ebb66710060a78fa02ec0d46
/usr/lib/.build-id/cd
/usr/lib/.build-id/cd/bd9f1499fcbed780ee09c1de86a3e3a5be677f
/usr/lib/.build-id/e1
/usr/lib/.build-id/e1/d4d802daac2a20c8379d563df77e0431b105d7
/usr/lib/.build-id/ed
/usr/lib/.build-id/ed/092bf54e8cc02333aa3b3cb129789040751123
/usr/lib/systemd/system/o2cb.service
/usr/lib/systemd/system/ocfs2.service
/usr/sbin/o2hbmonitor
/usr/share/doc/ocfs2-tools
/usr/share/doc/ocfs2-tools/COPYING
/usr/share/doc/ocfs2-tools/CREDITS
/usr/share/doc/ocfs2-tools/MAINTAINERS
/usr/share/man/man1/o2info.1.gz
/usr/share/man/man5/o2cb.sysconfig.5.gz
/usr/share/man/man5/ocfs2.cluster.conf.5.gz
/usr/share/man/man7/o2cb.7.gz
/usr/share/man/man7/ocfs2.7.gz
/usr/share/man/man8/debugfs.ocfs2.8.gz
/usr/share/man/man8/fsck.ocfs2.8.gz
/usr/share/man/man8/fsck.ocfs2.checks.8.gz
/usr/share/man/man8/mkfs.ocfs2.8.gz
/usr/share/man/man8/mount.ocfs2.8.gz
/usr/share/man/man8/mounted.ocfs2.8.gz
/usr/share/man/man8/o2cb.8.gz
/usr/share/man/man8/o2cb_ctl.8.gz
/usr/share/man/man8/o2cluster.8.gz
/usr/share/man/man8/o2hbmonitor.8.gz
/usr/share/man/man8/o2image.8.gz
/usr/share/man/man8/ocfs2_hb_ctl.8.gz
/usr/share/man/man8/tunefs.ocfs2.8.gz
[root@localhost x86_64]#
包含了o2cb ,mkfs.ocfs2, mount.ocfs2,o2cb_ctl o2info 等ocfs2工具包。
centos8 没有net-work 服务 而是由 NetworkManager 服务替换
需要修改源码中/vendor/common/o2cb.service 和ocfs2.service中 net-work 为NetworkManager
o2cb.service
[Unit]
Description=Load o2cb Modules
Documentation=man:o2cb(7) man:o2cb.sysconfig(5)
Requires=NetworkManager.service
After=NetworkManager.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/o2cb.init enable
ExecStop=/sbin/o2cb.init disable
[Install]
WantedBy=multi-user.target
ocfs2.service
[Unit]
Description=Mount ocfs2 Filesystems
Documentation=man:ocfs2(7) man:mount.ocfs2(8)
Requires=o2cb.service
After=NetworkManager.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ocfs2.init start
ExecStop=/sbin/ocfs2.init stop
ExecReload=/sbin/ocfs2.init restart
[Install]
WantedBy=multi-user.target
修改后 在centos8 系统上能用,否则,o2cb, ocfs2服务启不来。