Multi-configuration file deployment MySQL standalone Multi-instance

Source: Internet
Author: User
Tags mysql commands rehash file permissions

1. Installing gcc-c++, ncurses dependent packages

# yum Install gcc-c++  ncurses-devel

2. Install CMake to compile MySQL

# TAR-XVF cmake-3.2.0-.tar.gz# mv cmake-3.2.0 cmake# mv cmake/tmp/# cd/tmp/cmake/#./bootstrap# make# make install# CMA Ke--version

3. Installing Bison

# TAR-XVF bison-3.0.tar.gz# mv bison-3.0 bison# mv bison/tmp# cd/tmp/bison/#./cofigure# make# make install# bison--ve Rsion

4. Create a MySQL user

#/usr/sbin/groupadd mysql# useradd-s/sbin/nologin-g  mysql-m MySQL

5. Compiling the installation

Configuration

To build an executable file

# make

Installation

# make Install

6. Create a multi-instance data file directory

# mkdir-p/data/{3306,3307}/data/# mkdir-p/data/{3306,3307}/log/# tree/data/data                            #多实例的根目录 ├──3306                         # 3306 instances of the root directory │   ├──data                     #3306实例的数据目录 │   └──log                      #3306实例的日志目录 │   └──tmp                      #3306实例的临时文件目录 └──3307                         #3307实例的根目录    ├──data                     #3307实例的数据目录    └──log                      #3307实例的日志目录    └──tmp                      #3307实例的临时文件目录

Data-storage file: Data, index, binary log (bin log), replay logs (replay log).
Log-Logs file: Slow query log, error log.
TMP-Holds temporary files: Process ID file.

7. Configure a multi-instance configuration file
Create a profile for each instance

# vi/data/3306/my.cnf[client]default-character-set = Utf8port = 3306socket =/data/3306/tmp/mysql.sock[mysqld] Server-id = 1collation-server = Utf8_unicode_ciinit-connect = ' SET NAMES utf8 ' character-set-server = Utf8port = 330  6socket =/data/3306/tmp/mysql.sockdatadir =/data/3306/data/log-error =/data/3306/log/mysql.errpid-file = /data/3306/tmp/mysql.pidlog-bin =/data/3306/data/mysql-binrelay_log =/data/3306/data/relay-binslow_query_log_fi Le =/data/3306/log/slowquery.loggeneral_log_file =/data/3306/log/general.logskip-external-lockingkey_buffer_size = 16mmax_allowed_packet = 1mtable_open_cache = 64sort_buffer_size = 512knet_buffer_length = 8Kread_buffer_size = 256Kread _rnd_buffer_size = 512kmyisam_sort_buffer_size = 8mbinlog_format = Mixedslow_query_log = 1long_query_time = 1general_log = Off[mysqldump]quickmax_allowed_packet = 16m[mysql]no-auto-rehash[myisamchk]key_buffer_size = 20Msort_buffer_size = 20mread_buffer = 2mwrite_buffer = 2m[mysqlhotCopy]interactive-timeout 
# vi/data/3307/my.cnf[client]default-character-set = Utf8port = 3307socket =/data/3307/tmp/mysql.sock[mysqld] Server-id = 2collation-server = Utf8_unicode_ciinit-connect = ' SET NAMES utf8 ' character-set-server = Utf8port = 330  7socket =/data/3307/tmp/mysql.sockdatadir =/data/3307/data/log-error =/data/3307/log/mysql.errpid-file = /data/3307/tmp/mysql.pidlog-bin =/data/3307/data/mysql-binrelay_log =/data/3307/data/relay-binslow_query_log_fi Le =/data/3307/log/slowquery.loggeneral_log_file =/data/3307/log/general.logskip-external-lockingkey_buffer_size = 16mmax_allowed_packet = 1mtable_open_cache = 64sort_buffer_size = 512knet_buffer_length = 8Kread_buffer_size = 256Kread _rnd_buffer_size = 512kmyisam_sort_buffer_size = 8mbinlog_format = Mixedslow_query_log = 1long_query_time = 1general_log = Off[mysqldump]quickmax_allowed_packet = 16m[mysql]no-auto-rehash[myisamchk]key_buffer_size = 20Msort_buffer_size = 20mread_buffer = 2mwrite_buffer = 2m[mysqlhotCopy]interactive-timeout 

8. Configure file permissions for multiple instances
Authorizing MySQL users and groups to manage multi-instance catalogs/data

# Chown-r Mysql.mysql/data

9. Configure environment variables for MySQL commands
Method One:

# echo ' Export path=/usr/local/mysql/bin: $PATH ' >>/etc/profile
# Source/etc/profile

Method Two:
Copy the command below the/usr/local/mysql/bin/to the Global System command path/usr/local/sbin/, or make a link

10. Initialize the database and create the underlying database file

# cd/usr/local/mysql/scripts/#./mysql_install_db--DEFAULTS-FILE=/DATA/3306/MY.CNF--user=mysql--basedir=/usr/ local/mysql#./mysql_install_db--defaults-file=/data/3307/my.cnf--user=mysql--basedir=/usr/local/mysql

11. Start

# Mysqld_safe--defaults-file=/data/3306/my.cnf 2>&1 >/dev/null mysqld_safe--defaults-file=/data/ 3307/MY.CNF 2>&1 >/dev/null &

12. Change the root user's password and restrict the local login

# mysqladmin-s/data/3306/tmp/mysql.sock-u root-h ' localhost ' password ' xxxx ' # mysqladmin-s/data/3307/tmp/mysql.sock -u root-h ' localhost ' password ' xxxx '

13. Log in with the root user

# mysql-s  /data/3306/tmp/mysql.sock-u root-p# mysql-s  /data/3307/tmp/mysql.sock-u root-p

14. Stopping an instance

# mysqladmin-s/data/3306/tmp/mysql.sock-u root-p shutdown# mysqladmin-s/data/3307/tmp/mysql.sock-u root-p shutdown

  

Multi-configuration file deployment MySQL standalone Multi-instance

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.