Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of the method of creating Multi-instance of mysql5.6 in centos7 Environment

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This paper gives an example of how to create multi-instance of mysql5.6 in centos7 environment. Share with you for your reference, the details are as follows:

I. description of the mysql installation directory

Mysql5.6 is installed as a binary installation package under / data/mysql56

The data directory is under / data/mysql56/data

The configuration file is / etc/my.cnf

Description of multi-instance catalogue

/ mysql-instance

|-3308

|-- data # 3308 instance data directory

|-3309

|-- data # 3309 instance data directory

> mkdir-p / mysql-instance/3308/data > mkdir-p / mysql-instance/3309/data

Copy the configuration file to the instance directory

> cp / data/mysql56/support-files/my-default.cnf / mysql-instance/3308/my.cnf > cp / data/mysql56/support-files/my-default.cnf / mysql-instance/3309/my.cnf

IV. Modify configuration file

> vi / mysql-instance/3308/my.cnf > vi / mysql-instance/3309/ my.cnf [client] port = 3308socket = / mysql-instance/3308/mysql.sock [mysql] no-auto- rehash [mysqld] user = mysqlport = 3308socket = / mysql-instance/3308/mysql.sockbasedir = / data/mysql56datadir = / mysql-instance/3308/datapid-file = / mysql-instance/3308/mysql.pidrelay-log = / mysql-instance/3308/relay-binrelay-log-info-file = / mysql-instance/3308 / relay-log.infoserver-id = 12 [mysqld_safe] log-error = / mysql-instance/3308/mysql.errpid-file = / mysql-instance/3308/mysql.pid

The configuration of 3309 is the same as above, just change 3308 of the place to 3309

5. Create mysql multi-instance startup file

> vi / mysql-instance/3308/mysql > vi / mysqlMustanceUniverse 3309xmysqlqlqlqlqlqlqlqlqlqlqlqlqlqlqlqlqlqlserver username = "root" # Please fill in your own database password mysql_pwd= "123456" cmd_path= "/ data/mysql56/bin" mysql_sock= "/ mysql-instance/$ {port} / mysql.sock" mysql_start () {if [!-e "$mysql_sock"] Then printf "mysql start.\ n" / bin/sh ${cmd_path} / mysqld_safe-- defaults-file=/mysql-instance/$ {port} / my.cnf 2 > & 1 > / dev/null & else printf "mysql is running.\ n" exit fi} mysql_stop () {if [!-e "$mysql_sock"] Then printf "mysql is stopped...\ n" exit else printf "mysql stop.\ n" ${cmd_path} / mysqladmin-u ${mysql_user}-p$ {mysql_pwd}-S / mysql-instance/$ {port} / mysql.sock shutdown fi} mysql_restart () {printf "mysql restart.\ n" mysql_stop sleep 2 mysql_start} case $1 in start) mysql_start;; stop) mysql_stop;; restart) mysql_restart *) printf "usage: / data/$ {port} / mysql {start | stop | restart}\ n" esac

6. Authorize mysql user directory permissions

> chown-R mysql.mysql / mysql-instance > chmod 700 / mysql-instance/3308/mysql > chmod 700 / mysql-instance/3309/mysql

Initialize mysql multi-instance database files

> cd / daa/mysql56/scripts >. / mysql_install_db-- basedir=/data/mysql56-- datadir=/mysql-instance/3308/data-- user=mysql >. / mysql_install_db-- basedir=/data/mysql56-- datadir=/mysql-instance/3309/data-- user=mysql

8. Start multiple instances of mysql

> / mysql-instance/3308/mysql start > / mysql-instance/3309/mysql start > netstat-lntup | grep 330

9. Log in to mysql instance

> mysql- uroot-p-S / mysql-instance/3308/mysql.sock

More readers who are interested in MySQL-related content can check out this site topic: "MySQL query skills Collection", "MySQL Common function Summary", "MySQL Log Operation skills Collection", "MySQL transaction Operation skills Summary", "MySQL stored procedure skills Collection" and "MySQL Database Lock related skills Summary"

It is hoped that what is described in this article will be helpful to everyone's MySQL database design.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report