percona-server-8.0.25-15源码编译安装
###############################
cmake:需要源码安装cmake3.5.1+,但cmake不要升级到最新。 3.5.1版本、3.5.2版本即可。因为3.20+版本编译mysql8.0 会报各种错误
gcc:使用devtoolset-8即可,建议也不要升级到devtoolset-11最新版本
yum -y install centos-release-scl scl-utils-build devtoolset-8-toolchain
scl enable devtoolset-8 bash
-- BOOST_INCLUDE_DIR /usr/include -- LOCAL_BOOST_DIR -- LOCAL_BOOST_ZIP -- Could not find (the correct version of) boost. -- MySQL currently requires boost_1_77_0 CMake Error at cmake/boost.cmake:108 (MESSAGE): You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory> This CMake script will look for boost in <directory>. If it is not there, it will download and unpack it (in that directory) for you. You can also download boost manually, from https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2 If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80 Call Stack (most recent call first): cmake/boost.cmake:308 (COULD_NOT_FIND_BOOST) CMakeLists.txt:1578 (INCLUDE)
cmake . -DCMAKE_INSTALL_PREFIX=/home/work/mysql_3309 -DMYSQL_DATADIR=/home/work/mysql_3309/data -DSYSCONFDIR=/home/work/mysql_3309/conf -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DFORCE_INSOURCE_BUILD=1 -DWITH_BOOST=./ -DDOWNLOAD_BOOST=1
如果需要指定c和c++的编译器位置可通过:-DCMAKE_C_COMPILER、-DCMAKE_CXX_COMPILER分别指定
wget https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.25-15/source/tarball/percona-server-8.0.25-15.tar.gz wget https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.32-24/source/tarball/percona-server-8.0.32-24.tar.gz wget https://downloads.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.40-43/source/tarball/percona-server-5.7.40-43.tar.gz
wget https://downloads.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.28/binary/tarball/percona-xtrabackup-2.4.28-Linux-x86_64.glibc2.17.tar.gz wget https://downloads.percona.com/downloads/Percona-XtraBackup-8.0/Percona-XtraBackup-8.0.25-17/binary/tarball/percona-xtrabackup-8.0.25-17-Linux-x86_64.glibc2.17.tar.gz
关闭selinux:
[root@192.168.31.225:~]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: disabled Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33 [root@192.168.31.225:~]# setenforce 0 [root@192.168.31.225:~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of these three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@192.168.31.225:~]#
##################################
cmake:
注意:须提前准备好boot库,我这里下载的是boost_1_37_0.tar.gz版本
# tar -xzvf percona-server-8.0.25-15.tar.gz # cd percona-server-8.0.25-15/ # mkdir build # cd build # cmake ../ -DCMAKE_INSTALL_PREFIX=/home/work/mysql_3306 -DMYSQL_DATADIR=/home/work/mysql_3306/data -DSYSCONFDIR=/home/work/mysql_3306/etc -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_BOOST=../../boost_1_73_0 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_EMBEDDED_SERVER=OFF -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=gbk,gb2312,utf8mb4,ascii -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_DEBUG=0 -DWITH_EMBEDDED_SERVER=1 -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
make -j4:
# make -j4
make install:
# make install
初始化:mysqld --initialize
要保证--datadir指定的目录不存在,即data目录不存在;若存在,则报下面错:
[work@192.168.31.225:mysql_3306]# ./bin/mysqld --initialize --user=work --basedir=/home/work/mysql_3306 --datadir=/home/work/mysql_3306/data mysqld: Can't create/write to file '/home/work/mysql_3306/data/is_writable' (OS errno 13 - Permission denied) 2023-03-09T00:35:02.794491Z 0 [System] [MY-013169] [Server] /data/mysql_3306/bin/mysqld (mysqld 8.0.25-15) initializing of server in progress as process 184829 2023-03-09T00:35:02.797243Z 0 [ERROR] [MY-010460] [Server] --initialize specified but the data directory exists and is not writable. Aborting. 2023-03-09T00:35:02.797259Z 0 [ERROR] [MY-013236] [Server] The designated data directory /home/work/mysql_3306/data/ is unusable. You can remove all files that the server added to it. 2023-03-09T00:35:02.797339Z 0 [ERROR] [MY-010119] [Server] Aborting 2023-03-09T00:35:02.797510Z 0 [System] [MY-010910] [Server] /data/mysql_3306/bin/mysqld: Shutdown complete (mysqld 8.0.25-15) Source distribution. [work@192.168.31.225:mysql_3306]# ls
# mysqld --initialize --user=work --basedir=/home/work/mysql_3306 --datadir=/home/work/mysql_3306/data
比如:
[work@192.168.31.225:mysql_3306]# ./bin/mysqld --initialize --user=work --basedir=/home/work/mysql_3306 --datadir=/home/work/mysql_3306/data 2023-03-09T00:35:39.264213Z 0 [System] [MY-013169] [Server] /data/mysql_3306/bin/mysqld (mysqld 8.0.25-15) initializing of server in progress as process 184852 2023-03-09T00:35:39.274348Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2023-03-09T00:35:47.425879Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2023-03-09T00:36:12.110794Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !/ggTMN+W7s* [work@192.168.31.225:mysql_3306]#
启动:mysqld --defaults-file=
[work@192.168.31.225:mysql_3306]# bin/mysqld --defaults-file=/home/work/mysql_3306/conf/my.cnf & [1] 131771 [work@192.168.31.225:mysql_3306]# ps aux|grep mysqld work 131793 0.0 0.0 221940 1144 pts/2 S+ 22:19 0:00 grep --color=auto mysqld [1]+ Exit 1 bin/mysqld --defaults-file=/home/work/mysql_3306/conf/my.cnf [work@192.168.31.225:mysql_3306]#
本地socket登录:
[work@192.168.31.225:mysql_3306]# bin/mysql -P3306 -uroot -p -S /home/work/mysql_3306/tmp/mysql.sock
修改密码和创建用户(这里仅仅为了图简单方便):
mysql>ALTER USER USER() IDENTIFIED BY 'root'; mysql>CREATE USER 'root'@'%' IDENTIFIED BY 'root'; mysql>GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
install plugin group_replication soname 'group_replication.so'; install plugin rpl_semi_sync_master soname 'semisync_master.so'; install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
#########################
##########################
igoodful@qq.com