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 multi-instance configuration

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Mysql multi-instance common configuration methods:

Install mysql dependent packages

yum install ncurses-devel libaio-devel -y

mysql profile: pull to server

[root@MySql ~]# tree

.

|-- 3306

| |-- my.cnf

| `-- mysql

|-- 3307

| |-- my.cnf

| `-- mysql

Copy Configuration Files

[root@MySql ~]# mkdir -p /data/3306

[root@MySql ~]# mkdir -p /data/3307

[root@MySql ~]# cp 3306/my.cnf /data/3306

[root@MySql ~]# cp 3306/mysql /data/3306

[root@MySql ~]# cp 3307/my.cnf /data/3307

[root@MySql ~]# cp 3307/mysql /data/3307

[root@MySql 3306]# vi my.cnf

server-id = 1 The server-id of the two profiles should be different

Authorized:

[root@MySql 3306]# chmod +x /data/3306/mysql

[root@MySql 3306]# chmod +x /data/3307/mysql

[root@MySql ~]# chown -R mysql.mysql /data

[root@MySql 3306]# pwd

/data/3306

[root@MySql 3306]# ll

total 12

drwxr-xr-x 2 mysql mysql 4096 Mar 21 22:28 data

-rw-r--r-- 1 mysql mysql 1899 Mar 20 04:15 my.cnf

-rw-r--r-- 1 mysql mysql 1307 Mar 20 04:15 mysql

Multi-instance startup file startup mysql service essence:

mysqld_safe --defaults-file=/data/3306/my.cnf >/dev/null 2&>1

mysqld_safe --defaults-file=/data/3307/my.cnf >/dev/null 2&>1

Stop mysql service essence of multi-instance startup file:

mysqladmin -uroot -p123456 -S /data/3306/mysql.sock shutdown

mysqladmin -uroot -p123456 -S /data/3307/mysql.sock shutdown

Set the mysql startup command environment variable, you can use which mysql, then cp

Initialize mysql multi-instance database files

First, the initialization command is:

Mysql 5.1.X initialization command:

mysql_install_db --basedir=/usr/local/mysql --datadir=/data/3306/data --user=mysql

Mysql 5.5.X initialization command:

cd /usr/local/mysql/scripts ? The path is different from that of 5.1 and is not under the mysql bin path.

./ mysql_install_db --basedir=/usr/local/mysql --datadir=/data/3306/data --user=mysql

operation

[root@MySql ~]# cd /usr/local/mysql/scripts/

[root@MySql scripts]# ll

total 16

-rwxr-xr-x 1 7161 wheel 14816 Jun 19 2013 mysql_install_db

[root@MySql scripts]# ./ mysql_install_db --basedir=/usr/local/mysql --datadir=/data/3306/data --user=mysql

[root@MySql scripts]# ./ mysql_install_db --basedir=/usr/local/mysql --datadir=/data/3307/data --user=mysql

Second: Start the database

[root@MySql scripts]# /data/3306/mysql start

Starting MySQL...

[root@MySql scripts]# /data/3307/mysql start

Starting MySQL...

[root@MySql scripts]# netstat -lnptu |grep 330 tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 6668/mysqld

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1367/mysqld

View directory after startup

[root@MySql 3306]# ll

total 36

drwxr-xr-x 5 mysql mysql 4096 Mar 21 23:11 data

-rw-r--r-- 1 mysql mysql 1891 Mar 21 23:05 my.cnf

-rwxr-xr-x 1 mysql mysql 1305 Mar 21 22:51 mysql

-rw-rw---- 1 mysql mysql 126 Mar 21 23:07 mysql-bin.000001

-rw-rw---- 1 mysql mysql 107 Mar 21 23:11 mysql-bin.000002

-rw-rw---- 1 mysql mysql 56 Mar 21 23:11 mysql-bin.index

srwxrwxrwx 1 mysql mysql 0 Mar 21 23:11 mysql.sock

-rw-r----- 1 mysql root 2792 Mar 21 23:11 mysql_3306.err

-rw-rw---- 1 mysql mysql 5 Mar 21 23:11 mysqld.pid

[root@MySql 3307]# ll

total 28

drwxr-xr-x 5 mysql mysql 4096 Mar 21 23:07 data

-rw-r--r-- 1 mysql mysql 1893 Mar 21 23:04 my.cnf

-rwxr-xr-x 1 mysql mysql 1305 Mar 21 22:52 mysql

srwxrwxrwx 1 mysql mysql 0 Mar 21 23:07 mysql.sock

-rw-r----- 1 mysql root 1403 Mar 21 23:07 mysql_3307.err

-rw-rw---- 1 mysql mysql 5 Mar 21 23:07 mysqld.pid

sign-on database

After MySQL database is installed, by default, the administrator account is five passwords.

[root@MySql 3306]# mysql -S /data/3306/mysql.sock

mysql> system ls ==》Do not quit executing commands

data mysql mysql-bin.000002 mysql.sock mysql_oldboy3306.err

my.cnf mysql-bin.000001 mysql-bin.index mysql_3306.err mysqld.pid

system mysql -S /data/3307/mysql.sock; log in directly to another database

restart the database

[root@MySql scripts]# /data/3306/mysql stop

[root@MySql scripts]# /data/3306/mysql start

mysql multi-instance configuration completed

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