percona-mysql5.7_安裝-2(源碼編譯)

mysql衍生版本 Percona-mysql。 安裝方式以yum網絡安裝,源碼編譯安裝,二進制文件直接配置使用。 系統:centos7 mysql版本:5.7mysql


源碼編譯安裝

  • 系統優化 參考系統配置優化c++

  • 準備環境依賴git

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;
相關文章
相關標籤/搜索