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

Steps for creating and configuring multiple instances of MySQL

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The following mainly brings you the steps of MySQL multi-instance creation and configuration. I hope these contents can bring you practical use. This is also the main purpose of this article when I edit the steps of MySQL multi-instance creation and configuration. All right, don't talk too much nonsense, let's just read the following.

1.1 Multi-instance explanation 1.1.1 creating an environment profile

3306 3307 3308

Multiple mysqld processes (mysqld_safe)

Multiple profiles (port, server_id datadir log-error log-bin socket)

Manage multiple sets of data (multiple data directories, initialize data separately)

1.1.2 create a directory

Create mkdir-p / data/ {3306, 3307, 3308}

Multiple instances:

3306 3307 3308

Multiple mysqld processes (mysqld_safe)

Multiple profiles (port server_id datadir log-error log-bin socket)

Manage multiple sets of data (multiple data directories, initialize data separately)

Mkdir-p {3306, 3307, 3308}

1.1.3 create a profile

Vim / data/3306/my.cnf

[mysqld]

Basedir=/application/mysql

Datadir=/data/3306/data

Server-id=3306

Port=3306

Log-bin=/data/3306/mysql-bin

Socket=/data/3306/mysql.sock

Log-error=/data/3306/mysql.log

Vim / data/3307/my.cnf

[mysqld]

Basedir=/application/mysql

Datadir=/data/3307/data

Server-id=3307

Port=3307

Log-bin=/data/3307/mysql-bin

Socket=/data/3307/mysql.sock

Log-error=/data/3307/mysql.log

Vim / data/3308/my.cnf

[mysqld]

Basedir=/application/mysql

Datadir=/data/3308/data

Server-id=3308

Port=3308

Log-bin=/data/3308/mysql-bin

Socket=/data/3308/mysql.sock

Log-error=/data/3308/mysql.log

1.1.4 Directory authorization

Chown-R mysql.mysql / data/1.1.5 initialization data

Cd / application/mysql/scripts

. / mysql_install_db-defaults-file=/data/3306/my.cnf-basedir=/application/mysql-datadir=/data/3306/data-user=mysql

. / mysql_install_db-defaults-file=/data/3307/my.cnf-basedir=/application/mysql-datadir=/data/3307/data-user=mysql

. / mysql_install_db-defaults-file=/data/3308/my.cnf-basedir=/application/mysql-datadir=/data/3308/data-user=mysql

1.1.6 start the service

/ application/mysql/bin/mysqld_safe-defaults-file=/data/3306/my.cnf &

/ application/mysql/bin/mysqld_safe-defaults-file=/data/3307/my.cnf &

/ application/mysql/bin/mysqld_safe-defaults-file=/data/3308/my.cnf &

1.1.7 check to see if it starts

[root@db02 / data/3307/data] $netstat-lnp | grep 330

Tcp 0 0: 3306: * LISTEN 3877/mysqld

Tcp 0 0: 3307: * LISTEN 4048/mysqld

Tcp 0 0: 3308: * LISTEN 4219/mysqld

Unix 2 [ACC] STREAM LISTENING 18009 3877/mysqld / data/3306/mysql.sock

Unix 2 [ACC] STREAM LISTENING 18137 4048/mysqld / data/3307/mysql.sock

Unix 2 [ACC] STREAM LISTENING 18265 4219/mysqld / data/3308/mysql.sock

1.1.8 Log in to multiple instances

Description: you can enter the following command or

[root@db02] $mysql-S / data/3306/mysql.sock

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 2

Server version: 5.6.36-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | test |

+-+

4 rows in set (0.18 sec)

Description: the following commands can also be operated:

Mysql-uroot-p-P3308

Mysql-uroot-p-S / tmp/mysql3307.sock

1.1.9 multiple instance shutdown method

Description: you can specify the closed port when multiple instances are shut down.

[root@db02 /] $mysqladmin shutdown-S / data/3306/mysql.sock

[root@db02 /] $ps-ef | grep 330

Root 1330 1 0 08:49? 00:00:00 / usr/sbin/acpid

Root 2520 2088 0 22:25 pts/1 00:00:00 / bin/sh / application/mysql/bin/mysqld_safe-- defaults-file=/data/3307/my.cnf

Mysql 2815 2520 0 22:25 pts/1 00:00:12 / application/mysql/bin/mysqld-defaults-file=/data/3307/my.cnf-basedir=/application/mysql-datadir=/data/3307/data-plugin-dir=/application/mysql/lib/plugin-user=mysql-log-error=/data/3307/mysql.log-pid-file=/data/3307/data/db02.pid-socket=/data/3307/mysql.sock-port=3307

Root 2879 2088 0 22:25 pts/1 00:00:00 / bin/sh / application/mysql/bin/mysqld_safe-- defaults-file=/data/3308/my.cnf

Mysql 3028 2879 0 22:25 pts/1 00:00:10 / application/mysql/bin/mysqld-defaults-file=/data/3308/my.cnf-basedir=/application/mysql-datadir=/data/3308/data-plugin-dir=/application/mysql/lib/plugin-user=mysql-log-error=/data/3308/mysql.log-pid-file=/data/3308/data/db02.pid-socket=/data/3308/mysql.sock-port=3308

Root 3288 3146 0 23:14 pts/2 00:00:00 grep 330

Remarks: the following command

Shut down the MySQL database

# mysqld_multi stop 3306

# mysqld_multi stop 3307,3308,3309

# ps-ef | grep mysqld

Root 30822 12043 0 23:04 pts/0 00:00:00 grep mysqld

For the above steps on the creation and configuration of multiple instances of MySQL, do you find it very helpful? If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

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