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

MySQL 5.6 multiple instances of the same physical host configuration

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

Share

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

1. Planning catalogue

Create a software directory, which is shared by multiple instances

[root@localhost ~] # mkdir / mysql_software_56

For the installation process of single instance source code, please refer to

MySQL 5.6 source code compilation and installation process

Http://blog.itpub.net/26506993/viewspace-2142773/

-- the port number is the relevant directory of the 3306 instance

Create data file directory and log directory

[root@localhost] # mkdir-p / my3306/data

[root@localhost] # mkdir-p / my3306/log/iblog

[root@localhost] # mkdir-p / my3306/log/binlog

Create a directory for storing Pid and temporary files

[root@localhost] # mkdir-p / my3306/run

[root@localhost] # mkdir-p / my3306/tmp

Parameter file

Cat / etc/my_5.6_3306.cnf

[mysqld]

Basedir=/mysql_software_56

Datadir=/my3306/data

Port=3306

Socket=/my3306/run/mysql.sock

Pid_file=/my3306/run/mysqld.pid

-- the port number is the relevant directory of the 3307 instance

Create data file directory and log directory

[root@localhost] # mkdir-p / my3307/data

[root@localhost] # mkdir-p / my3307/log/iblog

[root@localhost] # mkdir-p / my3307/log/binlog

Create a directory for storing Pid and temporary files

[root@localhost] # mkdir-p / my3307/run

[root@localhost] # mkdir-p / my3307/tmp

Parameter file

Cat / etc/my_5.6_3307.cnf

[mysqld]

Basedir=/mysql_software_56

Datadir=/my3307/data

Port=3307

Socket=/my3307/run/mysql.sock

Pid_file=/my3307/run/mysqld.pid

two。 When initializing MySQL, use different parameter files and different data directories

-- the initial port number is 3306 instance

/ mysql_software_56/scripts/mysql_install_db-defaults-file=/etc/my_5.6_3306.cnf-datadir=/my3306/data/-user=mysql

-- the initial port number is 3307 instance

/ mysql_software_56/scripts/mysql_install_db-defaults-file=/etc/my_5.6_3307.cnf-datadir=/my3307/data/-user=mysql

3. Start the database (using different parameter files)

-- launch port number is 3306 instance

/ mysql_software_56/bin/mysqld_safe-defaults-file=/etc/my_5.6_3306.cnf-user=mysql &

-- launch port number is 3307 instance

/ mysql_software_56/bin/mysqld_safe-defaults-file=/etc/my_5.6_3307.cnf-user=mysql &

-- looking at the process, you can find two mysqld processes, corresponding to different parameter files

[root@localhost log] # ps-ef | grep mysql

Root 61998 50095 0 07:31 pts/4 00:00:00 / bin/sh / mysql_software_56/bin/mysqld_safe-- defaults-file=/etc/my_5.6_3307.cnf-- user=mysql

Mysql 62848 61998 1 07:31 pts/4 00:00:05 / mysql_software_56/bin/mysqld-defaults-file=/etc/my_5.6_3307.cnf-basedir=/mysql_software_56-datadir=/my3307/data-plugin-dir=/mysql_software_56/lib/plugin-user=mysql-log-error=/my3307/log/error.log-open-files-limit=65535 pid-file=/my3307/run/mysqld.pid socket=/my3307/run/mysql.sock port=3307

Root 62930 50095 0 07:39 pts/4 00:00:00 / bin/sh / mysql_software_56/bin/mysqld_safe-- defaults-file=/etc/my_5.6_3306.cnf-- user=mysql

Root 63780 62930 22 07:39 pts/4 00:00:04 / mysql_software_56/bin/mysqld-defaults-file=/etc/my_5.6_3306.cnf-basedir=/mysql_software_56-datadir=/my3306/data-plugin-dir=/mysql_software_56/lib/plugin-user=mysql-log-error=/my3306/log/error.log-open-files-limit=65535 pid-file=/my3306/log/run/mysqld.pid socket=/my3306/log/run/mysql.sock port=3306

4. Connect to the database (using different socket files and different port numbers)

-- the connection port number is 3306 instance

/ mysql_software_56/bin/mysql-uroot-p-- socket=/my3306/run/mysql.sock

/ mysql_software_56/bin/mysql-uroot-p-h 127.0.0.1-P 3306

-- the connection port number is 3307 instance

/ mysql_software_56/bin/mysql-uroot-p-- socket=/my3307/run/mysql.sock

/ mysql_software_56/bin/mysql-uroot-p-h 127.0.0.1-P 3307

5. Shut down the database (using a different port number)

-- disable the port number of 3306 instance

/ mysql_software_56/bin/mysqladmin-uroot-p-P 3306 shutdown

Enter password:

170729 07:42:37 mysqld_safe mysqld from pid file / my3306/log/run/mysqld.pid ended

[2] + Done / mysql_software_56/bin/mysqld_safe-defaults-file=/etc/my_5.6_3306.cnf-user=mysql

[root@localhost log] # ps-ef | grep mysql

Root 61998 50095 0 07:31 pts/4 00:00:00 / bin/sh / mysql_software_56/bin/mysqld_safe-- defaults-file=/etc/my_5.6_3307.cnf-- user=mysql

Mysql 62848 61998 0 07:31 pts/4 00:00:06 / mysql_software_56/bin/mysqld-defaults-file=/etc/my_5.6_3307.cnf-basedir=/mysql_software_56-datadir=/my3307/data-plugin-dir=/mysql_software_56/lib/plugin-user=mysql-log-error=/my3307/log/error.log open-files-limit=65535 pid-file=/my3307/run/mysqld.pid socket=/my3307/run/mysql.sock port=3307

-- disable the port number of 3307 instance

/ mysql_software_56/bin/mysqladmin-uroot-p-P 3307 shutdown

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