股票代码:000034.SZ
Mysql迁移到UOS
发布日期:2020-07-07
分享到:

1.软件介绍

2.环境要求

3.支持的操作系统

4.使用版本和获取方式

5.编译和测试方式

1)添加apt-get 安装源

2)安装相关编译包

3)解压mysql

4)配置cmake编译及相关参数

5)cmake后在下面这个路径的这个文件CMakeLists.txt增加如下这部分字段

6)获取服务器CPU核心数

7)遇到的报错的处理

 

1.软件介绍

MySQL 是一个关系型数据库管理系统。

 

2.环境要求

本文以 MySQL 5.7.30 版本

虚拟服务器 KVM Virtual Machine

虚拟机配置:32G内存,8核 aarch64架构 virt-rhel7.6.0 300G磁盘空间

虚拟机操作系统:Linux version 4.19.0-arm64-server (deepin@deepin-PC) (gcc version 8.3.0 (Debian 8.3.0-6))

 

3.支持的操作系统

UOS : Linux version 4.19.0-arm64-server (deepin@deepin-PC) (gcc version 8.3.0 (Debian 8.3.0-6))

 

4.使用版本和获取方式

mysql-5.7.30.tar.gz

https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.30.tar.gz

mysql-boost-5.7.30.tar.gz

https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.30.tar.gz

安装包放在/home/demo/tools/

 

5.编译和测试方式

1)添加apt-get 安装源

vi /etc/apt/sources.list

输入

## Generated by deepin-installer

deb [by-hash=force] https://packages.chinauos.cn/uos eagle main contrib non-free

#deb-src https://packages.chinauos.cn/uos eagle main contrib non-free

deb http://ftp.cn.debian.org/debian stretch main

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

关闭保存

2)安装相关编译包

sudo apt-get update

sudo apt-get install -y cmake

sudo apt-get install -y git

sudo apt-get install -y build-essential

sudo apt-get install -y openssl

sudo apt-get install -y libssl-doc(这个可能不需要装)

sudo apt-get install aptitude

aptitude安装不上的话 刷新下源

apt-get update

apt-get dist-upgrade

sudo aptitude install -y libssl-dev

sudo aptitude install -y libncurses5-dev

sudo aptitude install -y libncurses5

sudo aptitude install -y pkg-config

sudo aptitude install -y bison

sudo aptitude install -y libtirpc1

sudo aptitude install -y libtirpc-dev

sudo apt-get install -y chkconfig

3)解压mysql

mkdir -p /home/demo/tools/

cd /home/demo/tools/

tar zxvf mysql-5.7.30.tar.gz

tar zxvf mysql-boost-5.7.30.tar.gz

4)配置cmake编译及相关参数

cd mysql-5.7.30/

vi CMakeLists.txt

在文件开头

option(ENABLE_PIC "Generate position independent code (necessary for shared libraries)" TRUE)

set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_PIC})

保存CMakeLists.txt

cmake -DCMAKE_INSTALL_PREFIX=/application/mysql -DMYSQL_DATADIR=/application/mysql/data -DMYSQL_UNIX_ADDR=/application/mysql/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost

5)cmake后在下面这个路径的这个文件CMakeLists.txt增加如下这部分字段

vi /home/demo/tools/mysql-5.7.30/storage/innobase/CMakeLists.txt

fts/fts0fts.cc

handler/handler0alter.cc

row/row0mysql.cc

srv/srv0srv.cc

在这个文件 /home/demo/tools/mysql-5.7.30/sql/mysqld.cc 注释掉

6)获取服务器CPU核心数

cat /proc/cpuinfo | grep processor |wc -l

执行make编译 此处的8是上面CPU核心数命令的返回值 代表用几核编译 提高速度

make -j 8 && make install

7)遇到的报错的处理

20%] Built target mysys_ssl

[ 20%] Building C object extra/CMakeFiles/comp_err.dir/comp_err.c.o

[ 20%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_message.cc.o

[ 20%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_message_fiel

[ 20%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_name_resolve

[ 20%] Linking CXX executable comp_err

/usr/bin/ld: CMakeFiles/comp_err.dir/comp_err.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `stderr@@GLIBC_2.17' which maused when making a shared object; recompile with -fPIC

/usr/bin/ld: CMakeFiles/comp_err.dir/comp_err.c.o(.text+0x7c): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `std

/usr/bin/ld: 最后的链结失败: bad value

collect2: error: ld returned 1 exit status

make[2]: *** [extra/CMakeFiles/comp_err.dir/build.make:105:extra/comp_err] 错误 1

make[1]: *** [CMakeFiles/Makefile2:6738:extra/CMakeFiles/comp_err.dir/all] 错误 2

make[1]: *** 正在等待未完成的任务....

解决:

CMakeLists.txt 是mysql源码根目录下的

vi CMakeLists.txt文件开头 option(ENABLE_PIC "Generate position independent code (necessary for shared libraries)" TRUE)set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_PIC})

XML 地图 | Sitemap 地图