寻觅生命中的那一片浅草......

利用rpmbuild制作MySQL的rpm包

1、配置环境
yum -y install rpm-build
2、下载源代码rpm包
mkdir /root/download
cd /root/download
wget http://www.percona.com/redir/downloads/Percona-Server-5.1/Percona-Server-5.1.58-12.9/source/Percona-Server-51-5.1.58-rel12.9.271.rhel6.src.rpm

3、安装打包MySQL时依赖的包

yum -y install perl readline-devel gcc-c++ ncurses-devel zlib-devel libtool automake autoconf time ccache bison

4、安装percona的源代码
rpm -ivh Percona-Server-51-5.1.58-rel12.9.271.rhel6.src.rpm

安装了2个文件,它们的位置是
/root/rpmbuild/SOURCES/Percona-Server-5.1.58.tar.gz
/root/rpmbuild/SPECS/percona-server.spec

5、修改percona-server.spec
加入我们自己的编译参数
vi percona-server.spec

# The –enable-assembler simply does nothing on systems that does not
# support assembler speedups.

%if %{YASSL_BUILD}
之间的一段修改成这样

# The –enable-assembler simply does nothing on systems that does not
# support assembler speedups.
sh -c  “CFLAGS=\”$CFLAGS\” \
CXXFLAGS=\”$CXXFLAGS\” \
AM_CPPFLAGS=\”$AM_CPPFLAGS\” \
LDFLAGS=\”$LDFLAGS\” \
./configure \
$* \
–with-comment=MC-DB \
–with-server-suffix=-MC-DB-Server \
–with-charset=utf8 \
–with-plugins=blackhole,csv,innodb_plugin \
–enable-assembler \
–enable-local-infile \
–with-mysqld-user=%{mysqld_user} \
–with-unix-socket-path=/tmp/mysql.sock \
–with-pic \
-prefix=/usr \
–with-extra-charsets=gbk,gb2312,utf8 \
–without-debug \
–with-pthread \
–enable-thread-safe-client \
–with-client-ldflags=-all-static \
–without-ndb-debug \
%if %{YASSL_BUILD}

保存退出

6、定义在打包过程中不进行测试
export MYSQL_RPMBUILD_TEST=”no”

7、开始打包
cd /root/rpmbuild/SPECS/
rpmbuild -bb percona-server.spec
等待一段时间就可以看到编译好的软件包
/root/rpmbuild/RPMS/x86_64

Percona-Server-client-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-devel-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-server-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-shared-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-test-51-5.1.58-rel12.9.rhel6.x86_64.rpm

7、安装顺序
先安装这个
Percona-Server-shared-51-5.1.58-rel12.9.rhel6.x86_64.rpm
再安装其他软件包
8、已知问题:
无法打包为一个包
无法将所有问题安装到一个目录,例如我们之前一直安装的目录/usr/local/mysql

9、题外话
一般MySQL源代码包都有包含打包所需要的spec文件,一般存放在support-files/下

尚无评论

发表评论

2024年四月
« 5月    
1234567
891011121314
15161718192021
22232425262728
2930