mysql多執行個體

來源:互聯網
上載者:User

標籤:多執行個體

1、解決依賴關係:
    yum install ncurses-devel -y
    yum install libaio-devel -y
2、建立使用者和組;
    groupadd mysql
    useradd -s /sbin/nologin -g mysql -M mysql
3、建立設定檔目錄
    mkdir /data/{3306,3307}/data -p
     tree /data                     
    /data
    |-- 3306
    |   `-- data
    `-- 3307
             -- data

    4 directories, 0 files

4、 解壓、拷貝設定檔(見附件data.zip),且授權;
    chown -R mysql.mysql /data/
    find /data/ -type f -name "mysql" | xargs chmod +x


5、初始化資料庫

   cd /application/mysql/scripts/
   ./mysql_install_db --user=mysql --datadir=/data/3306/data/ --basedir=/application/mysql/

    OK
    Filling help tables...
    OK  

    #表示成功!

     ./mysql_install_db --user=mysql --datadir=/data/3307/data/ --basedir=/application         /mysql/
6、啟動資料庫:  /data/3306/mysql start
                 /data/3307/mysql start
         查看: ss -lnt|grep 330
-------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
7、啟動:
    /data/3306/mysql start                             

    Starting MySQL...
    /data/3307/mysql start
    Starting MySQL...
    連接埠查看:ss -lntup |grep mysql

8、開機自啟動
     echo "#mysql multi instances" >>/etc/rc.local
     echo "/data/3306/mysql start" >>/etc/rc.local
     echo "/data/3307/mysql start" >>/etc/rc.local 

9、登入: mysql -S /data/3306/mysql.sock
          mysql -S /data/3307/mysql.sock

10、




備忘:使用附件提供的多執行個體設定檔建立多執行個體時要注意修改設定檔的連接埠號碼和登入密碼;tmp目錄的許可權不要隨意修改。

-----------------------------------------------------------------------------------------
排查:連接埠慢 lsof -i :3306,

      觀察日誌錯誤;

      細看所有執行命令返回的輸出,

      查看/var/log/message
-------------------------------------------------------------------------------------------
錯誤:
141101 18:14:51 mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information解決:

解決

sed -i ‘s#/usr/local/mysql/#/application/mysql#g‘ /application/mysql/bin/mysqld_safe
sed -i ‘s#/application/mysql#/application/mysql/#g‘ /application/mysql/bin/mysqld_safe

-------------------------------------------------------------------------------------------

如果遇到環境變數的問題時:

      w        which + 錯誤

         echo $PATH

  echo "export PATH=/application/mysql/bin:$PATH">>/etc/profile

  ./etc/profile

或者cp -ap /application/mysql/bin/* /usr/local/sbin/

-------------------------------------------------------------------------------------------

本文出自 “一如既往” 部落格,謝絕轉載!

mysql多執行個體

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.