fpm制做mysql-5.6.33 rpm包
增加用户:
# groupadd -r mysql # useradd -g mysql -r -s /sbin/nologin -M -d /data/my_db mysql
源码安装mysql-5.6.33.tar.gz 初始代数据库
[root@c01 mysql-5.6.33]# cp /apps/mysql-5.6.33/support-files/mysql.server /etc/init.d/mysqld
[root@c01 mysql-5.6.33]# chmod 777 /etc/init.d/mysld
修改以下内容
basedir=/apps/mysql-5.6.33
datadir=/data/my_db
# Set some defaults
mysqld_pid_file_path=/data/my_db/mysqld.pid
[root@c01 mysql-5.6.33]# ln -sv /apps/mysql-5.6.33/include /usr/include/mysql
`/usr/include/mysql' -> `/apps/mysql-5.6.33/include'
[root@c01 mysql-5.6.33]# /apps/mysql-5.6.33/scripts/mysql_install_db --datadir=/data/my_db --user=mysql
[root@c01 mysql-5.6.33]# echo '/apps/mysql-5.6.33/lib' >/etc/ld.so.conf.d/mysql-x86_64.conf
[root@c01 mysql-5.6.33]# ldconfig
[root@c01 mysql-5.6.33]# echo 'export PATH=/apps/mysql-5.6.33/bin/:$PATH' >/etc/profile.d/mysql.sh
[root@c01 mysql-5.6.33]# source /etc/profile
[root@c01 mysql-5.6.33]# mv /etc/init.d/mysld /etc/init.d/mysqld
[root@c01 tmp]# fpm -s dir -t rpm -v 5.6.33 -n mysql --before-install /tmp/before.sh --after-install /tmp/after.sh --after-remove /tmp/remove.sh -d 'libaio' /apps/mysql-5.6.33/ /data/my_db/ /etc/init.d/mysqld
no value for epoch is set, defaulting to nil {:level=>:warn}
no value for epoch is set, defaulting to nil {:level=>:warn}
Created package {:path=>"mysql-5.6.33-1.x86_64.rpm"}
下面是所需要的脚本:
# cat /tmp/after.sh #!/bin/bash ln -sv /apps/mysql-5.6.33/include /usr/include/mysql echo '/apps/mysql-5.6.33/lib/' > /etc/ld.so.conf.d/mysql.conf ldconfig echo 'export PATH=/apps/mysql-5.6.33/bin/:$PATH' > /etc/profile.d/mysql.sh source /etc/profile chown -R mysql:mysql /data/my_db echo "[mysqld] basedir=/apps/mysql-5.6.33 datadir=/data/my_db port=3306 socket=/data/my_db/mysql.sock user=mysql innodb_file_per_table=on skip_name_resolve=on symbolic-links=0 init-connect='SET NAMES utf8' character-set-server=utf8 max_connections=5000 max_connect_errors=100000 [mysqld_safe] log-error=/data/my_db/mysqld.log pid-file=/data/my_db/mysqld.pid [client] socket=/data/my_db/mysql.sock " >/etc/my.cnf
# cat /tmp/before.sh #!/bin/bash #创建mysql数据存储目录 if [ ! -d /apps/mysql-5.6.16 ];then mkdir /apps/mysql-5.6.16 -p fi if [ ! -d /data/my_db ];then mkdir /data/my_db -p fi #创建mysql用户 groupadd -r mysql useradd -g mysql -r -s /sbin/nologin -M -d /data/my_db mysql # if [ -f /etc/ld.so.conf.d/mysql-x86_64.conf ];then rm -rf /etc/ld.so.conf.d/mysql-x86_64.conf fi
# cat /tmp/remove.sh #!/bin/bash userdel -r mysql if [ -f /etc/ld.so.conf.d/mysql.conf ];then rm -rf /etc/ld.so.conf.d/mysql.conf fi if [ -f cat /etc/profile.d/mysql.sh ];then rm -rf cat /etc/profile.d/mysql.sh fi
联系方式QQ:326528263 EMAIL:clnking@163.com 网名:bass 分享技术 突破难点 创新思维
浙公网安备 33010602011771号