您好,登錄后才能下訂單哦!
下文主要給大家帶來MySQL多實例創建及配置的步驟,希望這些內容能夠帶給大家實際用處,這也是我編輯MySQL多實例創建及配置的步驟這篇文章的主要目的。好了,廢話不多說,大家直接看下文吧。
3306 3307 3308
多個mysqld進程(mysqld_safe)
多個配置文件(port、server_id datadir log-error log-bin socket)
管理多套數據(多個數據目錄,分別初始化數據)
創建mkdir -p /data/{3306,3307,3308}
多實例:
3306 3307 3308
多個mysqld 進程(mysqld_safe)
多個配置文件(port server_id datadir log-error log-bin socket)
管理多套數據(多個數據目錄,分別初始化數據)
mkdir -p {3306,3307,3308}
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
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
/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 &
[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
說明:登錄可以輸入下面的命令或者是
[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)
說明:以下命令也可操作:
mysql -uroot -p -P3308
mysql -uroot -p -S /tmp/mysql3307.sock
說明:在多實例關閉的時候指定關閉的端口即可。
[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
備注:以下命令
關閉MySQL數據庫
# 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
對于以上關于MySQL多實例創建及配置的步驟,大家是不是覺得非常有幫助。如果需要了解更多內容,請繼續關注我們的行業資訊,相信你會喜歡上這些內容的。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。