關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 優化 MySQL 伺服器效能

    Posted on February 27th, 2006 Sam Tang 2 comments

    最理想是在安裝時已做好優化,但如果已經安裝好 MySQL 後才需要做優化的話,可以通過設定 /etc/my.cnf 來做。如果不熟悉 my.cnf 內的設定也沒關係,可以直接使用 MySQL 的範例檔,在 /usr/share/mysql/ 下會有 my-huge.cnf, my-large.cnf, my-medium.cnf 及 my-small.cnf 幾個檔案,根據伺服器的硬件而選擇適合的檔案:

    • my-huge.cnf: 適合 1GB – 2GB RAM的主機使用。
    • my-large.cnf: 適合 512MB RAM的主機使用。
    • my-medium.cnf: 只有 32MB – 64MB RAM 的主機使用,或者有 128MB RAM 但需要運行其他伺服器,例如 web server。
    • my-small.cnf: 記憶體少於 64MB 時適用這個,MySQL 會佔用較少資源。

    我選用了 my-large.cnf,只要執行以下指令便完成了,但如果你原先已經有 my.cnf,請先備份起來及自行調整:

    shell> cp /usr/share/mysql/my-large.cnf /etc/my.cnf
    shell> /etc/init.d/mysqld restart

    以上的第二句是重新啟動 MySQL,請根據你的系統設定修改。


     

    2 responses to “優化 MySQL 伺服器效能”

    1. [...] 資料來源: Real-Blog   [...]

    2. [...] mytop – a top clone for MySQL [...]

    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word