mysqld_multi啟動多個mysql例項
可以管理多個幀聽不同Unix套接字檔案和TCP/IP埠的連線的mysqld 程式。它可以啟動或停止伺服器,或報告它們的當前狀態。
即可以管理多個例項。
之前使用mysql_safe啟用多例項的方法,啟動和關閉都指定配置檔案,例項間是對立的,互不影響。成功的部署了多個例項主從Replication
mysql_multi多例項管理,配置簡單,方便管理。
說明
實戰
1.配置my.cnf檔案
~]# cat /etc/my.cnf
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe #根據自己的mysql目錄配置,使用which command可以查詢路徑
mysqladmin = /usr/bin/mysqladmin
[mysqld] #之前已經正常使用的mysql例項
basedir=/usr
datadir = /data/mysql
port = 3306
server_id = 2
socket = /tmp/mysql3306.sock
skip-host-cache
skip-name-resolve
character-set-server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket=/tmp/mysql3306.sock #配置client預設使用的scoket檔案
#mysqld1和mysqld2是使用mysqld_multi啟動的多個例項
[mysqld1]
basedir=/usr
datadir = /data/mysql1
port = 3307
server_id = 3
socket = /tmp/mysql3307.sock
skip-host-cache
skip-name-resolve
character-set-server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld2]
basedir=/usr
datadir = /data/mysql2
port = 3308
server_id = 3
socket = /tmp/mysql3308.sock
skip-host-cache
skip-name-resolve
character-set-server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
注:配置檔案中其他的引數跟正常的mysqld下一樣 根據實際需要設定即可
2.複製mysqld的檔案到mysqld1和mysqld2對應的datadir
~]# cp -pr /data/mysql /data/mysql1
~]# cp -pr /data/mysql /data/mysql2
3.啟動mysqld1和mysqld2例項--使用mysqld_multi
~]# mysqld_multi start 1
~]# mysqld_multi start 2
Usage: mysqld_multi [OPTIONS] {start|reload|stop|report} [GNR,GNR,GNR...]
or mysqld_multi [OPTIONS] {start|reload|stop|report} [GNR-GNR,GNR,GNR-GNR,...]
4.啟動預設的mysql例項--使用/etc/init.d/mysql start
~]# /etc/init.d/mysql start
Starting MySQL. [ OK ]
5.檢視已經啟動的mysql例項
~]# netstat -ntpl|grep 330
tcp 0 0 :::3306 :::* LISTEN 6643/mysqld
tcp 0 0 :::3307 :::* LISTEN 5667/mysqld
tcp 0 0 :::3308 :::* LISTEN 5666/mysqld
至此可以看到 在一臺機器上啟動了3個例項
6.連線不同的例項,用port區分
~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> Ctrl-C -- exit!
Aborted
~]# mysql -uroot -p -P3307
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> Ctrl-C -- exit!
Aborted
~]# mysql -uroot -p -P3308
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27000195/viewspace-1419251/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysqld_multi安裝多個mysql例項MySql
- mysql搭建多個例項(mysqld_multi的使用)MySql
- mysql使用mysqld_multi工具啟動多例項MySql
- 一臺MySQL資料庫啟動多個例項MySql資料庫
- oracle多個例項啟動方法Oracle
- 使用mysqld_multi實現單系統中配置多個MySQL伺服器例項MySql伺服器
- linux自動automatic啟動停止多個oracle例項LinuxOracle
- MySQL入門--Mysqld_multi多例項MySql
- 基於mysqld_multi實現MySQL 5.7.24多例項多程式配置MySql
- Linux中執行多個MySQL例項LinuxMySql
- 在Windows中執行多個MySQL例項WindowsMySql
- mysql例項停止、啟動、配置遠端訪問MySql
- MySQL在Windows上安裝多個例項的方法MySqlWindows
- docker redis 多個例項DockerRedis
- mysqld_multi搭建MySQL單機多例項服務MySql
- jafka安裝配置和啟動一個自帶例項和手寫一個例項
- 多個mapreduce連線例項
- 如何對多個動態代理例項做判等?
- 使用SRVCTL啟動例項與使用sqlplus啟動例項的區別SQL
- 2 Day DBA-管理Oracle例項-關於例項的啟動和關閉-關於例項啟動Oracle
- 啟動CRS單例項、設定自動啟動單例
- 3.1.5.9 啟動遠端例項
- 啟動ASM 例項報錯ASM
- mysql系列之多例項3—-基於mysqld_multi薦MySql
- oracle一個例項配置多個listener或多個埠Oracle
- 自動重新啟動oracle例項 for windowsOracleWindows
- 2 Day DBA-管理Oracle例項-關閉和啟動Oracle例項-使用OEMDC關閉和啟動Oracle例項Oracle
- oracle 多個例項監聽不到Oracle
- C# 只啟動一個例項完全解決方案C#
- oracle一個別例項配置多個listener或多個埠Oracle
- 3.1.5.5 啟動例項到限制模式模式
- 配置單例項自動重啟單例
- 啟動oracle例項最少引數Oracle
- 【MySQL】MySQL主從配置幾個重要的啟動選項含義MySql
- windows下啟動服務時不啟動oracle例項WindowsOracle
- java多型-優化上個例項Java多型優化
- oracle 多個例項安裝監聽Oracle
- 一個例項中,多個synchronized方法的呼叫synchronized