Fpm 之 Mysql-5.7.21 rpm 包制作

Fpm 之 Mysql-5.7.21 rpm 包制作

一、首先将mysql-5.7.21编译安装包,安装到自定义的目录

1. 下载安装包
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21.tar.gz

2.安装依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake

3.添加mysql 用户与组
groupadd mysql
useradd -r -g mysql mysql

4.新建MYSQL的安装目录,与数据存放目录
mkdir -p /app/mysql
mkdir -p /app/data

5.解压安装
tar -zxvf boost_1_59_0.tar.gz
tar -zxvf mysql-5.7.21.tar.gz
cd mysql-5.7.21      #进入mysql的解压目录

6.使用cmake 编译mysql
cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/app/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost_1_59_0 -DSYSCONFDIR=/etc \-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1

7.编译安装mysql
make && make install

8.设置开机自动启动脚本
cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

9.修改MYSQL的环境变量
vi /etc/profile
export PATH=$PATH:/app/mysql/bin
source /etc/profile

10.修改MYSQL所在目录权限
chown -R mysql:mysql /app/mysql

11.初始化MYSQL数据库
[[email protected] ~]# /app/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data
2018-03-26T07:31:17.298033Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-26T07:31:18.332278Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-03-26T07:31:18.436844Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-26T07:31:18.453099Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ac7149bc-30c7-11e8-999a-005056804f18.
2018-03-26T07:31:18.458082Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2018-03-26T07:31:18.458468Z 1 [Warning] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option.
[[email protected] ~]# ll /app/data/
total 110620
-rw-r-----. 1 mysql mysql       56 Mar 26 15:31 auto.cnf
-rw-r-----. 1 mysql mysql      420 Mar 26 15:31 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Mar 26 15:31 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Mar 26 15:31 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Mar 26 15:31 ib_logfile1
drwxr-x---. 2 mysql mysql     4096 Mar 26 15:31 mysql
drwxr-x---. 2 mysql mysql     4096 Mar 26 15:31 performance_schema
drwxr-x---. 2 mysql mysql    12288 Mar 26 15:31 sys

