本文参考华为鲲鹏社区相关文档完成
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源
代码语言:javascript复制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
代码语言:javascript复制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
代码语言:javascript复制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是否升级成功
代码语言:javascript复制cd /usr/lib64
ll |grep libstdc .so
5、源码编译升级MySQL
下载MySQL 5.7.31版本的源码包
yum install openssl-devel.aarch64
代码语言:javascript复制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
代码语言:javascript复制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
代码语言:javascript复制chmod x cmake.sh
./cmake.sh
make -j1
make install
编译安装出现如下报错时的解决方法
代码语言:javascript复制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相关目录并修改目录属主
代码语言:javascript复制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配置文件
代码语言:javascript复制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服务
代码语言:javascript复制cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start
4、环境变量配置
代码语言:javascript复制vi /etc/profile
export PATH=/data/mysql/bin:$PATH
source /etc/profile
5、登录MySQL,并修改root用户密码以及新建mysql用户
代码语言:javascript复制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;