標籤:
1. 源碼包下載:http://download.softagency.net/MySQL/Downloads/MySQL-5.1/
2. 編譯安裝
groupadd mysqluseradd -r -g mysql mysqlmkdir /data/mysql_multi/mysql_exa1/cd /data/mysql_multi/mysql_exa1/mkdir data binlog logmkdir /data/mysql_multi/mysql_exa2/cd /data/mysql_multi/mysql_exa2/mkdir data binlog logchown -R mysql:mysql /data/mysql_multi/mysql_exa2/ /data/mysql_multi/mysql_exa1/cd /data/installs/mysql-5.1.73./configure --prefix=/usr/local/mysql5.1 makemake install cd /usr/local/mysql5.1/bin/./mysql_install_db --user=mysql --basedir=/usr/local/mysql5.1 --datadir=/data/mysql_multi/mysql_exa1/data/ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql5.1 --datadir=/data/mysql_multi/mysql_exa2/data/cp -rp ../share/mysql/mysqld_multi.server /etc/init.d/mysql_multi #複製開機檔案vim /etc/init.d/mysql_multi #修改basedir 和 datadir
3. 配置多執行個體
[mysqld_multi]mysqld = /usr/local/mysql5.1/bin/mysqld_safemysqladmin = /usr/local/mysql5.1/bin/mysqladminuser = root #管理執行個體時指定的使用者名稱和密碼password = 1234[client]#port = 3306#socket = /data/mysql_multi/mysql_exa1/mysql.sock[mysqld3307]server-id = 3307port = 3307socket = /data/mysql_multi/mysql_exa1/mysql.sockpid-file = /data/mysql_multi/mysql_exa1/mysql.piddatadir = /data/mysql_multi/mysql_exa1/datalog-error = /data/mysql_multi/mysql_exa1/log/error.loglong_query_time = 1slow_query_log_file = /data/mysql_multi/mysql_exa1/log/slow-query.loglog-bin = /data/mysql_multi/mysql_exa1/binlog/mysql-binlog-bin-index = /data/mysql_multi/mysql_exa1/binlog/mysql-bin.indexexpire_logs_days = 2binlog_format=mixedskip-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8M[mysqld3308]server-id = 3308port = 3308socket = /data/mysql_multi/mysql_exa2/mysql.sockpid-file = /data/mysql_multi/mysql_exa2/mysql.piddatadir = /data/mysql_multi/mysql_exa2/datalog-error = /data/mysql_multi/mysql_exa2/log/error.loglong_query_time = 1slow_query_log_file = /data/mysql_multi/mysql_exa2/log/slow-query.loglog-bin = /data/mysql_multi/mysql_exa2/binlog/mysql-binlog-bin-index = /data/mysql_multi/mysql_exa2/binlog/mysql-bin.indexexpire_logs_days = 2binlog_format=mixedskip-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8M[mysqldump]quickmax_allowed_packet = 16M[mysql]no-auto-rehash[myisamchk]key_buffer_size = 20Msort_buffer_size = 20Mread_buffer = 2Mwrite_buffer = 2M[mysqlhotcopy]interactive-timeout
4. 啟動多執行個體
[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi start 3307[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi start 3308[email protected]192.168.100.246:/usr/local/mysql5.1/bin# netstat -lntp | grep mysql tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 26218/mysqld tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 31910/mysqld tcp 0 0 0.0.0.0:3308 0.0.0.0:* LISTEN 32154/mysqld
5. 關閉多執行個體
5.1 分別設定密碼
[email protected]192.168.100.246:/usr/local/mysql5.1/bin# mysql -uroot -p -S /data/mysql_multi/mysql_exa1/mysql.sock #指定sock檔案路徑登入Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.1.73-log Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> set password=password(‘1234‘);Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)[email protected]192.168.100.246:/usr/local/mysql5.1/bin# mysql -uroot -p -S /data/mysql_multi/mysql_exa2/mysql.sockEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.1.73-log Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> set password=password(‘1234‘);Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
5.2 關閉執行個體
[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi stop 3307[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi stop 3308 [email protected]192.168.100.246:/usr/local/mysql5.1/bin# netstat -lntp | grep mysqltcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 26218/mysqld
6. 注意事項
6.1 mysql_multi.log預設路徑:/usr/local/mysql5.1/share/mysqld_multi.log
6.2 新加執行個體時,只需要在設定檔加上執行個體相關配置,啟動執行個體即可,停止執行個體也類似
mysql-5.1.73多執行個體安裝啟動