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

每日存档 十月 19th, 2011

利用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/下

64位CentOS6通过yum安装32位软件

64位CentOS 6 通过yum安装软件的时候,默认不会安装32位的软件,这样会导致某些软件无法安装成功,实际上yum仓库里是有32位软件的,只是它默认只安装64位软件,如果需要安装32位,有2个方法,
假设你要安装libjpeg的32位版本

方法1:
先查询
yum list |grep libjpeg
指定安装32位版
yum install libjpeg.i686

方法2:
这是一种一劳永逸的方法
echo ‘multilib_policy=all’ >> /etc/yum.conf
以下命令会同时安装32位和64位版
yum install libjpeg 

参考资料:http://grokbase.com/t/centos.org/centos/2011/07/centos-centos6-installing-32bit-and-64bit-rpms-via-the-installer/133tcfqf5pag5uldm62ygv34psia

2011年十月
« 8月   11月 »
 12
3456789
10111213141516
17181920212223
24252627282930
31