mysql衍生版本 Percona-mysql。
安装方式以yum网络安装,源码编译安装,二进制文件直接配置使用。
系统:centos7
mysql版本:5.7
源码编译安装
-
系统优化
参考系统配置优化 -
准备环境依赖
useradd -s /sbin/nologin -M mysql
mkdir -p /opt/mysql/etc /data/mysql/data
chown -R mysql:mysql /data/mysql
###可yum安装的环境依赖包
yum -y install readline-devel gcc gcc-c++ boost make cmake bison bison-devel ncurses-devel libaio-devel perl git libtirpc libtirpc-devel
###boost(5.7版本仅支持1.59版本boost)
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz -p /tmp
cd /tmp && tar xvzf boost_1_59_0.tar.gz -C /usr/local/
cd /usr/local/boost_1_59_0
sh ./bootstrap.sh
./b2 stage threading=multi link=shared
./b2 install threading=multi link=shared --prefix=/usr/local
- 下载源代码软件
wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.27-30/source/tarball/percona-server-5.7.27-30.tar.gz -P /tmp
- 安装程序
### 解压程序包
cd /tmp && tar zxvf percona-server-5.7.27-30.tar.gz
### 编译编代码并安装(程序文件 /opt/mysql , 数据文件 /data/mysql/data/)
cd percona-server-5.7.27-30
cmake .
-DCMAKE_INSTALL_PREFIX=/opt/mysql
-DMYSQL_DATADIR=/data/mysql/data
-DSYSCONFDIR=/opt/mysql/etc
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DWITH_BOOST=/usr/local/boost_1_59_0
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_EDITLINE=0
-DENABLED_LOCAL_INFILE=1
-DENABLE_DOWNLOADS=1
mkdir source_downloads
wget https://codeload.github.com/google/googletest/zip/release-1.8.0
mv release-1.8.0 source_downloads/release-1.8.0.zip
make -j 4
make install
- 添加配置文件
rm -rf /etc/my.cnf*
cat << EOF > /opt/mysql/etc/my.cnf
[client]
port = 3306
socket = /data/mysql/mysql.sock
[mysqld_safe]
pid-file = /data/mysql/mysql.pid
socket = /data/mysql/mysql.sock
nice = 0
[mysqld]
server-id = 1
user = mysql
pid-file = /data/mysql/mysql.pid
socket = /data/mysql/mysql.sock
port = 3306
basedir = /opt/mysql
datadir = /data/mysql/data
log-error = /data/mysql/mysql.log
lower_case_table_names = 1
skip-name-resolve
log-bin=mysql-bin
expire_logs_days = 3
binlog_format=mixed
explicit_defaults_for_timestamp = true
innodb_data_file_path = ibdata1:10M:autoextend:max:2048M
innodb_file_per_table = 1
[mysql]
auto-rehash
EOF
- 初始化数据库
/opt/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/data/mysql/data
- 增加命令文件
ln -s /opt/mysql/bin/mysql /usr/sbin/
- 启动程序
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
sed -i 's|conf=/etc/my.cnf|conf=/opt/mysql/etc/my.cnf|g' /etc/init.d/mysqld
/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/etc/my.cnf &
- 无密码登录数据库及增加管理账户(仅配置管理账户密码前使用)
/opt/mysql/bin/mysql -S /data/mysql/mysql.sock
###消除密码复杂策略
> set global validate_password_policy=0;
> set global validate_password_length=0;
> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' ;
> flush privileges;
- 创建全局管理用户
mysql -uroot -p
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION ;
> flush privileges;