標籤:style http color os io strong 檔案 ar
關於Mysql Proxy LUA讀寫分離是本文要介紹的內容,主要是來瞭解Mysql Proxy LUA的學習內容,具體內容來看本文詳解,先來下載匹配的版本:
- http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/
下載最新版的二進位版本以mysql-proxy-0.8.0-linux-glibc2.3-x86-32bit為例。www.lua.org 下載lua。
1.通過mysql代理mysql-proxy來實現mysql的讀寫分離。
MySQL Proxy 安裝地址:192.168.0.234(寫,也可將mysql-proxy安裝在第三台伺服器上)
MySQL 伺服器位址:192.168.0.235(讀)
2.安裝mysql-proxy
- apt-get install mysql-proxy
這樣安裝好之後在/usr/lib/mysql-proxy/lua/proxy/裡面是沒有rw-splitting.lua檔案的,將下載導的lua二進位版本裡面share/doc/mysql-proxy/下面的rw-splitting.lua這個檔案拷貝到/usr/lib/mysql-proxy/lua/proxy/
3.啟動mysql-proxy
若不存在則建立mysql-proxy日誌目錄 mkdir /var/log/mysql-proxy/
啟動mysql-proxy命令:
- mysql-proxy --proxy-read-only-backend-addresses=192.168.0.235:3306
- --proxy-backend-addresses=192.168.0.234:3306
- --proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/rw-splitting.lua > /var/log/mysql-proxy/mysql-proxy.log &
啟動狀態:
- [email protected]:~# mysql-proxy --proxy-read-only-backend-addresses=192.168.0.235:3306
- --proxy-backend-addresses=192.168.0.234:3306
- --proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/rw-splitting.lua > /var/log/mysql-proxy/mysql-proxy.log &
- [1] 1584
- [email protected]:~# 2010- 03-11 01:53:36: (warning) g_set_prgname() called multiple times
- 2010-03-11 01:53:36: (critical) chassis.c:980: could not raise RLIMIT_NOFILE to 8192,
- Invalid argument (22). Current limit still 13214421558589654016.
然後查看連接埠,mysql-proxy預設連接埠是4040和4041
- lsof -i:4040
-
- [email protected]:~# lsof -i:4040
- COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
- mysql-pro 1584 root 7u IPv4 6018 0t0 TCP *:4040 (LISTEN)
這樣就表示mysql-proxy已經啟動成功。
亂碼處理在設定檔my.conf裡server-id下面加入
- skip-character-set-client-handshake
- init-connect=‘SET NAMES utf8‘
- default-character-set=utf8