MariaDB multi-instance and MariaDB instance

Source: Internet
Author: User

MariaDB multi-instance and MariaDB instance
1. Install MariaDB in yum and start

yum install MariaDB-server
systemctl start mariadb.service

 

2. Create a directory by case and set the owner Group

Store configuration files and databases by case

mkdir -pv /mysqldb/{3306,3307,3308}/{etc,socket,pid,log,data}

 

Set directory owner Group

chown -R mysql.mysql /mysqldb

 

3. Create Database Files
Mysql-e 'show variables like "basedir"; '# query the Mariadb installation directory
Mysql_install_db -- datadir =/mysqldb/3306/data -- user = mysql -- basedir =/usr
Mysql_install_db -- datadir =/mysqldb/3307/data -- user = mysql -- basedir =/usr
Mysql_install_db -- datadir =/mysqldb/3308/data -- user = mysql -- basedir =/usr

 

Iv. Configuration File
cp /etc/my.cnf /mysqldb/3306/etc/cp /etc/my.cnf /mysqldb/3307/etc/cp /etc/my.cnf /mysqldb/3308/etc/

Modify configuration file

The same is true for 3307 3308. You need to change the port and directory location.

5. service scripts
#! /Bin/bashport = 3306mysql_user = "root" mysql_pwd = "" cmd_path = "/usr/bin" # You can use which mysqld_safe to query metrics = "/mysqldb" mysql_sock = "$ {metrics }/$ {port}/socket/mysql. sock "function_start_mysql () {if [! -E "$ mysql_sock"]; then printf "Starting MySQL... \ n "$ {export _path}/mysqld_safe -- defaults-file =$ {mysql_basedir}/$ {port}/etc/my. cnf &>/dev/null & else printf "MySQL is running... \ n "exit fi} function_stop_mysql () {if [! -E "$ mysql_sock"]; then printf "MySQL is stopped... \ n "exit else printf" Stoping MySQL... \ n "$ {cmd_path}/mysqladmin-u $ {mysql_user}-p $ {mysql_pwd}-S $ {mysql_sock} shutdown fi} function_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: $ {mysql_basedir}/$ {port}/bin/mysqld {start | stop | restart} \ n "esac

Set permissions

The same is true for 3307,3308. You need to change the port number.

 

6. Start the Service (pay attention to the need to stop the Mariadb service in the Multi-case column to prevent conflicts)
/mysqldb/3306/mysqld start/mysqldb/3307/mysqld start/mysqldb/3308/mysqld start

 

VII. test connection
mysql -S /mysqldb/3306/socket/mysql.sock
mysql -S /mysqldb/3307/socket/mysql.sock
mysql -S /mysqldb/3308/socket/mysql.sock

 

 

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.