ARM服务器上源码编译安装MySQL5.7.21过程

1.安装环境:arm架构centos7.4操作系统

2.下载安装boost(如果源码包中没有boost)

  (1)下载boost:http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

  (2)创建boost的安装目录:

$: mkdir  /usr/local/boost

  (3)解压编译并安装

$: tar -xvzf boost_1_59_0.tar.gz  -C  /usr/local/boost
$: cd /usr/local/boost
$: ./bootstrap.sh
$: ./b2
$: ./b2 --prefix=/usr/local/boost install

 #: bootstrap.sh是用来检查安装环境的,如果报错了,看一下是缺少了什么,安装一下即可。

   #:b2是上一步成功后生成的,使用它来进行构建boost库。

3、下载MySQL源码包编译安装

(1)MySQL下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.21.tar.gz

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

(2)创建MySQL安装目录

$: mkdir /usr/local/mysql
$: mkdir /usr/local/mysql/data
$: useradd mysql
$: chown -R mysql:mysql /usr/local/mysql/

(3)安装MySQL编译所依赖的环境

$:yum install make cmake gcc gcc-c++ bison bison-devel ncurses ncurses-devel autoconf automake
$:yum -y install ncurses-devel libaio-devel bison perl-Time-HiRes
$:yum install libatomic

(4)编译MySQL

$:tar -xvf mysql-5.7.19.tar.gz
$:cd mysql-5.7.19
$:CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=6603 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_BOOST=boost
$:make j8
$:make install

编译之前还需干两件事:

《1》更换编辑器

下载gcc7.3.0版本,编译并安装(方法见另一博客),系统自带的gcc版本在编译过程中会报编译器内部错误,更换gcc版本后编译通过。

报错信息如下:

/root/mysql-5.7.19/storage/innobase/fts/fts0fts.cc: In function ‘dberr_t fts_sync_index(fts_sync_t*, fts_index_cache_t*)’:

/root/mysql-5.7.19/storage/innobase/fts/fts0fts.cc:4466:1: error: could not split insn

 }

 ^

(insn 737 2253 2259 (parallel [

            (set (reg:DI 0 x0 [orig:150 D.107908 ] [150])

                (plus:DI (mem/v:DI (reg/f:DI 19 x19 [orig:98 D.107919 ] [98]) [-1  S8 A64])

                    (const_int 536870912 [0x20000000])))

            (set (mem/v:DI (reg/f:DI 19 x19 [orig:98 D.107919 ] [98]) [-1  S8 A64])

                (unspec_volatile:DI [

                        (mem/v:DI (reg/f:DI 19 x19 [orig:98 D.107919 ] [98]) [-1  S8 A64])

                        (const_int 536870912 [0x20000000])

                        (const_int 5 [0x5])

                    ] UNSPECV_ATOMIC_OP))

            (clobber (reg:CC 66 cc))

            (clobber (reg:SI 1 x1))

        ]) /root/mysql-5.7.19/storage/innobase/include/sync0rw.ic:309 1856 {atomic_add_fetchdi}

     (expr_list:REG_UNUSED (reg:CC 66 cc)

        (expr_list:REG_UNUSED (reg:SI 1 x1)

            (nil))))

/root/mysql-5.7.19/storage/innobase/fts/fts0fts.cc:4466:1: internal compiler error: in final_scan_insn, at final.c:2897

Please submit a full bug report,

with preprocessed source if appropriate.

See for instructions.

意思是说编辑器内部错误,因此更换编辑器。

《2》更换gcc的lib库

如果不更换lib库会报如下错误:

[ 70%] Running C++ protocol buffer compiler (lite) on /root/mysql-5.7.19/rapid/plugin/x/protocol/mysqlx.proto

../../../extra/protobuf/protoc: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ../../../extra/protobuf/protoc)

../../../extra/protobuf/protoc: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ../../../extra/protobuf/protoc)

make[2]: *** [rapid/plugin/x/generated/protobuf_lite/mysqlx.pb.cc] Error 1

make[1]: *** [rapid/plugin/x/CMakeFiles/mysqlx.dir/all] Error 2

make: *** [all] Error 2

然而GLIBCXX_***是gcc编译的产物,我们只需找到原来系统自带版本的gcc的lib库替换掉就可以,方法如下:

