zoukankan      html  css  js  c++  java
  • mysql运维管理-企业rpm包的定制

    1.安装打包工具

    [linzhongniao@rpmbaozhizuo ~]# yum install rpm-build –y

    2.规划打包目录

    [linzhongniao@rpmbaozhizuo ~]$ vim .rpmmacros
    [linzhongniao@rpmbaozhizuo ~]$ cat .rpmmacros
    %_topdir    /home/linzhongniao/rpmbuild
    [linzhongniao@rpmbaozhizuo ~]$ mkdir -p /home/linzhongniao/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
    [linzhongniao@rpmbaozhizuo ~]$ tree /home/linzhongniao/rpmbuild/
    /home/linzhongniao/rpmbuild/
    ├── BUILD
    ├── RPMS
    ├── SOURCES
    ├── SPECS
    └── SRPMS

    3.mysql-5.5.32打包实战

    [linzhongniao@rpmbaozhizuo ~]$ mkdir -p /home/linzhongniao/tools
    [linzhongniao@rpmbaozhizuo ~]$ cd /home/linzhongniao/tools

    我们将mysql-5.5.32安装包放到新建的这个里面

    [linzhongniao@rpmbaozhizuo tools]$ ls
    mysql-5.5.32.tar.gz

    我们把源码包和启动脚本放到/home/linzhongniao/rpmbuild/SOURCES/下

    [linzhongniao@rpmbaozhizuo tools]$ cp mysql-5.5.32.tar.gz /home/linzhongniao/rpmbuild/SOURCES/
    [linzhongniao@rpmbaozhizuo ~]$ cp /home/linzhongniao/tools/mysql-5.5.32/support-files/mysql.server.sh /home/linzhongniao/rpmbuild/SOURCES/

    我们先登录到root用户解压mysql-5.5.32并查找一下.spec文件在哪,查找到在哪,再切换回普通用户将.spce放到/home/linzhongniao/
    rpmbuild/SPECS/下 。

     [root@rpmbaozhizuo ~]# find / -name *.spec
    /home/linzhongniao/tools/mysql-5.5.32/support-files/mysql.5.5.32.spec
    /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgomp.spec
    /usr/share/vim/vimfiles/template.spec
    [linzhongniao@rpmbaozhizuo tools]$ cp /home/linzhongniao/tools/mysql-5.5.32/support-files/mysql.5.5.32.spec /home/linzhongniao/rpmbuild/SPECS/
     [linzhongniao@rpmbaozhizuo ~]$ ll /home/linzhongniao/rpmbuild/SPECS/
    总用量 80
     -rw-r--r--. 1 linzhongniao linzhongniao 81051 3月   8 07:09 mysql.5.5.32.spec

    查看一下目录结构

    [linzhongniao@rpmbaozhizuo ~]$ tree /home/linzhongniao/rpmbuild/
    /home/linzhongniao/rpmbuild/
    ├── BUILD
    ├── RPMS
    ├── SOURCES
    │   ├── mysql-5.5.32.tar.gz
    │   └── mysql.server.sh
    ├── SPECS
    │   └── mysql.5.5.32.spec
    └── SRPMS

    4.开始打包

    Mysql5.5版本以后需要cmake安装,所以我们先安装cmake再开始打包
    安装cmake很简单直接configure,gmake&&gmake install就可以。

    [linzhongniao@rpmbaozhizuo ~]$ rpmbuild  -v -ba /home/linzhongniao/rpmbuild/SPECS/mysql.5.5.32.spec >>/tmp/install.log
    error: Failed build dependencies:
        gperf is needed by MySQL-5.5.32-2.linux2.6.x86_64
        ncurses-devel is needed by MySQL-5.5.32-2.linux2.6.x86_64
        readline-devel is needed by MySQL-5.5.32-2.linux2.6.x86_64
        time is needed by MySQL-5.5.32-2.linux2.6.x86_64

    好我们上面就是打包的结果,报错了,缺少依赖包,这些依赖包在mysql.5.5.32.spec都定义了。在进行打包时,如果缺少依赖包就会报错打包不成功。

    define distro_buildreq   gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel

    好我们把缺少的安装上再打包

    [root@rpmbaozhizuo cmake-2.8.8]# yum install gperf ncurses-devel readline-devel time –y
    [linzhongniao@rpmbaozhizuo ~]$ rpmbuild  -v -ba /home/linzhongniao/rpmbuild/SPECS/mysql.5.5.32.spec >>/tmp/install.log
    + umask 022
    + cd /home/linzhongniao/rpmbuild/BUILD
    + LANG=C
    + export LANG
    + unset DISPLAY
    + cd /home/linzhongniao/rpmbuild/BUILD
    + rm -rf mysql-5.5.32
    + /bin/mkdir -p mysql-5.5.32
    + cd mysql-5.5.32
    + /usr/bin/gzip -dc /home/linzhongniao/rpmbuild/SOURCES/mysql-5.5.32.tar.gz
    + /bin/tar -xvvf –
    ……省略…..
    CMake Error at cmake/build_configurations/mysql_release.cmake:126 (MESSAGE):
    
      aio is required on Linux, you need to install the required library:
    
    Debian/Ubuntu:  apt-get install libaio-dev
    RedHat/Fedora/Oracle Linux: yum install libaio-devel
    SuSE:   zypper install libaio-devel
    
      If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.
    
    Call Stack (most recent call first):
      CMakeLists.txt:97 (INCLUDE)
    
    error: Bad exit status from /var/tmp/rpm-tmp.jKr0Jj (%build)
    Bad exit status from /var/tmp/rpm-tmp.jKr0Jj (%build)

    哎啊,我们看又出错了,提示说需要安装libaio-devel,我们就把这个包装上再打包,看到下面的Wrote表示打包完成。

    [root@rpmbaozhizuo cmake-2.8.8]# yum install libaio-devel  -y
    [linzhongniao@rpmbaozhizuo ~]$ rpmbuild  -v -ba /home/linzhongniao/rpmbuild/SPECS/mysql.5.5.32.spec >>/tmp/install.log
    + umask 022
    + cd /home/linzhongniao/rpmbuild/BUILD
    + LANG=C
    + export LANG
    + unset DISPLAY
    + cd /home/linzhongniao/rpmbuild/BUILD
    …….省略…….
    Wrote: /home/linzhongniao/rpmbuild/SRPMS/MySQL-5.5.32-2.linux2.6.src.rpm
    Wrote: /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-server-5.5.32-2.linux2.6.x86_64.rpm
    Wrote: /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-client-5.5.32-2.linux2.6.x86_64.rpm
    Wrote: /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-test-5.5.32-2.linux2.6.x86_64.rpm
    Wrote: /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-devel-5.5.32-2.linux2.6.x86_64.rpm
    Wrote: /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-shared-5.5.32-2.linux2.6.x86_64.rpm
    Wrote: /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-embedded-5.5.32-2.linux2.6.x86_64.rpm
    ……省略…….
    exit 0

    5.列出RPM软件包内的文件信息

    [linzhongniao@rpmbaozhizuo ~]$ rpm -qpl /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-server-5.5.32-2.linux2.6.x86_64.rpm 
    /etc/init.d/mysql
    /etc/logrotate.d/mysql
    /etc/my.cnf
    /usr/bin/innochecksum
    /usr/bin/my_print_defaults
    /usr/bin/myisam_ftdump
    /usr/bin/myisamchk
    /usr/bin/myisamlog
    /usr/bin/myisampack
    /usr/bin/mysql_convert_table_format
    /usr/bin/mysql_fix_extensions
    /usr/bin/mysql_install_db
    /usr/bin/mysql_plugin
    /usr/bin/mysql_secure_installation
    /usr/bin/mysql_setpermission
    /usr/bin/mysql_tzinfo_to_sql
    /usr/bin/mysql_upgrade
    /usr/bin/mysql_zap
    /usr/bin/mysqlbug
    /usr/bin/mysqld_multi
    /usr/bin/mysqld_safe
    /usr/bin/mysqldumpslow
    /usr/bin/mysqlhotcopy
    /usr/bin/mysqltest
    /usr/bin/perror
    /usr/bin/replace
    /usr/bin/resolve_stack_dump
    /usr/bin/resolveip
    /usr/lib64/mysql/plugin/adt_null.so
    /usr/lib64/mysql/plugin/auth.so
    /usr/lib64/mysql/plugin/auth_socket.so
    /usr/lib64/mysql/plugin/auth_test_plugin.so
    /usr/lib64/mysql/plugin/daemon_example.ini
    /usr/lib64/mysql/plugin/debug/adt_null.so
    /usr/lib64/mysql/plugin/debug/auth.so
    /usr/lib64/mysql/plugin/debug/auth_socket.so
    /usr/lib64/mysql/plugin/debug/auth_test_plugin.so
    /usr/lib64/mysql/plugin/debug/libdaemon_example.so
    /usr/lib64/mysql/plugin/debug/mypluglib.so
    /usr/lib64/mysql/plugin/debug/qa_auth_client.so
    /usr/lib64/mysql/plugin/debug/qa_auth_interface.so
    /usr/lib64/mysql/plugin/debug/qa_auth_server.so
    /usr/lib64/mysql/plugin/debug/semisync_master.so
    /usr/lib64/mysql/plugin/debug/semisync_slave.so
    /usr/lib64/mysql/plugin/libdaemon_example.so
    /usr/lib64/mysql/plugin/mypluglib.so
    /usr/lib64/mysql/plugin/qa_auth_client.so
    /usr/lib64/mysql/plugin/qa_auth_interface.so
    /usr/lib64/mysql/plugin/qa_auth_server.so
    /usr/lib64/mysql/plugin/semisync_master.so
    /usr/lib64/mysql/plugin/semisync_slave.so
    /usr/sbin/mysqld
    /usr/sbin/mysqld-debug
    /usr/sbin/rcmysql
    /usr/share/doc/MySQL-server-5.5.32
    /usr/share/doc/MySQL-server-5.5.32/COPYING
    /usr/share/doc/MySQL-server-5.5.32/ChangeLog
    /usr/share/doc/MySQL-server-5.5.32/INFO_BIN
    /usr/share/doc/MySQL-server-5.5.32/INFO_SRC
    /usr/share/doc/MySQL-server-5.5.32/README
    /usr/share/doc/MySQL-server-5.5.32/my-huge.cnf
    /usr/share/doc/MySQL-server-5.5.32/my-innodb-heavy-4G.cnf
    /usr/share/doc/MySQL-server-5.5.32/my-large.cnf
    /usr/share/doc/MySQL-server-5.5.32/my-medium.cnf
    /usr/share/doc/MySQL-server-5.5.32/my-small.cnf
    /usr/share/info/mysql.info.gz
    /usr/share/man/man1/innochecksum.1.gz
    /usr/share/man/man1/my_print_defaults.1.gz
    /usr/share/man/man1/myisam_ftdump.1.gz
    /usr/share/man/man1/myisamchk.1.gz
    /usr/share/man/man1/myisamlog.1.gz
    /usr/share/man/man1/myisampack.1.gz
    /usr/share/man/man1/mysql.server.1.gz
    /usr/share/man/man1/mysql_convert_table_format.1.gz
    /usr/share/man/man1/mysql_fix_extensions.1.gz
    /usr/share/man/man1/mysql_install_db.1.gz
    /usr/share/man/man1/mysql_plugin.1.gz
    /usr/share/man/man1/mysql_secure_installation.1.gz
    /usr/share/man/man1/mysql_setpermission.1.gz
    /usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
    /usr/share/man/man1/mysql_upgrade.1.gz
    /usr/share/man/man1/mysql_zap.1.gz
    /usr/share/man/man1/mysqlbug.1.gz
    /usr/share/man/man1/mysqld_multi.1.gz
    /usr/share/man/man1/mysqld_safe.1.gz
    /usr/share/man/man1/mysqldumpslow.1.gz
    /usr/share/man/man1/mysqlhotcopy.1.gz
    /usr/share/man/man1/mysqlman.1.gz
    /usr/share/man/man1/mysqltest.1.gz
    /usr/share/man/man1/perror.1.gz
    /usr/share/man/man1/replace.1.gz
    /usr/share/man/man1/resolve_stack_dump.1.gz
    /usr/share/man/man1/resolveip.1.gz
    /usr/share/man/man8/mysqld.8.gz
    /usr/share/mysql
    /usr/share/mysql/SELinux
    /usr/share/mysql/SELinux/RHEL4
    /usr/share/mysql/SELinux/RHEL4/mysql.fc
    /usr/share/mysql/SELinux/RHEL4/mysql.te
    /usr/share/mysql/binary-configure
    /usr/share/mysql/charsets
    /usr/share/mysql/charsets/Index.xml
    /usr/share/mysql/charsets/README
    /usr/share/mysql/charsets/armscii8.xml
    /usr/share/mysql/charsets/ascii.xml
    /usr/share/mysql/charsets/cp1250.xml
    /usr/share/mysql/charsets/cp1251.xml
    /usr/share/mysql/charsets/cp1256.xml
    /usr/share/mysql/charsets/cp1257.xml
    /usr/share/mysql/charsets/cp850.xml
    /usr/share/mysql/charsets/cp852.xml
    /usr/share/mysql/charsets/cp866.xml
    /usr/share/mysql/charsets/dec8.xml
    /usr/share/mysql/charsets/geostd8.xml
    /usr/share/mysql/charsets/greek.xml
    /usr/share/mysql/charsets/hebrew.xml
    /usr/share/mysql/charsets/hp8.xml
    /usr/share/mysql/charsets/keybcs2.xml
    /usr/share/mysql/charsets/koi8r.xml
    /usr/share/mysql/charsets/koi8u.xml
    /usr/share/mysql/charsets/latin1.xml
    /usr/share/mysql/charsets/latin2.xml
    /usr/share/mysql/charsets/latin5.xml
    /usr/share/mysql/charsets/latin7.xml
    /usr/share/mysql/charsets/macce.xml
    /usr/share/mysql/charsets/macroman.xml
    /usr/share/mysql/charsets/swe7.xml
    /usr/share/mysql/config.huge.ini
    /usr/share/mysql/config.medium.ini
    /usr/share/mysql/config.small.ini
    /usr/share/mysql/czech
    /usr/share/mysql/czech/errmsg.sys
    /usr/share/mysql/danish
    /usr/share/mysql/danish/errmsg.sys
    /usr/share/mysql/dutch
    /usr/share/mysql/dutch/errmsg.sys
    /usr/share/mysql/english
    /usr/share/mysql/english/errmsg.sys
    /usr/share/mysql/errmsg-utf8.txt
    /usr/share/mysql/estonian
    /usr/share/mysql/estonian/errmsg.sys
    /usr/share/mysql/fill_help_tables.sql
    /usr/share/mysql/french
    /usr/share/mysql/french/errmsg.sys
    /usr/share/mysql/german
    /usr/share/mysql/german/errmsg.sys
    /usr/share/mysql/greek
    /usr/share/mysql/greek/errmsg.sys
    /usr/share/mysql/hungarian
    /usr/share/mysql/hungarian/errmsg.sys
    /usr/share/mysql/italian
    /usr/share/mysql/italian/errmsg.sys
    /usr/share/mysql/japanese
    /usr/share/mysql/japanese/errmsg.sys
    /usr/share/mysql/korean
    /usr/share/mysql/korean/errmsg.sys
    /usr/share/mysql/magic
    /usr/share/mysql/my-huge.cnf
    /usr/share/mysql/my-innodb-heavy-4G.cnf
    /usr/share/mysql/my-large.cnf
    /usr/share/mysql/my-medium.cnf
    /usr/share/mysql/my-small.cnf
    /usr/share/mysql/mysql-log-rotate
    /usr/share/mysql/mysql.server
    /usr/share/mysql/mysql_system_tables.sql
    /usr/share/mysql/mysql_system_tables_data.sql
    /usr/share/mysql/mysql_test_data_timezone.sql
    /usr/share/mysql/mysqld_multi.server
    /usr/share/mysql/ndb-config-2-node.ini
    /usr/share/mysql/norwegian
    /usr/share/mysql/norwegian-ny
    /usr/share/mysql/norwegian-ny/errmsg.sys
    /usr/share/mysql/norwegian/errmsg.sys
    /usr/share/mysql/polish
    /usr/share/mysql/polish/errmsg.sys
    /usr/share/mysql/portuguese
    /usr/share/mysql/portuguese/errmsg.sys
    /usr/share/mysql/romanian
    /usr/share/mysql/romanian/errmsg.sys
    /usr/share/mysql/russian
    /usr/share/mysql/russian/errmsg.sys
    /usr/share/mysql/serbian
    /usr/share/mysql/serbian/errmsg.sys
    /usr/share/mysql/slovak
    /usr/share/mysql/slovak/errmsg.sys
    /usr/share/mysql/solaris
    /usr/share/mysql/solaris/postinstall-solaris
    /usr/share/mysql/spanish
    /usr/share/mysql/spanish/errmsg.sys
    /usr/share/mysql/swedish
    /usr/share/mysql/swedish/errmsg.sys
    /usr/share/mysql/ukrainian
    /usr/share/mysql/ukrainian/errmsg.sys

    6.列出RPM软件包中的描述信息

    [linzhongniao@rpmbaozhizuo ~]$ rpm -qpi /home/linzhongniao/rpmbuild/RPMS/x86_64/MySQL-server-5.5.32-2.linux2.6.x86_64.rpm 
    Name: MySQL-server Relocations: (not relocatable)
    Version : 5.5.32Vendor: Oracle and/or its affiliates
    Release : 2.linux2.6Build Date: 2018年03月08日 星期四 07时52分10秒
    Install Date: (not installed)   Build Host: rpmbaozhizuo
    Group   : Applications/DatabasesSource RPM: MySQL-5.5.32-2.linux2.6.src.rpm
    Size: 173398967License: Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Under GPL license as shown in the Description field.
    Signature   : (none)
    Packager: MySQL Release Engineering <mysql-build@oss.oracle.com>
    URL : http://www.mysql.com/
    Summary : MySQL: a very fast and reliable SQL database server
    Description :
    The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
    and robust SQL (Structured Query Language) database server. MySQL Server
    is intended for mission-critical, heavy-load production systems as well
    as for embedding into mass-deployed software. MySQL is a trademark of
    Oracle and/or its affiliates
    
    The MySQL software has Dual Licensing, which means you can use the MySQL
    software free of charge under the GNU General Public License
    (http://www.gnu.org/licenses/). You can also purchase commercial MySQL
    licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
    the GPL. See the chapter "Licensing and Support" in the manual for
    further info.
    
    The MySQL web site (http://www.mysql.com/) provides the latest news and
    information about the MySQL software.  Also please see the documentation
    and the manual for more information.
    
    This package includes the MySQL server binary as well as related utilities
    to run and administer a MySQL server.
    
    If you want to access and work with the database, you have to install
    package "MySQL-client" as well!

    7.rpm方式安装验证

    [root@rpmbaozhizuo x86_64]# pwd
    /home/linzhongniao/rpmbuild/RPMS/x86_64
    [root@rpmbaozhizuo x86_64]# ls
    MySQL-client-5.5.32-2.linux2.6.x86_64.rpm  MySQL-embedded-5.5.32-2.linux2.6.x86_64.rpm  MySQL-shared-5.5.32-2.linux2.6.x86_64.rpm
    MySQL-devel-5.5.32-2.linux2.6.x86_64.rpm   MySQL-server-5.5.32-2.linux2.6.x86_64.rpmMySQL-test-5.5.32-2.linux2.6.x86_64.rpm
    [root@rpmbaozhizuo x86_64]# rpm -ivh MySQL-*
    Preparing...########################################### [100%]
       1:MySQL-devel########################################### [ 17%]
       2:MySQL-client   ########################################### [ 33%]
       3:MySQL-test ########################################### [ 50%]
       4:MySQL-embedded ########################################### [ 67%]
       5:MySQL-shared   ########################################### [ 83%]
       6:MySQL-server   ########################################### [100%]
    
    [root@rpmbaozhizuo x86_64]# ll /etc/init.d/mysql
     -rwxr-xr-x. 1 root root 10815 3月   8 07:51 /etc/init.d/mysql
    [root@rpmbaozhizuo x86_64]# rpm -qf /etc/init.d/mysql
    MySQL-server-5.5.32-2.linux2.6.x86_64
    [root@rpmbaozhizuo x86_64]# /etc/init.d/mysql start
    Starting MySQL.. SUCCESS!

    好到此rpm包已经制作完成,我们可以把常用的软件源码包制作成rpm包,这样安装就会很方便了。

    将定制的rpm包,用yum安装请看企业yum仓库的构建

  • 相关阅读:
    EMQ X v4.3 正式发布:性能大幅提升,更好用的多语言扩展
    全新 EMQ X Cloud 物联网云平台重磅发布
    MQTT 和 CoAP 在 EMQ X 世界的一次「约会」
    Python MQTT 异步框架 —— HBMQTT
    EMQ X 团队:连接数亿关键 IoT 设备|EMQ 2021 全球招聘季
    让每一个来自社区的声音被听见、有回响:EMQ X 开源项目正式采用 RFC 流程
    Kuiper 1.1.2 正式发布
    Xamarin.Forms iOS打包上传AppStore,奇妙的崩溃 EXC_CRASH (SIGABRT)
    大数据系列修炼-Scala课程01
    文本摘要简述
  • 原文地址:https://www.cnblogs.com/zywu-king/p/8570211.html
Copyright © 2011-2022 走看看