Think before you speak, read before you think.

制作MariaDB5.5.31的rpm包

制作MariaDB的rpm包使用CMake CPack Package Generators,这种制作出来的包叫做CPackRPM包。

首先安装好环境(必须全部检查):

bzr > 2.0
gunzip
GNU tar
gcc 2.95.2 or later
g++
GNU make 3.75 or later
libtool 1.5.24 or later
bison (2.0 for MariaDB 5.5)
libncurses (在centos下名为ncurses-devel)
zlib-dev
GNU automake
GNU autoconf
cmake >= 2.8.7 (在centos下名为cmake28)

使用非root用户,将下载好的mariadb-5.5.31.tar.gz解压,这里是 /home/jpuyy/mariadb-5.5.31。

将要编译的参数写到cmake后面,这里是最关键的是制作rpm包的参数-DRPM=centos6,语句的最后要有一个点号,表示在当前目录生成。

cmake28 -DRPM=centos6 \
-DCMAKE_INSTALL_PREFIX=/usr/local/DBServer/MariaDB5.5.31 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=complex .

当最后几行是如下信息时,表示检查编译通过

-- Configuring done
-- Generating done
-- Build files have been written to: /home/jpuyy/mariadb-5.5.31

打包

make package

连spec文件都不用写,cmake会自动生成制作rpm的环境,位置在/home/jpuyy/mariadb-5.5.31/_CPack_Packages/Linux/RPM

最后生成的rpm包如下

MariaDB-5.5.31-centos6-x86_64-client.rpm
MariaDB-5.5.31-centos6-x86_64-common.rpm
MariaDB-5.5.31-centos6-x86_64-devel.rpm
MariaDB-5.5.31-centos6-x86_64-server.rpm
MariaDB-5.5.31-centos6-x86_64-shared.rpm
MariaDB-5.5.31-centos6-x86_64-test.rpm

这些包的作用

https://kb.askmonty.org/en/about-the-mariadb-rpm-files/

安装方法:

需要解决冲突和依赖

冲突:查找已经安装的mysql包,rpm -qa ‘mysql*’,移除查找到的mysql包

rpm -e mysql-libs-5.1.66-2.el6_3.x86_64 --nodeps
rpm -e `rpm -qa mysql-libs*` --nodeps

依赖:在执行rpm -ivh MariaDB-5.5.31-centos6-x86_64*时,如果出现依赖,如

error: Failed dependencies:
perl(DBI) is needed by MariaDB-server-5.5.31-1.x86_64
perl(Time::HiRes) is needed by MariaDB-test-5.5.31-1.x86_64

可以yum安装perl-DBI,perl-Time-HiRes。也可以使用

rpm -ivh MariaDB-5.5.31-centos6-x86_64-* --nodeps

不去检测依赖。PS:有些依赖确实无用可不用安装。

参考:

https://kb.askmonty.org/en/source-building-mariadb-on-centos/

https://kb.askmonty.org/en/installing-mariadb-with-the-rpm-tool/


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *