MARIADB single-Machine multi-instance

Source: Internet
Author: User

We run 3 MySQL services on the same server to open the 3306,3307,3308 port separately
##############################################
# # # Installation MARIADB # #
##############################################
Slightly

##############################################
# # # of Initialization Environment # #
##############################################
1) Create 3 directories to save 3 data for each instance
[[email protected] ~]# mkdir-p/mariadb/data{3306,3307,3308}

2) Change the owning group and owner
[Email protected] ~]# chown-r mysql:mysql/mariadb

###############################################
# # # for data Instance Directory initialization # # #
###############################################
[Email protected] ~]# mysql_install_db--datadir=/mariadb/data3306--user=mysql
[Email protected] ~]# mysql_install_db--datadir=/mariadb/data3307--user=mysql
[Email protected] ~]# mysql_install_db--datadir=/mariadb/data3308--user=mysql

##############################################
# # # Create an Instance # #
##############################################
1) Edit the source configuration file
[Email protected] ~]# cp-a/etc/my.cnf/etc/my.cnf.bak
[[email protected] ~]# VI/ETC/MY.CNF # Add the following code, which is not listed in the value is to keep the default value
[Mysqld_multi]
Mysqld =/usr/bin/mysqld_safe
user = MySQL

# Add three instances
[mysqld3306]
# occupied ports (each instance consumes one port)
port=3306
# Specify the directory where the socket file resides
Socket=/tmp/mysql3306.sock
# Specify where the lock file is located
Pid-file=/tmp/mysql3306.pid
# Specify the DB instance directory
datadir=/mariadb/data3306


[mysqld3307]
port=3307
Socket=/tmp/mysql3307.sock
Pid-file=/tmp/mysql3307.pid
datadir=/mariadb/data3307

[mysqld3308]
port=3308
Socket=/tmp/mysql3308.sock
Pid-file=/tmp/mysql3308.pid
datadir=/mariadb/data3308


##############################################
# # # Launch Instance # #
##############################################
[[email protected] ~]# mysqld_multi--defaults-extra-file=/etc/my.cnf start 3306
[[email protected] ~]# Mysqld_multi--DEFAULTS-EXTRA-FILE=/ETC/MY.CNF Report # View launched instances
Reporting MySQL Servers
MySQL server from group:mysqld3306 is running
MySQL server from group:mysqld3307 are not running
MySQL server from group:mysqld3308 are not running
To start another instance
[[email protected] ~]# mysqld_multi--defaults-extra-file=/etc/my.cnf start 3307
[[email protected] ~]# mysqld_multi--defaults-extra-file=/etc/my.cnf start 3308

###############################################
# # # Client Login # # #
###############################################
1 connection via TCP/IP
[[email protected] ~]# Mysql-p3306-hlocalhost--PROTOCOL=TCP # You cannot use the TCP protocol connection when there is--skip-networking in the service startup parameter

2 How to connect an instance
[[email protected] ~]# mysql-s/tmp/mysql3307.sock # Cannot connect remotely

################################################
# # # To manipulate this instance # # # #
################################################
MariaDB [(None)]> CREATE Database database_3306;
Query OK, 1 row Affected (0.00 sec)

MariaDB [(None)]> CREATE Database database_3307;
Query OK, 1 row Affected (0.00 sec)


MariaDB [(None)]> CREATE Database database_3308;
Query OK, 1 row Affected (0.00 sec)

[Email protected] ~]# ll/mariadb/data3306
Total 110632
。。。。。。。。
drwx------2 MySQL mysql 4096 may 01:16 database_3306
。。。。。。。。

[Email protected] ~]# ll/mariadb/data3307
Total 110632
。。。。。。
drwx------2 MySQL mysql 4096 may 01:16 database_3307
。。。。。。

[Email protected] ~]# ll/mariadb/data3308
Total 110632
。。。。。。
drwx------2 MySQL mysql 4096 may 01:16 database_3308
。。。。。。
################################################
# # # Close Instance # # #
################################################
[Email protected] ~]#/usr/bin/mysqladmin-u root-p-s/tmp/mysql3306.sock shutdown
Enter Password:





MARIADB single-Machine multi-instance

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.