?本文參考華為鯤鵬社區相關文檔完成
https://www.huaweicloud.com/kunpeng/
系統為aarch64位的centos AltArch系統
1、準備如下cmake gcc相關源碼包
cmake
https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz
gcc
https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
gcc所需的依賴包
https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
https://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
2、配置CentOS-AltArch-7 華為云yum源
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-AltArch-7.repo
sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
3、檢查是否有安裝cmake
下載cmake源碼包
下載地址 https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz
編譯cmake
cp /home/cmake-3.9.2.tar.gz /usr/local/src
cd /usr/local/src
tar -zxf cmake-3.9.2.tar.gz
cd cmake-3.9.2
./configure
make && make install
測試cmake是否安裝完成 cmake -version
4、升級gcc
gcc --version
yum install bison* ncurses*
cd /home
tar -zxf gcc-7.3.0.tar.gz
cd gcc-build-7.3.0/
./contrib/download_prerequisites
#下載isl、gmp、mpc、mpfr的依賴包上傳至該目錄下
cat /proc/cpuinfo| grep "processor"| wc -l #查看當前CPU核心數,make編譯時“-j”參數可利用多核CPU加快編譯速度
cd /home/gcc-7.3.0
mkdir gcc-build-7.3.0
cd gcc-build-7.3.0
../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr
make -j1 #只有一核,若有多核,修改為對應核心數加快編譯速度
make install
驗證gcc是否升級成功
cd /usr/lib64
ll |grep libstdc++.so
5、源碼編譯升級MySQL
下載MySQL 5.7.31版本的源碼包
yum install openssl-devel.aarch64
yum install openssl-devel.aarch64
http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
下載補丁文件,并放置到mysql-5.7.x路徑下
補丁下載路徑:https://bugs.mysql.com/file.php?id=28180&bug_id=94699
tar -zxf mysql-boost-5.7.31.tar.gz -C /home
cd /home
cp 0001-Bug-94699-Mysql-deadlock-and-bugcheck-on-aarch64.patch mysql-5.7.31/
cd mysql-5.7.31/
patch -p1 < 0001-Bug-94699-Mysql-deadlock-and-bugcheck-on-aarch64.patch
vim cmake.sh
#添加如下行
-DWITH_BOOST=的路徑為實際boost所在路徑
cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql
-DMYSQL_DATADIR=/data/mysql/data
-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
-DDOWNLOAD_BOOST=1
-DWITH_BOOST=/home/mysql-5.7.31/boost/boost_1_59_0/
#若在預編譯時出現依賴包不全的情況,可自行查閱資料安裝依賴包,并重新預編譯。重新預編譯前,需要執行rm -rf CMakeCache.txt
chmod +x cmake.sh
./cmake.sh
make -j1
make install
編譯安裝出現如下報錯時的解決方法
cp /usr/include/sys/prctl.h /home/mysql-5.7.31/include/
vi /home/mysql-5.7.31/sql/mysqld.cc 添加如下圖所示一行
6、編譯完成啟動并配置MySQL
1、創建mysql用戶,MySQL相關目錄并修改目錄屬主
cd /data/
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql mysql
cd mysql
mkdir data run log
bin/mysqld --initialize --basedir=/data/mysql --datadir=/data/mysql/data --user=mysql
touch /data/mysql/log/mysql.log
touch /data/mysql/run/mysql.pid
chown -R mysql:mysql log run
2、配置my.cnf配置文件
vi /etc/my.cnf
[mysqld]
datadir=/data/mysql/data/
socket=/data/mysql/mysql.sock
[mysqld_safe]
log-error=/data/mysql/log/mysql.log
pid-file=/data/mysql/run/mysql.pid
3、啟動MySQL服務
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start
4、環境變量配置
vi /etc/profile
export PATH=/data/mysql/bin:$PATH
source /etc/profile
5、登錄MySQL,并修改root用戶密碼以及新建mysql用戶
ln -s /data/mysql/mysql.sock /tmp/mysql.sock
mysql -uroot -p
SET PASSword = PASSWORD('MySQL@2019');
UPDATE mysql.user SET authentication_string =PASSWORD('MySQL@2019') WHERE User='mysql';
GRANT ALL PRIVILEGES ON *.* TO mysql@localhost IDENTIFIED BY 'MySQL@2019' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO mysql@"%" IDENTIFIED BY 'MySQL@2019' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'MySQL@2019' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'MySQL@2019' WITH GRANT OPTION;