標籤:iat pre 進入 chkconfig Owner sql ESS row 下載
MySQL多執行個體_沁貳百科
註:部署雙執行個體前,首先需要部署單一實例,單一實例部署詳情如下:
https://www.cnblogs.com/wangqiner/p/9081002.html
1、如已經安裝完成單一實例,需要先停止單一實例運行,接下來進行多執行個體部署
/etc/init.d/mysqld stopchkconfig mysqld off
2、已經製作好多執行個體設定檔及開機檔案,以下為:
3、上傳data.tar.gz到根目錄,然後tar解壓
[[email protected] /]# tar xf data.tar.gz
[[email protected] /]# tree /data
data
├── 3306
│ ├── my.cnf
│ └── mysql
└── 3307
├── my.cnf
└── mysql
4、授權所有者、所屬組及檔案許可權並查看
chown -R mysql.mysql /data/
[[email protected] /]# find /data -name mysql|xargs ls -l
-rw-r--r-- 1 root root 1345 Apr 26 2017 /home/data/3306/mysql
-rw-r--r-- 1 root root 1345 Apr 26 2017 /home/data/3307/mysql
[[email protected] home]# find /home/data -name mysql|xargs chmod 700
[[email protected] home]# find /home/data -name mysql|xargs ls -l
-rwx------ 1 root root 1345 Apr 26 2017 /home/data/3306/mysql
-rwx------ 1 root root 1345 Apr 26 2017 /home/data/3307/mysql
[[email protected] home]#
5、進入MySQL初始設定檔案目錄
cd /application/mysql/scripts
6、初始化3306,3307 兩個執行個體(為了產生MySQL data下資料關聯及檔案)
./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
7、環境變數設定,如已經配置,可跳過
echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profilesource /etc/profile
8、啟動前為保證沒有錯誤檔案的報錯,提前建立錯誤記錄檔檔案及授權所有者及所屬組
touch /data/3306/oldboy_3306.errtouch /data/3307/oldboy_3307.errchown mysql.mysql /data/3306/oldboy_3306.errchown mysql.mysql /data/3307/oldboy_3307.err
9、啟動MySQL多執行個體
---命令---
/data/3306/mysql start/data/3307/mysql start
---展示---
[[email protected] data]# /data/3306/mysql start
Starting MySQL...
[[email protected] data]# /data/3307/mysql start
Starting MySQL...
10、查看MySQL連接埠是否正常啟動
[[email protected] data]# ss -lntupNetid State Recv-Q Send-Q Local Address:Port Peer Address:Port tcp LISTEN 0 600 :::3306 :::* users:(("mysqld",36610,11))tcp LISTEN 0 600 :::3307 :::* users:(("mysqld",37337,11))
11、分別登入進入MySQL多執行個體
---進入命令---
mysql -S /data/3306/mysql.sock
mysql -S /data/3307/mysql.sock
----展示-----
[[email protected] data]# mysql -S /data/3306/mysql.sockWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.36 Source distributionCopyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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.00 sec)mysql> exitBye[[email protected] data]# mysql -S /data/3307/mysql.sockWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.36 Source distributionCopyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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.01 sec)mysql> exitBye
完成以上操作,MySQL多執行個體就已經部署完成!
以下是增加一台執行個體思路
1、複製根目錄下/data/3306 改名為 /data/3308
2、進行對比多執行個體MySQL執行個體下的my.cnf 和mysql 開機檔案,
唯一的區別在於執行個體名稱的不同(如3306,3307,3308),以及server id 的不同(任意數不相同即可)
3、使用sed -i "s#3306#3308#g" /data/3308/my* 命令進行替換,如果不太明白,可以開啟複製後的3308目錄中的設定檔及開機檔案,一一修改為3308 即可;
4、修改完成後初始化執行個體3308 ,可根據上述初始化命令將其他執行個體名稱改為3308即可;
5、建立錯誤記錄檔檔案到執行個體3308下;
6、授權執行個體3308 ,更改所有者、所屬組及許可權;
7、啟動多執行個體3308 /data/3308/mysql start;
8、查看連接埠是否啟動。
MySQL-5.6.36-多執行個體-部署(編譯版)