$:locate libstdc++.so.6
    /root/libstdc++.so.6
    /usr/lib64/libstdc++.so.6
    /usr/lib64/libstdc++.so.6.0.19
    /usr/local/gcc/gcc-7.3.0/gcc-build-7.3.0/aarch64-unknown-linux-gnu/libstdc++-        v3/src/.libs/libstdc++.so.6
    /usr/local/gcc/gcc-7.3.0/gcc-build-7.3.0/aarch64-unknown-linux-gnu/libstdc++-        v3/src/.libs/libstdc++.so.6.0.24
    /usr/local/gcc/gcc-7.3.0/gcc-build-7.3.0/prev-aarch64-unknown-linux-gnu/libstdc++-    v3/src/.libs/libstdc++.so.6
    /usr/local/gcc/gcc-7.3.0/gcc-build-7.3.0/prev-aarch64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.24
    /usr/local/gcc/gcc-7.3.0/gcc-build-7.3.0/stage1-aarch64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
    /usr/local/gcc/gcc-7.3.0/gcc-build-7.3.0/stage1-aarch64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.24
    /usr/local/lib64/libstdc++.so.6
    /usr/local/lib64/libstdc++.so.6.0.24
    /usr/local/lib64/libstdc++.so.6.0.24-gdb.py
    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
$:strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
.
.
.
GLIBCXX_DEBUG_MESSAGE_LENGTH
/*当前没有我们需要GLIBCXX版本号,在/usr/local/lib64/libstdc++.so.6就是我们编译gcc7.3.0的产物*/
$:find / -name "libstdc++.so*"
/*这也可以找到我们编译gcc的lib产物*/
$: cd /usr/lib64
$: cp libstdc++.so.6 ~/
$: rm -rf libstdc++.so.6
$: cp  /usr/local/lib64/libstdc++.so.6 ./

做完这些就只需要耐心等待编译完成!!!

(5)修改MySQL的配置文件my.cnf

$:cd /usr/local/mysle
$: touch my.cnf
$: chown -R mysql:mysql my.cnf

文件内容:

[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
#character_set_server=utf8
#init_connect='SET NAMES utf8'
basedir=/usr/local/mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mysqld/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

************************************************************************************************************************

根据配置文件的内容创建mysqld.log和mysqld.pid文件

$: mkdir /var/run/mysqld
$: mkdir /var/log/mysqld
$: cd /var/run/mysqld
$: touch mysqld.pid
$: cd /var/log/mysqld
$: touch mysqld.log

$: chown -R mysql:mysql /var/log/mysqld
$: chown -R mysql:mysql /var/run/mysqld

6、创建数据库

$;/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
输出:
2018-07-24T08:38:48.158741Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprected. Please use --explicit_defaults_for_timestamp server option (see documentation for ore details).
2018-07-24T08:38:52.898624Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-07-24T08:38:53.814092Z 0 [Warning] InnoDB: Creating foreign key constraint system ables.
2018-07-24T08:38:54.073175Z 0 [Warning] No existing UUID has been found, so we assume tat this is the first time that this server has been started. Generating a new UUID: ff5c74c-8f1c-11e8-873a-8cfdf0088053.
2018-07-24T08:38:54.111578Z 0 [Warning] Gtid table is not ready to be used. Table 'mysq.gtid_executed' cannot be opened.
2018-07-24T08:38:54.113556Z 1 [Note] A temporary password is generated for root@localhot: 4Mzoz

2018-07-24T08:38:54.113556Z 1 [Note] A temporary password is generated for root@localhot: 4Mzoz

标红的就是初次启动数据库的初始密码。

7、进入MySQL安装目录,启动MySQL数据库

$: ./support-files/mysql.server start

报错1:

Starting MySQL.2018-07-24T08:39:49.551572Z mysqld_safe error: log-error set to '/var/log/mysqld/mysqld.log', however file don't exists. Create writable for user 'mysql'.
 ERROR! The server quit without updating PID file (/usr/local/mysql/localhost.localdomain.pid).

处理:

 原因是my.cnf中的data数据目录配置错误,修改后启动成功!

8.MySQL数据库启动成功后,登录测试修改密码,初始密码为生成数据库时系统分配的密码。

[root@aarch64vm-centos74-010 mysql]# ./bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password = "smartcore" ;
Query OK, 0 rows affected (0.02 sec)

mysql> create database oozie;
Query OK, 1 row affected (0.02 sec)

mysql>  show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| oozie              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.04 sec)

mysql> grant all privileges on oozie.* to oozie@'%' identified by 'oozie';
Query OK, 0 rows affected, 1 warning (0.02 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[root@aarch64vm-centos74-010 mysql]# 

 

 

你可能感兴趣的:(ARM服务器上源码编译安装MySQL5.7.21过程)