安裝rpm-build [root@master ~]# yum install rpm-build 創建工作目錄 [root@master ~]# mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} [root@master ~]# cp mysql-5.5.27.tar.gz /root/rpmbuild/SOURCES/ [root@master ~]# cp my.cnf /root/rpmbuild/SOURCES/ [root@master ~]# cp mysqld /root/rpmbuild/SOURCES/ [root@master ~]# cd /root/rpmbuild/SPECS/ [root@master SPECS]# vim mysql.spec Name: mysql Version: 5.5.27 Release: 1%{?dist} Summary: mysql-5.5.27.tar.gz to mysql-5.5.27.rpm Group: Applications/Archiving License:GPL URL: http://www.cnblogs.com/kingtigerhu Vendor: knight Source0: %{name}-%{version}.tar.gz Source1: mysqld Source2: my.cnf BuildRequires: cmake Requires: ncurses-devel Autoreq: no Autoprov : no %description Build mysql-5.5.27.tar.gz to mysql-5.5.27.rpm %prep %setup -q %build //編譯的時候會報錯,所以把%configure刪除了 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci make %{?_smp_mflags} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} %{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}/etc/rc.d/init.d/mysqld %{__install} -p -D %{SOURCE2} %{buildroot}/etc/my.cnf %pre //$1有3個值,代表動作,安裝類型,1表示安裝,2表示升級,0表示卸載 if [ $1 == 1 ];then /usr/sbin/useradd mysql 2> /dev/null fi %post if [ $1 == 1 ];then /sbin/chkconfig --add mysqld /sbin/chkconfig mysqld on echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile source /etc/profile chown -R mysql:mysql /usr/local/mysql /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data > /dev/null 2>&1 fi %preun if [ $1 == 0 ];then /usr/sbin/userdel mysql 2> /dev/null /etc/init.d/mysqld stop > /dev/null 2>&1 fi %postun %clean rm -rf %{buildroot} %files %defattr(-,root,root,0755) /usr/local/mysql/ %attr(0755,root,root) /etc/rc.d/init.d/mysqld %config(noreplace) /etc/my.cnf %doc %changelog * Thu May 12 2016 knight <[email protected]> - 5.5.27-1 - Initial version [root@master SPECS]# rpmbuild -bb mysql.spec [root@master SPECS]# ll /root/rpmbuild/RPMS/x86_64/mysql-* -rw-r--r-- 1 root root 28426984 5月 12 04:16 /root/rpmbuild/RPMS/x86_64/mysql-5.5.27-1.el6.x86_64.rpm [root@slave2 ~]# rpm -ivh mysql-5.5.27-1.el6.x86_64.rpm --nodeps --force Preparing... ########################################### [100%] 1:mysql ########################################### [100%] [root@slave2 ~]# Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/local/mysql/bin/mysqladmin -u root password 'new-password' /usr/local/mysql/bin/mysqladmin -u root -h slave2 password 'new-password' Alternatively you can run: /usr/local/mysql/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/local/mysql/scripts/mysqlbug script! rpm包安裝的時候會顯示這些信息,但是不影響,不知道怎麼屏蔽這些信息,求指教
rpm打包mysql5.5
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.