創建多個 mysql-5.5 實例時出錯
我在我的測試伺服器上安裝了第三個 mysql 實例。
2 個實例已經在執行,沒有任何問題。
當我通過 mysql-5.5.30 zip 源安裝第三個實例時,它安裝成功但是當我嘗試重新啟動 mysql 的第三個實例時它說,
找不到 MySQL 伺服器 PID 文件!
$$ FAILED $$ 啟動 MySQL……………………………………………………….. ………..
伺服器退出而不更新 PID 文件。
在 3305 上執行的第一個實例
BASEDIR: /usr/local/mysql Configuration File: /etc/my.cnf Socket: /tmp/mysql.stock
在 3306 上執行的第二個實例
BASEDIR: /backup/mysql-cbt Configuration File: /backup/mysql-cbt/my.cnf Socket: /backup/mysql-cbt/mysql.stock
在 3307 上執行的第三個實例
BASEDIR: /home/mysql-5/ Configuration File: /home/mysql-5/my.cnf Socket: /home/mysql-5/mysql.stock
錯誤日誌如下。
130513 11:22:23 mysqld_safe Starting mysqld daemon with databases from /backup/mysql-cbt/data<br> 130513 11:22:23 InnoDB: The InnoDB memory heap is disabled<br> 130513 11:22:23 InnoDB: Mutexes and rw_locks use GCC atomic builtins<br> 130513 11:22:23 InnoDB: Compressed tables use zlib 1.2.3<br> 130513 11:22:23 InnoDB: Using Linux native AIO<br> 130513 11:22:23 InnoDB: Initializing buffer pool, size = 128.0M<br> 130513 11:22:23 InnoDB: Completed initialization of buffer pool<br> 130513 11:22:23 InnoDB: highest supported file format is Barracuda.<br> 130513 11:22:23 InnoDB: Waiting for the background threads to start<br> 130513 11:22:24 InnoDB: 5.5.30 started; log sequence number 1595675<br> 130513 11:22:24 [ERROR] /backup/mysql-cbt/bin/mysqld: unknown option '--safe- show- database'<br> 130513 11:22:24 [ERROR] Aborting<br> 130513 11:22:24 InnoDB: Starting shutdown...<br> 130513 11:22:25 InnoDB: Shutdown completed; log sequence number 1595675<br> 130513 11:22:25 [Note] /backup/mysql-cbt/bin/mysqld: Shutdown complete<br> 130513 11:22:25 mysqld_safe mysqld from pid file /backup/mysql-cbt/cbt-instance.pid ended
仍然無法弄清楚這個錯誤。如何啟動第三個實例?
安裝
故事從這裡開始。我已經通過源安裝了mysql:
- 將源mysql-5.5.30-linux2.6-x86_64.tar.gz提取到目錄,然後遞歸地將mysql目錄的權限更改為使用者和組mysql。
- 在 mysql 的腳本目錄中,我以 root 身份執行此命令:
[root@server /backup/mysql-cbt/scripts]# ./mysql_install_db --basedir=/backup/mysql-cbt/ --datadir=/backup/mysql-cbt/data --defaults-file=/backup/mysql-cbt/my.cnf --user=mysql** Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /backup/mysql-cbt//bin/mysqladmin -u root password 'new-password' /backup/mysql-cbt//bin/mysqladmin -u root -h 69.16.196.128 password 'new-password' Alternatively you can run: /backup/mysql-cbt//bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /backup/mysql-cbt/ ; /backup/mysql-cbt//bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /backup/mysql-cbt//mysql-test ; perl mysql-test-run.pl Please report any problems with the /backup/mysql-cbt//scripts/mysqlbug script!
當我重新啟動此實例時,它會給出更新 pid 並退出的錯誤。
缺少哪一步?
我的
my.cnf
文件(/backup/mysql-cbt/my.cnf
):[mysqld] federated basedir = /backup/mysql-cbt datadir = /backup/mysql-cbt/data log-error = /backup/mysql-cbt/cbt-instance.err pid-file = /backup/mysql-cbt/cbt-instance.pid #socket = /tmp/mysql.sock socket = /backup/mysql-cbt/mysql.sock port = 3310 user = mysql tmpdir = /backup/mysql-cbt/tmpdir
/etc/init.d/mysql_cbt
# If you want to affect other MySQL variables, you should make your changes # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. # If you change base dir, you must also change datadir. These may get # overwritten by settings in the MySQL configuration files. basedir=/backup/mysql-cbt datadir=/backup/mysql-cbt/data # Default value, in seconds, afterwhich the script should timeout waiting # for server start. # Value here is overriden by value in my.cnf. # 0 means don't wait at all # Negative numbers mean to wait indefinitely service_startup_timeout=900 # Lock directory for RedHat / SuSE. lockdir='/var/lock/subsys' lock_file_path="$lockdir/mysql" # The following variables are only set for letting mysql.server find things. # Set some defaults mysqld_pid_file_path=/backup/mysql-cbt/mysql-cbt-instance.pid if test -z "$basedir" then basedir=/usr/local/mysql-cbt bindir=/usr/local/mysql-cbt/bin if test -z "$datadir" then datadir=/backup/mysql-cbt/data fi sbindir=/backup/mysql-cbt/bin libexecdir=/backup/mysql-cbt/bin else bindir="$basedir/bin" if test -z "$datadir" then datadir="$basedir/data" fi sbindir="$basedir/sbin" libexecdir="$basedir/libexec" fi
查看錯誤日誌,您可以看到
130513 11:22:24
$$ ERROR $$/backup/mysql-cbt/bin/mysqld:未知選項’–safe-show-database'
130513 11:22:24$$ ERROR $$中止
130513 11:22:24 InnoDB:開始關閉…
在您的 MySQL 版本的文件中,您可以看到
此選項已棄用並且不執行任何操作,因為有一個 SHOW DATABASES 權限可用於控制對每個帳戶的數據庫名稱的訪問。請參閱第 6.2.1 節,“MySQL 提供的權限”。–safe-show-database 在 MySQL 5.5.3 中被移除
怎麼解決:
註釋掉或刪除
safe-show-database
您的第三個實例的 my.cnf(因為它在 MySQL 5.5 上已棄用並自 MySQL 5.5.3 起刪除)並嘗試再次啟動第三個實例。使用 mysql init.d 腳本:
如果您安裝了許多 MySQL 實例並希望通過 init.d 腳本控制它,您需要對腳本進行一些更改:
- 改變
basedir
變數- 改變
datadir
變數- 將任何提及更改
/etc/my.cnf
為/backup/mysql-cbt/my.cnf
/backup/mysql-cbt/bin/mysqld_safe --defaults-file=/backup/mysql-cbt/my.cnf &
一個不錯的my.cnf
選擇是使用命令行(知道您my.cnf
是對的,然後開始更改腳本以將其控制為服務。
隨著 MySQL 5.5…
./mysql_install_db --basedir=/backup/mysql-cbt/ --datadir=/backup/mysql-cbt/data --defaults-file=/backup/mysql-cbt/my.cnf --user=mysql
唔…
我在 5.6 GA(去年的最新版本)中做了很多這樣的事情,並且在(很多)跟踪和錯誤之後發現,它可以解決這個問題。
./scripts/mysql_install_db --defaults-file=/home/pol/Downloads/mysql/src/my.cnf
我以這種令人費解的方式這樣做的原因是我是一名學生,我想讓 MySQL 在我沒有 root 權限的大學機器上工作。它正在獲取進入 my.cnf 的內容,這是棘手的部分(至少對我而言) - 你的看起來很像我現在為 5.6 的源安裝所做的。
到目前為止,很容易。
然後出於一個我不再記得的原因(IIRC,這是為了在這裡回答一個關於 MySQL 5.5 的問題),我嘗試安裝 5.5。我的簡單腳本不起作用!我發現在(又一次**)**反複試驗之後,5.5 需要在 mysql_install_db 腳本的命令行上顯式指定不同的選項。嘗試像你一樣做,但添加 pid 文件和套接字的規範,它對我有用。也許它也適合你?