12.修改配置文件,如下:
vi /etc/my.cnf
[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
user = mysql
basedir = /app/mysql
datadir = /app/mysql/data
port=3306
server-id = 1
socket=/tmp/mysql.sock

character-set-server = utf8
#log-error = /var/log/mysql/error.log
#pid-file = /var/log/mysql/mysql.pid
general_log = 1
skip-name-resolve
#skip-networking
back_log = 300

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 28M
key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30

performance_schema = 0
explicit_defaults_for_timestamp

#lower_case_table_names = 1

myisam_sort_buffer_size = 8M
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES

[mysqldump]
quick
max_allowed_packet = 16M

13.创建错误日志与PID存放位置
mkdir -p /var/log/mysql/
chown -R mysql:mysql /var/log/mysql/

14.启动mysql
[[email protected] mysql]# service mysqld start
Starting MySQL.[  OK  ]
[[email protected] mysql]# netstat -tlnp | grep 3306
tcp        0      0 :::3306                     :::*                        LISTEN      27565/mysqld

二、制作rpm包安装后的运行脚本

[[email protected] mysql]#mkdir -p /app/mysql/script                    #存放安装后的运行脚本
[[email protected] mysql]#cp /etc/my.cnf .                                      #将mysql的配置文件复制到该目录
[[email protected] mysql]#vi server.sh                                             #rpm包安装后的要运行的脚本
#!/bin.bash

#add mysql user
groupadd mysql
useradd -r -g mysql mysql

#制作自启动服务
cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

#添加环境变量
echo "export PATH=$PATH:/app/mysql/bin" >> /etc/profile

#环境变量生效,但貌似不起作用,需后续在客户端运行
source /etc/profile

#修改mysql安装目录的权限
chown -R mysql:mysql /app/mysql

#复制配置文件到相应路径
cp /app/mysql/script/my.cnf /etc/

三、生成rpm包

fpm -s dir -t rpm -n mysql -v 5.7.21 -d ‘gcc,gcc-c++,ncurses,ncurses-devel,cmake‘ --post-install /app/mysql/script/server.sh -f /app/mysql/

四、到客户端测试安装rpm包

[[email protected] ~]# ll | grep mysql-5.7.21-1.x86_64.rpm
-rw-r--r--  1 root root 469765290 Jun 13 20:57 mysql-5.7.21-1.x86_64.rpm
[[email protected] ~]# yum -y localinstall mysql-5.7.21-1.x86_64.rpm 

五、安装完后的效果

[[email protected] ~]# ll /app/                #指定了安装目录
total 8
drwxr-xr-x 12 mysql mysql 4096 Jun 13 20:07 mysql
drwxr-xr-x  4 root  root  4096 Jun 13 16:53 software
[[email protected] ~]# chkconfig | grep mysqld           #添加了自启动服务
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[[email protected] ~]# service mysqld start          #启动成功
Starting MySQL.[  OK  ]

原文地址:http://blog.51cto.com/12965094/2129267

时间: 2024-11-02 08:15:39

Fpm 之 Mysql-5.7.21 rpm 包制作的相关文章

Fpm 之 Nginx rpm 包制作

Fpm 之 Nginx rpm 包制作 一.下载nginx编译安包机器上 wget http://nginx.org/download/nginx-1.12.2.tar.gz 二.安装nginx的编译所需的依赖包 yum -y install pure lib gcc-c++ openssl openssl-devel 三.编译安装nginx tar -zxvf nginx-1.12.2.tar.gz cd nginx-1.12.2 ./configure --prefix=/app/nginx

MySQL 5.6.35 RPM包方式的安装

Mysql 5.6.35版本 RPM包方式的安装 一.删除旧的RPM包: 查询 rpm -qa | grep -i mysql如果有需要先删除rpm -ev mysql-libs- --nodepsrpm -e --nodeps mysql-devel-5.1.73rpm -e --nodeps mysql-5.1.73*加--nodeps是强力删除 二.在安装要确保先禁用selinux,关闭防火墙iptables 禁用selinux临时禁用命令setenforce 0 永久禁用使用文本编辑工具

nginx的rpm包制作

nginx prm包 详细制作流程 1.准备工作 1.1:我这里准备了一台centos7的虚拟主机 1.2:官网下载最新的稳定版nginx源码包,地址:http://nginx.org/nginx-1.10.2.tar.gz 1.3:官网下载nginx的控制脚本,地址:https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/ 1.4:手动安装一遍,看看都需要哪些依赖,所需依赖:gcc-c++,pcre-

RPM包制作方法

一.RPM介绍 RPM 前是Red Hat Package Manager 的缩写,本意是Red Hat 软件包管理,顾名思义是Red Hat 贡献出来的软件包管理:现在应为RPM Package Manager的缩写.在Fedora.Redhat.Mandriva.SuSE.YellowDog等主流发行版本,以及在这些版本基础上二次开发出来的发行版采用: RPM包中除了包括程序运行时所需要的文件,也有其它的文件:一个RPM包中的应用程序,有时除了自身所带的附加文件保证其正常以外,还需要其它特定

Ngins rpm包制作,spec配置文件

Name:           nginx Version:        1.4.2 Release:        1%{?dist} Summary:        nginx from source Group:          System Environment/Daemons License:        GPLv2 URL:            http://nginx.org Source0:        %{name}-%{version}.tar.gz Source

php-7.1.0 rpm包制作

nginx-1.8.0 rpm包制作见上篇文章:http://www.cnblogs.com/xiaoming279/p/6251149.html spec文件 Name: php Version: 7.1.0 Release: 1%{?dist} Summary: php Group: Applications/Server License: GPLv2 URL: http://www.51.com Source0: %{name}-%{version}.tar.gz Source1: php

rpm包制作(一)

rpm介绍 rpm的全称是RedhatPackage Manager,常见的使用rpm软件包的系统主要有Fedora.CentOS.openSUSE.SUSE企业版.PCLinuxOS等.使用deb软件包后缀的类Debian系统最常见的有Debian.Ubuntu.Finnix等. 从软件运行的结构来说,一个软件主要可以分为三个部分:可执行程序.配置文件和动态库.当然还有可能会有相关文档.手册.供二次开发用的头文件以及一些示例程序等等.可执行文件是必须的,其他部分都是可选的. 制作rpm软件包的

linux之rpm包制作

难点:spec文件的编写 1,首先安装rpm-build命令 yum install rpm-build 2,介绍spec编写规则: #ll #drwxr-xr-x  2 root root 4096 Jul 29 13:50 BUILD #drwxr-xr-x  2 root root 4096 Jul 29 13:51 RPMS #drwxr-xr-x  2 root root 4096 Jul 29 13:51 SOURCES #drwxr-xr-x  2 root root 4096 J

linux rpm包制作

Linux Rpm 包制作 一.简介 RPM(Red Hat Package Manager)的最常见的软件包管理器. 软件包管理器 rpm,deb(dpkg) RPM包命名:name-version-release.architecture.rpm. xorg-x11-xsm-1.0.2 -4.fc6.i386.rpm 包名       版本号 编译次数 厂商 平台 RPM功能:安装.卸载.升级.查询和验证. rpm     -ivh              安装 rpm     -Uvh