MySQL Multi-instance deployment

Source: Internet
Author: User

There are two ways that MySQL can be implemented in multiple instances, both of which have pros and cons.
The first is to use multiple configuration files to launch different processes to implement multiple instances, the advantages of this method is simple, simple configuration, the disadvantage is not easy to manage.
The second is the use of the official Mysqld_multi with a separate configuration file to achieve multiple instances, this way to customize the configuration of each instance is not too, the advantage is easy to manage, centralized management

The first uses multiple profiles to start multiple

1. Install and compile the database

2. Initializing the database

/usr/local/mysql_3306/bin/mysql_install_db--basedir=/usr/local/mysql_3306--datadir=/data/dbdata_3306--user= Mysql
/usr/local/mysql_3307/bin/mysql_install_db--basedir=/usr/local/mysql_3307--datadir=/data/dbdata_3307--user= Mysql
/usr/local/mysql_3308/bin/mysql_install_db--basedir=/usr/local/mysql_3308--datadir=/data/dbdata_3308--user= Mysql

3. Create the respective configuration file (need to specify the respective data directory, port, socket file)

Vim/data/dbdata_3306/my.cnf

Vim/data/dbdata_3307/my.cnf

Vim/data/dbdata_3308/my.cnf

4. Start each instance with a configuration issue

/bin/sh/usr/local/mysql_3306/bin/mysqld_safe--DEFAULTS-FILE=/DATA/DBDATA_3306/MY.CNF &

/bin/sh/usr/local/mysql_3307/bin/mysqld_safe--DEFAULTS-FILE=/DATA/DBDATA_3307/MY.CNF &

/bin/sh/usr/local/mysql_3308/bin/mysqld_safe--DEFAULTS-FILE=/DATA/DBDATA_3308/MY.CNF &

To close different instances

A.kill-9 Process ID

B./bin/sh/usr/local/mysql_3306/bin/mysqladmin-u ${mysql_username}-p${mysql_password}-s/data/dbdata_${mysql_port }/mysql.sock shutdown

The second approach is configured with the official Mysql_multi

1. Install and initialize the database as in the first way

2. Edit the configuration file (three instances of the configuration file are put together)

Vi/etc/my.cnf

[Mysqld_multi]
Mysqld =/usr/local/mysql/bin/mysqld_safe
Mysqladmin =/usr/local/mysql/bin/mysqladmin
user = Admin
Password = password

[Mysqld1]//define Instance 3306

Socket/data/dbdata_3306/mysql.sock

Port = 3306

Pid-file =/data/dbdata_3306/3306.pid

DataDir =/data/dbdata_3306

..........

[Mysqld2]//define Instance 3307

Socket/data/dbdata_3307/mysql.sock

Port = 3307

Pid-file =/data/dbdata_3307/3307.pid

DataDir =/data/dbdata_3307

..........

[MYSQLD3]//define instance 3308

Socket/data/dbdata_3308/mysql.sock

Port = 3308

Pid-file =/data/dbdata_3308/3308.pid

DataDir =/data/dbdata_3308

..........

3. Start each instance

/usr/local/mysql/bin/mysqld_multi Start 1

/usr/local/mysql/bin/mysqld_multi Start 2

/usr/local/mysql/bin/mysqld_multi Start 3

Or

/usr/local/mysql/bin/mysqld_multi Start 1-3

This article from "Banging blog" blog, declined reprint!

MySQL Multi-instance deployment

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.