Archive for February 2009

設定 mysql 成 master / slave 架構

準備兩台 mysql server , 用 vmware ESX server , clone 了兩台出來 , 也順便把 dbs 的 aggregator 弄了一套在上面
e2e8905137d0c2753f1eb106aa59eee4

  1. 加個 master 端的 repl 帳號 , 只允許 REPLICATION SLAVE 權限
    GRANT REPLICATION SLAVE ON *.* TO ‘repl’@'%’ IDENTIFIED BY ‘xxxxxx’;
    – 小心 % 要改一下!
  2. Setting the Replication Master Configuration 改 master 的 /etc/my.cnf 檔
    [mysqld]
    log-bin=mysql-bin
    server-id=1
  3. Setting the Replication Slave Configuration 改 slave 的 /etc/my.cnf 檔 , 主要是設 server-id , 把那個 log-bin=mysql-bin 註解掉
  4. 把 master 要 replication 的 database 搬一份到 slave

    in master server:

    cd /var/lib/mysql

    tar cf – db_item/ | ssh root@172.30.0.183 ‘cd /var/lib/mysql/ ; tar xf –’

    ( 172.30.0.183 是此例的 slave )

  5. Setting Up Replication with New Master and Slaves
  6. unlock master

    in master:

    unlock tables;

  7. startup slave ,

    execute change master to command:

    change master to master_host=’172.30.0.182′ , master_user=’repl’ , master_password=’xxxxx’ , master_log_file=’mysql-bin.000005′, master_log_pos=791;

  8. in slave:

    start slave;
  9. done!

解決 error while loading shared libraries 的方法

執行程式時, 若遇到

./update_item: error while loading shared libraries: libsqlrclientwrapper-0.40.so.1: cannot open shared object file: No such file or directory

像這樣的錯誤訊息 , 表示程式中所需的 so 檔(share library) 沒找到 , 要修改 /etc/ld.so.conf 加上這個目錄 , 改完要下 ldconfig –v 讓路徑生效

可以用 ldd 看該程式所使用到的 shared library 有那些, 及 lib 路徑

—–

以下是 gentoo 的標準解法 , 其他版本的 linux 則不太相同!!

cat /etc/ld.so.conf   這個檔是由 env-update 產生的 , 所以再繼續看一下 /etc/env.d 下 , 究竟有啥

# ld.so.conf autogenerated by env-update; make all changes to
# contents of /etc/env.d directory
/usr/local/lib
/usr/i686-pc-linux-gnu/lib
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1
/usr/local/firstworks/lib

參考資料, 這是 compile sqlrelay 列出來的 information

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

———————————————————————-

/bin/sh ../../libtool –mode=finish /usr/local/firstworks/lib

PATH=”$PATH:/sbin” ldconfig -n /usr/local/firstworks/lib

———————————————————————-

Libraries have been installed in:

/usr/local/firstworks/lib

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR’

flag during linking and do at least one of the following:

- add LIBDIR to the `LD_LIBRARY_PATH’ environment variable

during execution

- add LIBDIR to the `LD_RUN_PATH’ environment variable

during linking

- use the `-Wl,–rpath -Wl,LIBDIR’ linker flag

- have your system administrator add LIBDIR to `/etc/ld.so.conf’

在 /etc/env.d 下建立一個 90sqlrelay

內容是

LDPATH="/usr/local/firstworks/lib"

再run : env-update , 就看到 /etc/ld.so.conf 多了正確的 lib path 了

sqlrelay : install / settings / history / tunning 方法

step1. 裝 sqlrelay 前要先裝 Rudiments 的 library , 現在抓 rudiments 0.32 版.

PATH="$PATH:/sbin" ldconfig -n /usr/local/firstworks/lib

Libraries have been installed in:
/usr/local/firstworks/lib

他有提到幾點

- add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
- use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf’

—->解決 lib 問題 : ld.so.conf

