MySQL-Proxy for CentOS 5 Installation Guide

雖說CentOS 5在 EPEL Repository有mysql-proxy, 但是那是0.5.x 的版本, 要用比較新的0.8.x, 目前沒有看到, 所以花時間去試了一下.

  1. 安裝一套CentOS5, 我實驗的VM是使用CentOS 5.6, 只裝了基本的Base跟Develop Tools
  2. 先做一次yum -y update, 更新一些套件到最新
  3. 安裝RPMForge & EPEL Repositories
  4. 再做一次yum -y update, 更新一些套件到最新
  5. 安裝一些必須的套件:

    yum -y install install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers flex libtiff-devel pam-devel pkgconfig readline-devel zlib-devel libevent-devel
  6. libevent網站抓libevent來裝, CentOS附的太舊

    # wget http://monkey.org/~provos/libevent-2.0.12-stable.tar.gz
    # tar -zxpvf libevent-2.0.12-stable.tar.gz
    # cd libevent-2.0.12-stable
    # ./configure –prefix=/usr/local
    # make all install
  7. LUA網站抓新的LUA來裝, CentOS附的太舊

    # wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
    # tar -zxpvf lua-5.1.4.tar.gz
    # cd lua-5.1.4
    # vi src/Makefile

    修改CFLAGS, 在後頭加入 -fPIC

    # make linux install
    # cp src/lua.pc /usr/local/lib/pkgconfig

  8. 這裡 自己複製一份magic.h, 放置到 /usr/include/linux/magic.h, 後頭裝glib2會用到
  9. GTK+網站抓glib2回來裝, CentOS附的太舊

    # wget http://ftp.gnome.org/pub/gnome/sources/glib/2.28/glib-2.28.0.tar.bz2
    # bzip2 -d -c glib-2.28.0.tar.bz2 | tar -xpvf –
    # cd glib-2.28.0
    # ./configure –prefix=/usr/local
    # make all install
  10. 要Build mysql-proxy 之前先設定好一些環境變數, 否則會去用到CentOS內附的舊版本

    # export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
    # export LUA_CFLAGS=”-I/usr/local/include” LUA_LIBS=”-L/usr/local/lib -llua -ldl” LDFLAGS=”-lm”
    # export GLIB_CFLAGS=”-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include”
    # export GLIB_LIBS=”-L/usr/local/lib -lglib-2.0″
    # export GMODULE_CFLAGS=”-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include”
    # export GMODULE_LIBS=”-L/usr/local/lib -lgmodule-2.0″
  11. 終於可以開始build mysql-proxy了, 去 MySQL Proxy網站抓Source, 這裡有Mirror.

    # wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/mysql-proxy-0.8.1.tar.gz
    # tar -zxpvf mysql-proxy-0.8.1.tar.gz
    # cd mysql-proxy-0.8.1
    # ./configure –prefix=/usr/local
    # make all install

  12. 這樣就完成了, 可以執行mysql-proxy -V 確認, 以下是我跑出來的結果

    # /usr/local/bin/mysql-proxy -V
    mysql-proxy 0.8.1
    chassis: mysql-proxy 0.8.1
    glib2: 2.28.0
    libevent: 2.0.12-stable
    LUA: Lua 5.1.4
    package.path: /usr/local/lib/mysql-proxy/lua/?.lua
    package.cpath: /usr/local/lib/mysql-proxy/lua/?.so
    — modules
    admin: 0.8.1
    proxy: 0.8.1

至於裝好之後的設定, 不是這篇要講的, 這裡幫大家裝起來就好 🙂

Comments
  • johnpupu 27 6 月, 2011 at 09:32

    深深的覺得有ports真好

  • […] Replication (Master-Slave) for CentOS Installation Guide(後文各稱為Master/Slave), 再參考MySQL-Proxy for CentOS 5 Installation Guide安裝好一台MySQL-Proxy(後文稱為Proxy), […]

  • Post a comment

    Threaded commenting powered by interconnect/it code.