標籤:完成後 mys 安裝 匯入 tmp 目錄 tar zxvf rom pat
解壓 MySQL 5.7 二進位包到指定目錄
[[email protected] ~]# tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
建立 MySQL 軟連結
[[email protected] ~]#mv /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql
建立 MySQL 使用者
[[email protected] ~]#groupadd -r mysql
[[email protected] ~]# useradd -r -g mysql -s /bin/false -M mysql
在 MySQL 二進位包目錄中建立 mysql-files 目錄 [MySQL 資料匯入/匯出資料專放目錄]
[[email protected] ~]# mkdir -v /usr/local/mysql/mysql-files
mkdir: created directory `/usr/local/mysql/mysql-files‘
建立多執行個體資料目錄
[[email protected] ~]# mkdir -vp /data/mysql_data{1..4}
mkdir: created directory /data‘ <br/>mkdir: created directory
/data/mysql_data1‘
mkdir: created directory /data/mysql_data2‘ <br/>mkdir: created directory
/data/mysql_data3‘
mkdir: created directory `/data/mysql_data4‘
修改 MySQL 二進位包目錄的所屬使用者與所屬組
1 [[email protected] ~]# chown root.mysql -R /usr/local/mysql
修改 MySQL 多執行個體資料目錄與 資料匯入/匯出專放目錄的所屬使用者與所屬組
[[email protected] ~]# chown mysql.mysql -R /usr/local/mysql/mysql-files /data/mysql_data{1..4}
配置 MySQL 設定檔 /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld
mysqladmin = /usr/local/mysql/bin/mysqladmin
log = /tmp/mysql_multi.log
[mysqld1]
# 設定資料目錄 [多執行個體中一定要不同]
datadir = /data/mysql_data1
# 設定sock存放檔案名稱 [多執行個體中一定要不同]
socket = /tmp/mysql.sock1
# 設定監聽開放連接埠 [多執行個體中一定要不同]
port = 3306
# 設定運行使用者
user = mysql
# 關閉監控
performance_schema = off
# 設定innodb 緩衝大小
innodb_buffer_pool_size = 32M
# 設定監聽IP地址
bind_address = 0.0.0.0
# 關閉DNS 反向解析
skip-name-resolve = 0 **
[mysqld2]
datadir = /data/mysql_data2
socket = /tmp/mysql.sock2
port = 3307
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0
[mysqld3]
datadir = /data/mysql_data3
socket = /tmp/mysql.sock3
port = 3308
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0
[mysqld4]
datadir = /data/mysql_data4
socket = /tmp/mysql.sock4
port = 3309
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0
*修改環境變數
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
複製多執行個體指令碼到服務管理目錄下 [ /etc/init.d/ ]
[[email protected] ~]# cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi
添加指令碼執行許可權
[[email protected] ~]# chmod +x /etc/init.d/mysqld_multi
- 添加進service服務管理
[[email protected] ~]# chkconfig --add mysqld_multi
- 啟動測試
- 查個多執行個體狀態
[[email protected] ~]# /etc/init.d/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld1 is not running
MySQL server from group: mysqld2 is not running
MySQL server from group: mysqld3 is not running
MySQL server from group: mysqld4 is not running
啟動多執行個體
[[email protected] ~]# /etc/init.d/mysqld_multi start
查看多執行個體狀態
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running
- 查看執行個體監聽連接埠
[[email protected] ~]# netstat -lntp | grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 2673/mysqld
tcp 0 0 0.0.0.0:3307 0.0.0.0: LISTEN 2676/mysqld
tcp 0 0 0.0.0.0:3308 0.0.0.0: LISTEN 2679/mysqld
tcp 0 0 0.0.0.0:3309 0.0.0.0: LISTEN 2682/mysqld
- 串連測試
MySQL多執行個體安裝部署