MariaDB10.1源码安装流程(CentOS6.5)

--安装所需软件包
[root@localhost mariadb-10.1.14]# yum install bison bison-devel ncurses libxml2 libxml2-devel

下载新版本的cmake工具
[root@localhost install]# wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz --no-check-certificate
--2016-06-17 05:21:22--  https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
Resolving cmake.org... 66.194.253.19
Connecting to cmake.org|66.194.253.19|:443... connected.
WARNING: certificate common name “*.kitware.com” doesn’t match requested host name “cmake.org”.
HTTP request sent, awaiting response... 200 OK
Length: 6863498 (6.5M) [application/x-gzip]
Saving to: “cmake-3.5.2.tar.gz”

100%[===================================================================================================================>] 6,863,498    137K/s   in 65s    
2016-06-17 05:22:35 (104 KB/s) - “cmake-3.5.2.tar.gz” saved [6863498/6863498]

[root@localhost install]# tar fxvz cmake-3.5.2.tar.gz
[root@localhost install]# cd cmake-3.5.2
[root@localhost cmake-3.5.2]# ./bootstrap

编译安装cmake3.5.2

[root@localhost cmake-3.5.2]# make
.....
[ 98%] Building C object Tests/CMakeLib/PseudoMemcheck/NoLog/CMakeFiles/pseudonl_BC.dir/ret0.c.o
[ 99%] Linking C executable BC
[ 99%] Built target pseudonl_BC
Scanning dependencies of target pseudonl_purify
[ 99%] Building C object Tests/CMakeLib/PseudoMemcheck/NoLog/CMakeFiles/pseudonl_purify.dir/ret0.c.o
[ 99%] Linking C executable purify
[ 99%] Built target pseudonl_purify
Scanning dependencies of target pseudonl_valgrind
[ 99%] Building C object Tests/CMakeLib/PseudoMemcheck/NoLog/CMakeFiles/pseudonl_valgrind.dir/ret0.c.o
[ 99%] Linking C executable valgrind
[ 99%] Built target pseudonl_valgrind
Scanning dependencies of target pseudo_emulator
[ 99%] Building C object Tests/RunCMake/CMakeFiles/pseudo_emulator.dir/pseudo_emulator.c.o
[ 99%] Linking C executable pseudo_emulator
[ 99%] Built target pseudo_emulator
Scanning dependencies of target pseudo_iwyu
[100%] Building C object Tests/RunCMake/CMakeFiles/pseudo_iwyu.dir/pseudo_iwyu.c.o
[100%] Linking C executable pseudo_iwyu
[100%] Built target pseudo_iwyu
Scanning dependencies of target foo
[100%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX static library libfoo.a
[100%] Built target foo

[root@localhost cmake-3.5.2]# make install
.....
-- Installing: /usr/local/bin/ccmake
-- Installing: /usr/local/bin/cmake
-- Installing: /usr/local/bin/ctest
-- Installing: /usr/local/bin/cpack
-- Installing: /usr/local/share/cmake-3.5/include/cmCPluginAPI.h
-- Installing: /usr/local/share/cmake-3.5/editors/vim/cmake-help.vim
-- Installing: /usr/local/share/cmake-3.5/editors/vim/cmake-indent.vim
-- Installing: /usr/local/share/cmake-3.5/editors/vim/cmake-syntax.vim
-- Installing: /usr/local/share/cmake-3.5/editors/emacs/cmake-mode.el
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/cmake-3.5/completions/cmake
-- Installing: /usr/local/share/cmake-3.5/completions/cpack
-- Installing: /usr/local/share/cmake-3.5/completions/ctest

--查看cmake的版本
[root@localhost cmake-3.5.2]# cmake --version
cmake version 3.5.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

--下载MariaDB 10.1源码包
[root@localhost install]# wget http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.1.14/source/mariadb-10.1.14.tar.gz
--2016-06-15 23:47:38--  http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.1.14/source/mariadb-10.1.14.tar.gz
Resolving mirrors.tuna.tsinghua.edu.cn... 166.111.206.63, 2402:f000:1:416:166:111:206:63
Connecting to mirrors.tuna.tsinghua.edu.cn|166.111.206.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 55341017 (53M) [application/octet-stream]
Saving to: “mariadb-10.1.14.tar.gz”

100%[===================================================================================================================>] 55,341,017   576K/s   in 64s     
2016-06-15 23:48:44 (843 KB/s) - “mariadb-10.1.14.tar.gz” saved [55341017/55341017]

[root@localhost install]# tar -zxvf mariadb-10.1.14.tar.gz
[root@localhost install]# cd mariadb-10.1.14
[root@localhost mariadb-10.1.14]# ls
BUILD           config.h.cmake      CREDITS            extra               libMySQL     mysys      README      storage        VERSION
BUILD-CMAKE     configure.cmake     dbug               include             libmysqld    mysys_ssl  scripts     strings        vio
client          COPYING             debian             INSTALL-SOURCE      libservices  pcre       sql         support-files  win
cmake           COPYING.LESSER      Docs               INSTALL-WIN-SOURCE  man          plugin     sql-bench   tests          wsrep
CMakeLists.txt  COPYING.thirdparty  EXCEPTIONS-CLIENT  KNOWN_BUGS.txt      mysql-test   randgen    sql-common  unittest       zlib

--创建MariaDB软件安装目录、数据文件和日志文件目录
[root@localhost storage]# mkdir /maria
[root@localhost storage]# mkdir -p /maria_data/cnf
[root@localhost maria_data]# mkdir -p /log/maria
[root@localhost maria_data]# chown -R mysql:mysql /log/maria/

--开始编译安装
[root@localhost mariadb-10.1.14]#cmake . -DCMAKE_INSTALL_PREFIX=/maria \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATEDX_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT='MariaDB 10.1 production environment' \
-DWITH_READLINE=ON \
-DSYSCONFDIR=/maria_data/cnf \
-DMYSQL_UNIX_ADDR=/maria_data/maria.sock \
-DMYSQL_DATADIR=/maria_data

-- Running cmake version 3.5.2
-- MariaDB 10.1.14
-- Packaging as: mariadb-10.1.14-Linux-x86_64
-- OPENSSL_INCLUDE_DIR = /usr/include
-- OPENSSL_LIBRARIES = /usr/lib64/libssl.so
-- CRYPTO_LIBRARY = /usr/lib64/libcrypto.so
-- OPENSSL_MAJOR_VERSION = 1
-- SSL_LIBRARIES = /usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl
-- Checking for one of the modules 'libsystemd;libsystemd-daemon'
-- Systemd features not enabled
-- Found LibXml2: /usr/lib64/libxml2.so (found version "2.7.6") 
-- Configuring done
-- Generating done
-- Build files have been written to: /install/mariadb-10.1.14

[root@localhost mariadb-10.1.14]#make
.....
Scanning dependencies of target bug25714
[100%] Building C object tests/CMakeFiles/bug25714.dir/bug25714.c.o
[100%] Linking CXX executable bug25714
[100%] Built target bug25714
Scanning dependencies of target mysql_client_test
[100%] Building C object tests/CMakeFiles/mysql_client_test.dir/mysql_client_test.c.o
[100%] Linking CXX executable mysql_client_test
[100%] Built target mysql_client_test
Scanning dependencies of target mysqld
[100%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
[100%] Linking CXX executable mysqld
[100%] Built target mysqld
Scanning dependencies of target udf_example
[100%] Building C object sql/CMakeFiles/udf_example.dir/udf_example.c.o
[100%] Linking C shared module udf_example.so
[100%] Built target udf_example
Scanning dependencies of target mysql_tzinfo_to_sql
[100%] Building CXX object sql/CMakeFiles/mysql_tzinfo_to_sql.dir/tztime.cc.o
[100%] Linking CXX executable mysql_tzinfo_to_sql
[100%] Built target mysql_tzinfo_to_sql
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
[100%] Linking CXX executable my_safe_process
[100%] Built target my_safe_process

[root@localhost mariadb-10.1.14]#make install
.....
-- Installing: /maria/bin/mytop
-- Installing: /maria/bin/mysqlhotcopy
-- Installing: /maria/bin/mysqldumpslow
-- Installing: /maria/bin/mysqld_multi
-- Installing: /maria/bin/mysqld_safe
-- Installing: /maria/bin/wsrep_sst_common
-- Installing: /maria/bin/wsrep_sst_mysqldump
-- Installing: /maria/bin/wsrep_sst_rsync
-- Installing: /maria/bin/wsrep_sst_xtrabackup
-- Installing: /maria/bin/wsrep_sst_xtrabackup-v2
-- Installing: /maria/share/maria_add_gis_sp.sql
-- Installing: /maria/share/maria_add_gis_sp_bootstrap.sql
-- Installing: /maria/support-files/my-huge.cnf
-- Installing: /maria/support-files/my-innodb-heavy-4G.cnf
-- Installing: /maria/support-files/my-large.cnf
-- Installing: /maria/support-files/my-medium.cnf
-- Installing: /maria/support-files/my-small.cnf
-- Installing: /maria/support-files/wsrep.cnf
-- Installing: /maria/support-files/mysqld_multi.server
-- Installing: /maria/support-files/mysql-log-rotate
-- Installing: /maria/support-files/binary-configure
-- Installing: /maria/support-files/wsrep_notify
-- Installing: /maria/support-files/magic
-- Installing: /maria/support-files/policy
-- Installing: /maria/support-files/policy/apparmor
-- Installing: /maria/support-files/policy/apparmor/usr.sbin.mysqld
-- Installing: /maria/support-files/policy/apparmor/README
-- Installing: /maria/support-files/policy/apparmor/usr.sbin.mysqld.local
-- Installing: /maria/support-files/policy/selinux
-- Installing: /maria/support-files/policy/selinux/mariadb-server.te
-- Installing: /maria/support-files/policy/selinux/README
-- Installing: /maria/support-files/policy/selinux/mariadb-server.fc
-- Installing: /maria/share/pkgconfig/mariadb.pc
-- Installing: /maria/share/aclocal/mysql.m4
-- Installing: /maria/support-files/mysql.server

--更改MariaDB数据文件的权限为mysql
[root@localhost cnf]# chown -R mysql:mysql /maria_data/

--创建MySQL数据库的系统表
[root@localhost maria]# /maria/scripts/mysql_install_db --user=mysql  --datadir=/maria_data/
.....
2016-06-17 17:37:16 139707541080032 [Note] InnoDB: Highest supported file format is Barracuda.
2016-06-17 17:37:16 139707541080032 [Note] InnoDB: 128 rollback segment(s) are active.
2016-06-17 17:37:16 139707541080032 [Note] InnoDB: Waiting for purge to start
2016-06-17 17:37:16 139707541080032 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.29-76.2 started; log sequence number 1616819
2016-06-17 17:37:16 139706685712128 [Note] InnoDB: Dumping buffer pool(s) not yet started
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
'./bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/maria_data/'

You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support/new features from MariaDB
Corporation Ab. You can contact us about this at sales@mariadb.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/

--拷贝配置文件模板到配置文件目录
[root@localhost maria]# cp ./support-files/my-medium.cnf /maria_data/cnf/my.cnf

--启动数据库
[root@localhost maria]# ./bin/mysqld_safe --defaults-file=/maria_data/cnf/my.cnf &
[1] 14633
[root@localhost maria]# 160617 18:55:09 mysqld_safe Logging to '/log/maria/err.log'.
160617 18:55:09 mysqld_safe Starting mysqld daemon with databases from /maria_data

--修改root用户密码
[root@localhost maria]# ./bin/mysqladmin -uroot password 'root'

--连接数据库
[root@localhost maria]# ./bin/mysql -uroot -p'root'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.1.14-MariaDB MariaDB 10.1 production environment

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| cnf                |
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> use test
Database changed
MariaDB [test]> show tables;
Empty set (0.00 sec)

MariaDB [test]> create table test(a int);
Query OK, 0 rows affected (0.08 sec)

MariaDB [test]> show create table test;
+-------+---------------------------------------------------------------------------------------+
| Table | Create Table                                                                          |
+-------+---------------------------------------------------------------------------------------+
| test  | CREATE TABLE `test` (
  `a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+---------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

MariaDB [test]> insert into test values(100);
Query OK, 1 row affected (0.00 sec)

MariaDB [test]> select * from test;
+------+
| a    |
+------+
|  100 |
+------+
1 row in set (0.00 sec)

MariaDB [test]> show engines;
+--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                                                          | Transactions | XA   | Savepoints |
+--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+
| MRG_MyISAM         | YES     | Collection of identical MyISAM tables                                                            | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                                                            | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                                                               | NO           | NO   | NO         |
| FEDERATED          | YES     | FederatedX pluggable storage engine                                                              | YES          | NO   | YES        |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                                        | NO           | NO   | NO         |
| Aria               | YES     | Crash-safe tables with MyISAM heritage                                                           | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                                                               | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, foreign keys and encryption for tables | YES          | YES  | YES        |
| SEQUENCE           | YES     | Generated tables filled with sequential values                                                   | YES          | NO   | YES        |
+--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

本文标题:MariaDB10.1源码安装流程(CentOS6.5)
当前路径:http://scyanting.com/article/pspsii.html