step2. 裝 sqlrelay , 抓

  • wget http://downloads.sourceforge.net/sqlrelay/sqlrelay-0.40.tar.gz?modtime=1231398430&big_mirror=0
  • configure , make , make install
  • 檢查是否有 sql_relay.so : find / -name sql_relay.so -print
    /usr/lib/php5/lib/php/extensions/no-debug-non-zts-20060613/sql_relay.so
  • gentoo 在 /etc/php 下的兩個環境 : apache2-php5 , cli-php5 目錄 裡面的 ext , ext-active 都要有這個 file : sqlrelay.ini , 內容是
    extension=sql_relay.so
  • 找安裝程式把 libsqlrclientwrapper*so* 放在哪個目錄 , 再修改 /etc/ld.so.conf 加上這個目錄 , 改完要下 ldconfig –v 讓路徑生效

Tuning SQL Relay -

http://sqlrelay.sourceforge.net/sqlrelay/tuning.html

這邊提到一些改善 SQL Relay 效能的方法, 不過這些方法也適用於一些 networked daemon 的 tunning

如 下 sysctl -a|grep timeout 看到

net.ipv4.tcp_fin_timeout = 60 設成 30 ,
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout

tcp_tw_recycle , tcp_tw_reuse 這兩個 default 是 0 (關起來的) 設成 1 ,
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle

——–
cat /etc/sysctl.conf
net.ipv4.ip_local_port_range = “1024 65535″ —> 這個在 gentoo 好像無效
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

Protected: [old] sqlrelay : install / settings / history

This post is password protected. To view it please enter your password below:


chroot 最簡單的作法

用 gentoo 的 stage3-x86-2008.0.tar.bz2

建一個 /chroot 目錄 , 把 stage3-x86-2008.0.tar.bz2 解到這目錄 , 要 copy 這幾個 file 到 /chroot 下對應的目錄, /etc/resolv.conf /etc/fstab

下 chroot /chroot /bin/bash 就進入到 gentoo 預建好的 tree 中了 ,

要 env-update ; source /etc/profile

另外可以把 /chroot/etc/passwd 那邊有關帳號的修改一下, 譬如取消 root 帳號

Protected: [ruten] memcache usage

This post is password protected. To view it please enter your password below:


Protected: [ruten] sqlrelay version / list / status

This post is password protected. To view it please enter your password below:


mysql的資料移轉到oracle, MySQL to Oracle Migration / convert Tool

Protected: [ruten] oracle buyrank schema

This post is password protected. To view it please enter your password below:


wii iso update

Cars
Cars.Mater.National
Lego_Batman
Need_for_speed_Carbon
pcn-nfsp_Need_for_speed_prostreet
Super_Mario_Galaxy
Tiger Woods 08 Wii NTSC-U
winter_game_2008

2/3

Doraemon

台北郊區散步的好地點 bookmarks

舊曆年假期很長 , 台北市好像變空城 , 但是去熱門的景點像陽明山,寺廟等人又很多 , 這時去這些郊山走走很不錯.

內湖:內湖親山步道 / 碧山嚴 / 金龍寺 / 鯉魚山步道
http://www.mobile01.com/waypointdetail.php?id=5787
http://www.mobile01.com/waypointdetail.php?id=475
http://www.mobile01.com/waypointdetail.php?id=473

軍艦岩
http://www.mobile01.com/waypointdetail.php?id=5955

政大
http://www.mobile01.com/waypointdetail.php?id=4388

狗殷勤古道 – 平菁街
http://www.mobile01.com/waypointdetail.php?id=4266
http://www.tonyhuang39.com/tony0550/tony0550.html

坪頂古圳 – 內雙溪 – 至善路三段370巷29號
http://www.mobile01.com/waypointdetail.php?id=4260

台北大湖-內湖休閒農場
http://www.mobile01.com/waypointdetail.php?id=4041

社子島堤防景觀工程(社子左岸)
http://www.mobile01.com/waypointdetail.php?id=3122

平等里的櫻花(2007年2月)
http://www.mobile01.com/waypointdetail.php?id=2662

步道 guide

  1. http://www.yougoipay.com/kenny/
  2. http://www.tonyhuang39.com/index.html
  3. http://gohiking.myweb.hinet.net/index.htm