Establishment of MARIADB multi-instance in CENTOS7 environment

Source: Internet
Author: User

Environment all based on VMware player 12

Os:centos7

Mariadb:mariadb-10.1.12-linux-x86_64.tar.gz

Mainly based on the help documents given by MARIADB, as well as this post on the Internet to operate

In the middle of a myriad of problems, with Google's help to solve all

A few hours, I'm a 鶸.

Su Root #切换到root用户

Groupadd MySQL #添加mysql组

useradd-g MySQL MySQL #在mysql组中添加mysql用户

Cd/usr/local

Gunzip

Ln-s mariadb-10.1.12-linux-x86_64 MySQL #创建符号链接

CD MySQL

Chown-r MySQL. #修改权限

Chgrp-r MySQL. #修改权限

Mkdir-p/var/lib/mysql3307 #创建数据文件夹

chmod--reference/var/lib/mysql/var/lib/mysql3307 #将数据文件夹的访问权限授予mysql, otherwise this folder can only be accessed by the root user

Chown--reference/var/lib/mysql/var/lib/mysql3307

scripts/mysql_install_db--user=mysql--datadir=/var/lib/mysql3307 #初始化数据文件夹

Cp-p/etc/my.cnf/var/lib/mysql3307/my.cnf #在数据文件夹中添加my. CNF configuration file, the next step is to modify it

Modify the/VAR/LIB/MYSQL3307/MY.CNF as shown below

[Mysqld]
datadir=/var/lib/mysql3307
Socket=/var/lib/mysql/mysql3307.sock
port=3307

[Mysqld_safe]
Log-error=/var/log/mysqld3307.log
Pid-file=/var/run/mysqld/mysqld3307.pid

Bin/mysql_safe--defaults-file=/var/lib/mysql3307/my.cnf--user=mysql &

After this step, the error is started, and after reviewing the errors, it is found that the default is in the My.cnf file under/etc/, which has two paths:/var/og/mariadb/mysql.log and/var/run/mariadb/ Mysql.pid, and these two paths do not exist, so the error

After creating these two folders, still error, because the permissions are not enough, the/VAR/RUN/MARIADB directory is authorized to the MySQL user can

Bin/mysql_safe--defaults-file=/var/lib/mysql3307/my.cnf & #以我们指定的my. CN profile as required, launch MYSQ instance

Then use the command NETSTAT-TANP | grep 3307to see that MySQL is already listening on port 3307.

bin/mysql-uroot-p-h127.0.0.1-p3307, connecting into MySQL

Modify the root password and import the database initialization script with source

Bin/mysqladmin-s/var/lib/mysql/mysql3307.sock shutdown-p #结束3307号mysql进程

Cp-r- P /var/lib/mysql3307/var/lib/mysql3308 #复制mysql数据文件夹, the-p parameter is to be copied together with the permissions, otherwise the permissions copied over are Root,mysql inaccessible.

Cp-r- P /var/lib/mysql3307/var/lib/mysql3309

Modify the My.cnf file in the mysql3308 and mysql3309 folder, and then run

Bin/mysql_safe--DEFAULTS-FILE=/VAR/LIB/MYSQL3307/MY.CNF &

Bin/mysql_safe--DEFAULTS-FILE=/VAR/LIB/MYSQL3308/MY.CNF &

Bin/mysql_safe--DEFAULTS-FILE=/VAR/LIB/MYSQL3309/MY.CNF &

Can run three MARIADB db instances at the same time

Establishment of MARIADB multi-instance in CENTOS7 environment

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.