1. Compile and install CMake
# tar zxf cmake-3.5.2.tar.gz#./configure# Gmake # Gmake Install
3. Compile and install MySQL
#useradd mysql-s/sbin/nologin-m # yum install ncurses-devel-y# yum install libaio-devel-y# tar xvf mysql-5.5.49.tar.g z# CD mysql-5.5.49
CMake. -dcmake_install_prefix=/usr/local/mysql-5.5.49-dextra_charsets=gbk,gb2312,utf8,ascii-denabled_local_infile=on- Dwith_innobase_storage_engine=1-dwith_federated_storage_engine=1-dwith_blackhole_storage_engine=1-dwithout_ Example_storage_engine=1-dwithout_partition_storage_engine=1-dwith_fast_mutexes=1-dwith_zlib=bundled-denabled_ Local_infile=1-dwith_readline=1-dwith_embedded_server=1-dwith_debug=0
# make# make install# ln-s/usr/local/mysql-5.5.49/usr/local/mysql# echo ' export path=/usr/local/mysql/bin/: $PATH ' > >/etc/profile# tail-l/etc/profile# source/etc/profile# Echo $PATH
4. Create a multi-instance data Catalog
Take two instances as an example
# mkdir-p/data/{3306,3307}/data# tree/data//data/|--3306| '--data '--3307 '--data
5. Set the first instance configuration file
# vi /data/3306/my.cnf[client]port = 3306socket = /data/3306/mysql.sock[mysql] no-auto-rehash[mysqld]user = mysqlport = 3306socket = /data/3306/ mysql.sockbasedir = /usr/local/mysqldatadir = /data/3306/dataopen_files_limit = 1024back_log = 600max_connections = 800max_connect_errors = 3000table_cache = 614external-locking = FALSEmax_allowed_packet =8Msort_buffer_size = 1mjoin_buffer_size = 1mthread_cache_size = 100thread_concurrency = 2query_cache_ size = 2mquery_cache_limit = 1mquery_cache_min_res_unit = 2kthread_stack = 192ktmp_table_size = 2mmax_heap_table_size = 2mlong_query_time = 1pid-file = /data/3306/mysql.pidlog-bin = /data/3306/mysql-binrelay-log = /data/3306/ relay-binrelay-log-info-file = /data/3306/relay-log.infobinlog_cache_size = 1mmax_binlog_cache_size = 1mmax_binlog_size = 2Mexpire_logs_days = 7key_buffer_size = 16Mread_buffer_size = 1mread_rnd_buffer_size = 1mbulk_insert_buffer_size = 1mlower_case_table_names = 1skip-name-resolveslave-skip-errors = 1032,1062replicate-ignore-db=mysqlserver-id = 1innodb_additional_mem_pool_size = 4minnodb_buffer_pool_size = 32minnodb_data_file_path = ibdata1:128M:autoextendinnodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 2minnodb_log_file_size = 4minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_ timeout = 120innodb_file_per_table = 0[mysqldump]quickmax_allowed_packet = 2m[ mysqld_safe]log-error=/data/3306/mYsql_3306.errpid-file=/data/3306/mysqld.pid
6. Set the startup text
vi /data/3306/mysqld#!/bin/shport=3306mysql_user= "root" mysql_pwd= "cmdpath="/application/usr/local/mysql/ Bin "mysql_sock="/data/${port}/mysql.sock "#startup functionfunction_start_mysql () { if [ ! -e "$mysql _sock" ];then printf "starting mysql...\n" /bin/sh ${cmdpath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2 >&1 > /dev/null & else printf "mysql is running...\n " exit fi} #stop functionfunction_stop_mysql () { if [ ! -e "$mysql _sock" ];then printf " mysql is stopped...\n " exit else printf "stoping mysql...\n" ${cmdpath}/mysqladmin -u ${ Mysql_user} -p${mysql_PWD} -S /DATA/${PORT}/MYSQL.SOCK SHUTDOWN   FI} #restart functionfunction_ Restart_mysql () { printf "restarting mysql...\n" function_stop_mysql sleep 2 function_start_mysql}case $1 instart) function_start_mysql;; Stop) function_stop_mysql;; Restart) function_restart_mysql;; *) printf "usage: /data/${port}/mysql {start|stop|restart}\n" esac# chown - R mysql.mysql /data/# chmod +x mysqld
7. Initializing the database
#/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/data/3306/data/--user=mysql
8. Start the database
#/data/3306/mysqld Start
9. Log in to the database
# mysql-s/data/3306/mysql.sock
10. Configure a second instance
# cp/data/3306/my.cnf/data/3307/my.cnf# Cp/data/3306/mysqld/data/3307/mysqld//server-id changed to 2server-id = Sed-i ' s#33 06#3307#g '/data/3307/my.cnf# sed-i ' s#3306#3307#g '/data/3307/mysqld# chown-r mysql.mysql/data/#/usr/local/mysql/ scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/data/3307/data/--user=mysql#/data/3307/mysqld start# mysql-s/data/3307/mysql.sock
Deploy MySQL Multi-instance