环境信息:openEuler 22.03 (LTS-SP3) 。 aarch64架构环境。 (项目需求需要在此安装mysql 8.0.25)
#mysql-8.0.25-1.el7.aarch64.rpm-bundle.tar 。 安装rpm包会报错依赖,暂时不理会。
#老问题,el7的东西 ,并不完全适配 oe2203sp3.aarch64.xx 下。
#1 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service
#2 创建mysql用户组和用户
groupadd mysql
useradd -g mysql mysql
passwd mysql
#搭建数据盘(略),
#3 创建数据目录
mkdir -p /data/mysql
cd /data/mysql
mkdir data tmp run log relaylog
chown -R mysql:mysql /data
#4 配置yum源
cat /etc/yum.repos.d/openEuler.repo
#mount /root/openEuler-22.03-LTS-SP1-everything-aarch64-dvd.iso /mnt
yum clean all
yum makecache
yum list
#5 安装依赖包
yum -y install bison bison-devel ncurses ncurses-devel libaio-devel openssl openssl-devel gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel libcurl-devel
yum -y install wget tar gcc gcc-c++ git rpcgen cmake make
yum -y install numactl numactl-devel*
yum -y install libtirpc libtirpc-devel m4
cat /etc/yum.repos.d/openEuler.repo
[OS]
name=OS
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/OS/$basearch/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever/OS&arch=$basearch
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/OS/$basearch/RPM-GPG-KEY-openEuler
[everything]
name=everything
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/everything/$basearch/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever/everything&arch=$basearch
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/everything/$basearch/RPM-GPG-KEY-openEuler
[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/EPOL/main/$basearch/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever/EPOL/main&arch=$basearch
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/OS/$basearch/RPM-GPG-KEY-openEuler
[debuginfo]
name=debuginfo
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/debuginfo/$basearch/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever/debuginfo&arch=$basearch
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/debuginfo/$basearch/RPM-GPG-KEY-openEuler
[source]
name=source
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/source/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever&arch=source
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/source/RPM-GPG-KEY-openEuler
[update]
name=update
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/update/$basearch/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever/update&arch=$basearch
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/OS/$basearch/RPM-GPG-KEY-openEuler
[update-source]
name=update-source
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/update/source/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever/update&arch=source
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/source/RPM-GPG-KEY-openEuler
mysql源码包下载地址:https://downloads.mysql.com/archives/community/
#(重点!) 编译mysql ,需要升级CMake版本至3.4.3或以上。和升级GCC版本至5.3.0或者以上
#这里的openEuler 2203均符合要求。不需要升级安装cmake、GCC。
#6 编译安装mysql 8.0.25
[root@openEuler2203SP3 ~]# cmake --version
cmake version 3.22.0
[root@openEuler2203SP3 ~]# gcc -v
gcc version 10.3.1 (gcc for openEuler 2.3.6)
cd /home
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-8.0.25.tar.gz --no-check-certificate
tar -zxvf mysql-boost-8.0.25.tar.gz
cd mysql-8.0.25/
mkdir build
cd build
cmake .. -DBUILD_CONFIG=mysql_release -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DWITH_BOOST=/home/mysql-8.0.25/boost/boost_1_73_0
make -j 16 && make -j 16 install
###
ls /usr/local/mysql/
/usr/local/mysql/bin/mysql --version
预期结果:/usr/local/mysql/bin/mysql Ver 8.0.25 for Linux on aarch64 (Source distribution)
cmake对应参数的解释:
# 7 运行mysql
### 7.1 编写 /etc/my.cnf
cat /etc/my.cnf
[mysqld_safe]
log-error=/data/mysql/log/mysql.log
pid-file=/data/mysql/run/mysqld.pid
[mysqldump]
quick
[mysql]
no-auto-rehash
[client]
default-character-set=utf8
[mysqld]
basedir=/usr/local/mysql
socket=/data/mysql/run/mysql.sock
tmpdir=/data/mysql/tmp
datadir=/data/mysql/data
default_authentication_plugin=mysql_native_password
port=3306
user=mysql
### 7.2 文件授权、 加入service服务。 配置环境变量
chown mysql:mysql /etc/my.cnf
chmod 777 /usr/local/mysql/support-files/mysql.server
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
chown -R mysql:mysql /etc/init.d/mysql
echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile
source /etc/profile
###7.3 修改数据目录权限 。 初始化数据库的数据目录
chmod 755 /data/mysql/data/
su - mysql
#初始化后,注意查看生成的临时密码。
mysqld --defaults-file=/etc/my.cnf --initialize
#初始化完成后,查看数据目录下数据文件“/data/mysql/data”的用户组和用户权限为mysql:mysql(因为前面/etc/my.cnf文件中配置的操作系统用户是user=mysql)。
ll /data/mysql/data
### 7.4 启动数据库
#说明:如果以root用户(su - root)第一次启动数据库服务(service mysql start),
#则启动时会提示缺少mysql.log文件而导致失败。切换到mysql用户(su - mysql)启动数据库服务后,
#会在/data/mysql/log目录下生成mysql.log文件,停止数据库服务(service mysql stop),再次以root用户启动数据库服务则不会报错。
service mysql start
#或者 mysqld --defaults-file=/etc/my.cnf &
ps -ef | grep mysql
### 7.5 登录数据库 (输入刚才初始化时,出现的临时密码。)
mysql -uroot -p -S /data/mysql/run/mysql.sock
#配置数据库账号密码。创建全域root用户(允许root从其他服务器访问)。
alter user 'root'@'localhost' identified by "123456";
create user 'root'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%';
flush privileges;
#关闭数据库(可略)
service mysql stop
mysqladmin -uroot -p123456 shutdown -S /data/mysql/run/mysql.sock
初始化数据库的临时密码 (demo图):
本文参考:(下面链接部署的是 mysql 8.0.17版本)
https://www.hikunpeng.com/document/detail/zh/kunpengdbs/ecosystemEnable/MySQL/kunpengmysql8017_02_0003.html
### 额外事项
### 升级安装CMake (版本3.5.2)。
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz --no-check-certificate
tar -zxvf cmake-3.5.2.tar.gz
cd cmake-3.5.2
./bootstrap
make -j 16 && make install
hash -r
/usr/local/bin/cmake --version
### 升级安装GCC (版本7.3.0)。
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz --no-check-certificate
tar -xvf gcc-7.3.0.tar.gz
cd gcc-7.3.0/
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-bootstrap
#如果配置报错提示“configure: error: no acceptable C compiler found in $PATH”,则执行以下命令。
#yum -y reinstall gcc gcc-c++
make -j 16 && make -j 16 install
gcc -v
END