cixiren 发表于 2018-10-5 11:39:18

Fpm 之 Mysql-5.7.21 rpm 包制作

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数据库
  # /app/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data
  2018-03-26T07:31:17.298033Z 0 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 InnoDB: New log files created, LSN=45790
  2018-03-26T07:31:18.436844Z 0 InnoDB: Creating foreign key constraint system tables.
  2018-03-26T07:31:18.453099Z 0 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 Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2018-03-26T07:31:18.458468Z 1 root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
  # 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
  
  port=3306
  socket=/tmp/mysql.sock
  
  # 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>  # 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
  
  quick
  max_allowed_packet = 16M
  13.创建错误日志与PID存放位置
  mkdir -p /var/log/mysql/
  chown -R mysql:mysql /var/log/mysql/
  14.启动mysql
  # service mysqld start
  Starting MySQL.
  # netstat -tlnp | grep 3306
  tcp      0      0 :::3306                     :::*                        LISTEN      27565/mysqld

页: [1]
查看完整版本: Fpm 之 Mysql-5.7.21 rpm 包制作