This article references: http://chenzehe.iteye.com/blog/1266260 thanks to the original author's share!
First install/Update some of the base packages that will be used at compile time
Yum-y install gcc gcc-c++ make cmake ncurses ncurses-devel libxml2 libxml2-devel openssl-devel Bison bison-devel
MARIADB Download: ftp://mirrors.fe.up.pt/pub/mariadb/mariadb-10.1.20/source/mariadb-10.1.20.tar.gz
Compile and install mariadb10.1.x version requires GCC support c++11, do not know friends can read my other article: Source installation GCC-4.9.2
1. Create a MySQL user
useradd -s /sbin/nologin -g mysql -M mysql #不允许mysql用户登录
2. Create a data storage directory
[[email protected] local]# mkdir -pv /data/dbdata
[[email protected] local]# mkdir -pv /data/innodb
[[email protected] local]#
chown -R mysql.mysql /data/ #修改目录权限为mysql
3, Installation mariadb
[Email protected] mariadb-10.1.19]#
cmake -DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DSYSCONFDIR=/usr/local/mysql-DMYSQL_TCP_PORT=3306-DEXTRA_CHARSETS=all-DMYSQL_USER=mysql-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/dbdata-DWITH_XTRADB_STORAGE_ENGINE=1-DWITH_FEDERATEDX_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STPRAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWIYH_READLINE=1-DWIYH_SSL=system-DVITH_ZLIB=system-DWITH_LOBWRAP=0-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci
[[email protected] mariadb-10.1.19]# make
[[email protected] mariadb-10.1.19]# make install
Here MARIADB has been installed, configuration can be used. I'm using a multi-instance configuration method here.
1. Initialize Data directory
#把用到的工具添加到/usr/bin Directory
Ln-s/usr/local/mysql/bin/mysqld_multi/usr/bin/mysqld_multi
Ln-s/usr/local/mysql/scripts/mysql_install_db/usr/bin/mysql_install_db
[[email protected] mysql]#
./scripts/mysql_install_db--datadir=/data/dbdata--user=mysql
2. Configure multi-instance database configuration files
A) modify the My.cnf file
[Mysqld_multi] mysqld=/usr/local/mysql/bin/Mysqld_safe mysqladmin=/usr/local/mysql/bin/mysqladmin User=MySQL # The MySQL server [mysqld6033] Port=6033#bind-address =127.0.0.1Socket=/tmp/mysql.sock.6033DataDir=/data/dbdata pid-file=/data/dbdata/my.pid Skip-external-Locking Skip-name-Resolve Interactive_timeout=86400Wait_timeout=86400Key_buffer=384M Max_allowed_packet=4M Table_cache=8192sort_buffer_size=2M read_buffer_size=2M myisam_sort_buffer_size=64M Thread_cache= +query_cache_size=64M thread_concurrency= +max_connection= Maxmax_connect_errors= -max_heap_table_size=64M Open_files_limit=2048Slow_query_log=1Long_query_time=2Slow-query-log-file=/data/dbdata/slowquery.sql Log-bin =/data/dbdata/Replication Server-ID= -#master-host =192.168.0.100#master-user =Repuser #master-password =repuser123 #master-port =6033#master-connect-retry = -Log-slave-Updates Skip-slave-Start character-set-server =UTF8 Collation_server=Utf8_general_ci Master-Info-file=/data/dbdata/master.Info# Uncomment the followingifYou is using InnoDB tables Innodb_data_home_dir=/data/InnoDB Innodb_data_file_path=ibdata1:200m;ibdata2:200m;ibdata3:200m;ibdata4:200m;ibdata5:200m Innodb_log_group_home_dir=/data/innodb/Innodb_log_arch_dir=/data/innodb/innodb_buffer_pool_size=700M innodb_additional_mem_pool_size=256M innodb_log_file_size=256M innodb_log_buffer_size=32M Innodb_flush_log_at_trx_commit=0Innodb_lock_wait_timeout= -Default_storage_engine= InnoDB
3. Start the multi-instance database
#将/usr/local/mysql/bin加到$PATH环境变量里
[[email protected] mysql]# vi /etc/profile
export PATH=/usr/local/mysql/bin:$PATH #插入到最后一行
#启动mysql
[[email protected] mysql]# mysqld_multi start 6033 –user #6033是my.cnf里设置的端口
The InnoDB will be loaded at startup and cannot be restarted in the middle, otherwise the following error will occur
151114 00:59:38 Mysqld started
151114 0:59:38 [Warning] option ' thread_stack ': Unsigned value 126976 adjusted to 131072
Innodb:no valid checkpoint found.
Innodb:if This error appears if you were creating an InnoDB database,
Innodb:the problem may be, during an earlier attempt you managed
Innodb:to Create the InnoDB data files, but log file creation failed.
Innodb:if that's the case, please refer to
Innodb:http://dev.mysql.com/doc/refman/5.0/en/error-creating-innodb.html
151114 0:59:38 [ERROR] Default storage Engine (InnoDB) is not available
151114 0:59:38 [ERROR] Aborting
151114 0:59:38 [Note]/usr/local/mysql/bin/mysqld:shutdown complete
151114 00:59:38 Mysqld Ended
Delete the InnoDB folder and restart it.
Installation Configuration mariadb-10.1.19