CentOS6.5 x86_64 System
[Email protected] ~]# wget https://downloads.mariadb.org/interstitial/mariadb-10.0.15/source/ Mariadb-10.0.15.tar.gz/from/http%3a//mirrors.neusoft.edu.cn/mariadbgroupadd-r Mysqluseradd-r-G mysql-s/sbin/ Nologin Mysqlmkdir/data/mydata{1..3}chown-r mysql:mysql/data/*
Installation
Yum-y install gcc gcc-c++ make cmake ncurses ncurses libxml2 libxml2-devel openssl-devel Bison bison-devel #依赖组件解压MariaDB SOURCE Package Tar XF mariadb CD mariadb-10.0.15/cmake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mydata-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-dmysql_unix_addr=/tmp/mysql.sock-ddefault_charset=utf8-ddefault_collation=utf8_general_cimake- J 4-j 4 means 4-core processing can quickly compile make install
Output environment variables
[Email protected] ~]# vim/etc/profile.d/mysql.shexport path= $PATH:/usr/local/mysql/bin/[[email protected] mariadb-10.0.15]#. /etc/profile.d/mysql.sh
Output header file library file man help document
Vim/etc/ld.so.conf.d/mysql.conf/usr/local/mysql/lib[[email protected] mariadb-10.0.15]# Vim/etc/man.configmanpath /usr/local/mysql/man[[email protected] mariadb-10.0.15]# man-m/usr/local/mysql/man/mysqld[[email protected] tmp]#/ usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/data/mydata1--user=mysql
Providing configuration files and startup scripts
[Email protected] mariadb-10.0.15]# Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf[[email protected] mariadb-10.0.15]# Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld[[email protected] mariadb-10.0.15]# chmod +x/etc/init.d/mysqld ^c[[email protected] mariadb-10.0.15]# chkconfig mysqld on^c[[email Protected] mariadb-10.0.15]#/etc/init.d/mysqld start then test direct input MySQL
Multi-instance configuration runs on different ports 3306,3307,3308
Configuration files such as/etc/my.cnf
[Client] #password = your_password#port = 3306#socket = /tmp/mysql.sockdefault-character-set = utf8# Here follows entries for some specific programs[mysqld_multi]mysqld = /usr/local/ mysql/bin/mysqld_safemysqladmin = /usr/local/mysql/bin/mysqladminuser = rootlog = /var/log/mysql/mysqld.multi.log#password =[mysqld1]port=3306socket=/tmp/mysql3306.sockpid-file=/tmp/mysql3306.pidmax_allowed_packet=1mnet_ buffer_length=2ktable_open_cache=4sort_buffer_size=64kthread_stack=128kbasedir=/usr/local/mysqldatadir=/data/ mydata1server-id=1[mysqld2]port=3307socket=/tmp/mysql3307.sockpid-file=/tmp/mysql3307.pidmax_allowed_packet= 1mnet_buffer_length=2kTable_open_cache=4sort_buffer_size=64kthread_stack=128kbasedir=/usr/local/mysqldatadir=/data/mydata2server-id= 1[mysqld3]port=3308socket=/tmp/mysql3308.sockpid-file=/tmp/mysql3308.pidmax_allowed_packet=1mnet_buffer_length =2ktable_open_cache=4sort_buffer_size=64kthread_stack=128kbasedir=/usr/local/mysqldatadir=/data/ Mydata3server-id=1## the mariadb server
Multi-instance management scripts
[Email protected] mariadb-10.0.15]# Cp/usr/local/mysql/support-files/mysqld_multi.server/etc/init.d/mysqld.multi [Email protected] mariadb-10.0.15]# chmod +x/etc/init.d/mysqld.multi
Modify a multi-instance script to start at the same time, close 3 instances
[[email protected] mariadb-10.0.15]# Vim/etc/init.d/mysqld.multi Edit Modify
#!/bin/sh## a simple startup script for mysqld_multi by tim smith and Jani Tolonen.# This script assumes that my.cnf file exists either in /etc/my.cnf or# /root/.my.cnf and has groups [ mysqld_multi] and [mysqldn]. see the# mysqld_multi documentation for detailed instructions.## this script can be used as /etc/init.d/ mysql.server## comments to support chkconfig on redhat linux# Chkconfig: 2345 64 36# description: a very fast and reliable sql database engine.## version 1.0#basedir=/usr/local/mysqlbindir=/usr/local/mysql/ Binconf=/etc/my.cnfexport path= $PATH: $bindirif test -x $bindir/mysqld_multithen mysqld_multi= "$bindir/mysqld_multi";else echo "Can ' t execute $bindir/mysqld_multi from dir $basedir"; exit;ficase "$" in ' start ' ) "$mysqld _multi" --defaults-extra-file= $conf start $2 ;; ' Stop ' ) ' $mysqld _multi ' -- defaults-extra-file= $conf stop $2 ;; ' report ' ] "$mysqld _multi" --defaults-extra-file= $conf report $2 ;; ' restart ' ) "$mysqld _multi" - -defaults-extra-file= $conf stop $2 "$mysqld _multi" --defaults-extra-file= $conf start $2 ;; *) echo "usage: $0 { Start|stop|report|restart} " >&2 ;; Esac
to test!
[[Email protected] mariadb-10.0.15]# /etc/init.d/mysqld.multi start 1,2,3[[email protected] mariadb-10.0.15]# netstat -antlp |grep mysqldtcp 0 0 :::3307 :::* LISTEN 20628/mysqld tcp 0 0 :::3308 :::* listen 20630/mysqld tcp 0 0 :::3306 :::* LISTEN 20619/mysqld [[email Protected] mariadb-10.0.15]# /etc/init.d/mysqld.multi stop 1,2,3[[email protected] mariadb-10.0.15]# netstat -antlp |grep mysqld
How to connect to a database
[[email protected] tmp]# mysql -s /tmp/mysql3307.sock This allows you to connect welcome to the mariadb monitor. commands end with ; Or \g.your mariadb connection id is 2server version: 10.0.15-mariadb Source distributionCopyright (c) 2000, 2014, Oracle, SkySQL Ab And others. type ' help; ' or ' \h ' for help. Type ' \c ' to clear the current input statement. mariadb [(None)]> [[email protected] tmp]# mysql -uroot -h127.0.0.1 -P3306 -p This can also connect enter password: welcome to the mariadb monitor. commands end with ; or \g.your mariadb connection id is 3server version: 10.0.15-mariadb source distributioncopyright (c) 2000, 2014, oracle, skysql ab and others. type ' help; ' or ' \h ' for help. Type ' \c ' to clear the current input statement. mariadb [(None)]>
And so on
CentOS6.5 installing MariaDB10.0.15 compilation installation and multi-instance management configuration