標籤:多執行個體
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多執行個體