CentOS 7源码编译安装MySQL 8.0

0.前期准备条件

•查看linux的版本

[root@mysql etc]# cat /etc/RedHat-release
CentOS Linux release 7.3.1611 (Core)

•Could NOT find Curses

yum install ncurses-devel

•Bison executable not found in PATH

yum install bison

备注:
 安装过程中会缺少基础包,本实例环境缺少上述包,先提前安装相应的包

1.cmake的源编译安装

[root@db software]# nohup tar zxvf cmake-3.11.1.tar.gz &
[root@db software]# cd cmake-3.11.1
[root@db cmake-3.11.1]# ./configure
[root@localhost cmake-3.0.1]# gmake && make install

2.wolfssl包的部署安装[可选项]

*. 从wolfssl.com网站下载wolfssl-3.13.0.zip压缩包
*. 解压至/data/software/mysql-8.0.11/extra/wolfssl-3.13.0目录中。
*. cd extra/wolfssl-3.13.0/IDE/MYSQL
*. 执行do.sh脚本
*. use -DWITH_SSL=wolfssl for CMake

3.openssl和openssl-devel[本实验使用的是system ssl]

yum install –y openssl openssl-devel

4.mysql的编译安装

[root@mysql software]#tar zxvf mysql-8.0.11.tar.gz
[root@mysql software]# cd mysql-8.0.11/
[root@mysql software]# mkdir Zdebug
[root@mysql software]# cd Zdebug

cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNODB_MEMCACHED=ON \
-DWITH_SSL=system \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT="zsd edition" \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/tmp \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock \
-DSYSCONFDIR=/data/mysqldata/3306 > /data/software/mysql-8.0.11/Zdebug/mysql_cmake80.log 2>&1

出现下列日志:

............
-- Configuring done
-- Generating done
-- Build files have been written to: /data/software/mysql-8.0.11/Zdebug
............

说明编译成功,其中-DWITH_SSL=system用的是linux操作系统的openssl,需要安装openssl和openssl-devel包,才可以被编译

如果需要编译安装快速,可以运用多线程加快编译安装,命令如下:

make -j 12
make install

•MySQL 8.0的软件目录结构

[root@mysql Zdebug]# cd /usr/local/mysql/
[root@mysql mysql]# ls -l
total 612
drwxr-xr-x.  2 root root  4096 May 16 14:20 bin
drwxr-xr-x.  2 root root    55 May 16 14:20 docs
drwxr-xr-x.  3 root root    266 May 16 14:20 include
drwxr-xr-x.  4 root root    173 May 16 14:20 lib
-rw-r--r--.  1 root root 301518 Apr  8 14:44 LICENSE
-rw-r--r--.  1 root root 301518 Apr  8 14:44 LICENSE-test
drwxr-xr-x.  4 root root    30 May 16 14:20 man
drwxr-xr-x. 10 root root  4096 May 16 14:21 mysql-test
-rw-r--r--.  1 root root    687 Apr  8 14:44 README
-rw-r--r--.  1 root root    687 Apr  8 14:44 README-test
drwxr-xr-x. 28 root root  4096 May 16 14:21 share
drwxr-xr-x.  2 root root    90 May 16 14:21 support-files

5.创建mysql用户&并修改相关文件

[root@mysql mysql]# groupadd mysql
[root@mysql mysql]# useradd -g mysql mysql

6.设置用户操作系统资源的限制

[root@localhost cmake-3.0.1]# vi /etc/security/limits.conf
mysql soft nproc 65536
mysql hard nproc 65536
mysql soft nofile 65536
mysql hard nofile 65536

验证limit是否生效

[root@mysql ~]# su - mysql
[mysql@mysql ~]$ ulimit -a

日志如下:
............
open files                      (-n) 65536
max user processes              (-u) 65536

7.创建MySQL数据目录及赋予相应权限

#cd /data/
#mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,innodb_ts,innodb_log},backup,scripts}
#chown -R mysql:mysql mysqldata
#su - mysql

8.配置my.cnf文件

$vi /data/mysqldata/3306/my.cnf

[client]
port = 3306
socket = /data/mysqldata/3306/mysql.sock
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /data/mysqldata/3306/mysql.sock
pid-file = /data/mysqldata/3306/mysql.pid
basedir = /usr/local/mysql
datadir = /data/mysqldata/3306/data
tmpdir = /data/mysqldata/3306/tmp
open_files_limit = 60000
explicit_defaults_for_timestamp
server-id = 1203306
lower_case_table_names = 1
character-set-server = utf8
federated
#sql_mode=STRICT_TRANS_TABLES
max_connections = 1000
max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=0
back_log=100
default-storage-engine = InnoDB
log_slave_updates = 1

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/232c0fae9cf13e671035f7b41fc30ef2.html