Kylin v10 源码安装MySQL-5.7
背景
在银河麒麟 v10 ARM64环境下,没有官方正式的RPM包。所以需要用到最为原始源代码安装方式。
环境
- OS: Kylin v10 SP2
- MySQL: 5.7.43
- Platform: Arm64
安装记录
安装前准备
1、安装依赖包
yum install gcc gcc-c++ cmake ncurses-devel bison openssl-devel
2、下载软件包
# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.43.tar.gz
# wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4.4/rpcsvc-proto-1.4.4.tar.xz
3、创建Mysql 用户
groupadd mysql -g 8848
useradd -r -g mysql mysql -u 8848
4、创建对应目录
mkdir -p /data/mysql/{data,logs}
chown mysql.mysql /data/mysql -R
安装rpcsvc-proto
1、三步曲安装
tar axvf rpcsvc-proto-1.4.4.tar.xz
cd rpcsvc-proto-1.4.4
./configure && make -j$(nproc --all) && make install
安装 MySQL
1、解压MySQL
tar axvf mysql-boost-5.7.43.tar.gz
cd mysql-5.7.4
2、配置安装
# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DENABLE_DOWNLOADS=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_BOOST=${PWD}/boost
# make -j(nproc --all) && make install
3、创建配置文件
cat >/etc/my.cnf<<EOF
[mysqld]
datadir = /data/mysql/data
basedir = /usr/local/mysql
socket = /tmp/mysql.sock
user = mysql
port = 3306
character-set-server = utf8
sql_mode = NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
character_set_server = UTF8
collation_server = utf8_general_ci
skip_name_resolve = true
symbolic-links = 0
[mysqld_safe]
log-error = /data/mysql/logs/mysqld.log
[client]
port = 3306
socket = /tmp/mysql.sock
EOF
4、添加环境变量
cat >/etc/profile.d/mysql.sh<<EOF
export MYSQL_HOME=/usr/local/mysql
export PATH=\$PATH:\$MYSQL_HOME/bin
EOF
source /etc/profile
6、初始化数据
mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql
7、创建服务
cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/usr/lib/systemd/systemd-sysv-install enable mysqld
systemctl enable mysqld
systemctl start mysqld
8、首次修改密码
> alter user 'root'@'localhost' identified by 'VQIU!8848';
9、开启远程登陆
> grant all privileges on *.* to 'root'@'%' identified by 'VQIU!8848';
10、若需要在Kubernetes上使用service访问,创建如下资源:
export HOST=IP地址
export PORT=3306
export NS=vqiu
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Endpoints
metadata:
name: vqiu-mysql
namespace: ${NS}
subsets:
- addresses:
- ip: ${HOST}
ports:
- name: mysql
port: ${PORT}
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: vqiu-mysql
namespace: ${NS}
labels:
role: database
name: mysql
spec:
ports:
- name: mysql
port: ${PORT}
targetPort: ${PORT}
protocol: TCP
type: ClusterIP
clusterIP: None
EOF