Archive for the ‘System/Linux/Unix*’ Category.

[note] ubuntu 裝 LAMP 的 guide (中文)

wow! MooseFS vs. NFS

URL = http://www.ccok.me/page/read/200

MooseFS = http://www.moosefs.org/

結果是 MooseFS 勝 NFS 2-3倍!!

FreeBSD + apache with large connection settings

solved 如下:

一、  網站的 Search功能因為使用 Ajax的方式,在大量User使用下,造成 Mysql 連線問題而影響 Apahce.

二、  因為新網站為全新製作,所有舊有的網址(包含 Search Agent、各大討論區、子公司…)會全部導回首頁 (Rewrite)…

在大量存取下,短時間產生Mysql、Apache連線,影響mysql與apache 的效能…

 

 

 

problem: 大量出現…

Approaching the limit on PV entries, consider increasing either the vm.pmap.shpgperproc or the vm.pmap.pv_entry_max

===> MaxClients  設太大

這兩個有設

FreeBSD: append to /etc/sysctl (or you can use sysctl -w to add these)

kern.maxfiles=65536
kern.maxfilesperproc=32768

如下:

一、 網站的 Search功能因為使用 Ajax的方式,在大量User使用下,造成 Mysql 連線問題而影響 Apahce.

二、 因為新網站為全新製作,所有舊有的網址(包含 Search Agent、各大討論區、子公司…)會全部導回首頁 (Rewrite)

在大量存取下,短時間產生MysqlApache連線,影響mysqlapache 的效能…

Use subversion on Dropbox steps

這麼一來, 可以用 Dropbox 的地方就可以輕鬆的 check out code 了 (y)

Continue reading ‘Use subversion on Dropbox steps’ »

Subversion Server Notes

postfix , 寄 yahoo 的信改由 hinet 的 smtp 發 , 用 telnet command 測試對方 smtp 通不通

cat main.cf
transport_maps = regexp:/etc/postfix/transport

cat transport
.*\.yahoo\..*   smtp:[msa.hinet.net]

telnet smtp.test.com.tw 25

HELO test.com.tw
mail from:test@test.com.tw
rcpt to:test@testdomain.com.tw
data
Subject:test
xxxxxxxxxxx

linux mount windows share directory / cifs / samba

在 /etc/fstab 加一行:

//192.168.100.1/ruten /rutenlog cifs user,rw,suid,username=XXX,password=YYY 0 0

Maximum Availability Architecture – Oracle Streams Configuration Best Practices

Oracle doc PDF URL : http://dn.monster.tw/my/docs/oracle/MAA_10gR2_Streams_Configuration.pdf

Oracle® Streams Advanced Queuing User’s Guide and Reference
10g Release 2 (10.2) –
http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/toc.htm

sample memo: http://www.monster.com.tw/archives/2565

Oracle Maximum Availability Architecture – Overview – http://www.oracle.com/technology/deploy/availability/htdocs/maaoverview.html

[設定/memo] PL/SQL Developer , plsql 免設 tnsname 檔的方法

在 Database 那格用這種格式: IP_ADDRESS/SERVICE_NAME

擷取PLSQL

Protected: [收藏] Linux Embedded system step by steps – PDF / debian / linux booting steps

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


RSA token VPN

route add 172.0.0.0 mask 255.0.0.0 172.30.0.51

R0013869

1

screen

XP 版的比較複雜

擷取-rsa-1

擷取-rsa-2

Protected: amazon ec2 實作參考資料

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


開啟 vmware esxi server virtual switch Promiscuous Mode 的方法 – for sniff network purpose

要研究這麼深?! 沒辦法, 最近遇到奇怪問題非得啟用 Promiscuous Mode 來看看發生啥事了.

設定 step by step 看圖:056a3fd358a30a988ad401d605afe440

 

這是 免費的 sniff tools: http://www.ethereal.com/

gentoo emerge command

升級系統/世界

emerge -uDN system ( world )

升級完世界 把多餘的東西砍掉

emerge --depclean

檢查 library 一致?

revdep-rebuild

用vmware , frame buffer I/O很慢 , 要加 -q

安裝被keywords mark起來的ebuild

把 ebuild 名稱加到 /etc/portage/package.keywords 就可以了

在 /etc/make.conf 加 ACCEPT_KEYWORDS=”~amd64″

裝特定版本的 package

emerge =www-servers/apache-2.x.x
cd /
mount -t proc proc /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
cp -L /etc/resolv.conf /mnt/gentoo/etc/
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile

[gentoo] 排除舊的 lib 相容問題

 * Messages for package sys-devel/libtool-2.2.6b:

 * Old versions of installed libraries were detected on your system.
 * In order to avoid breaking packages that depend on these old libs,
 * the libraries are not being removed.  You need to run revdep-rebuild
 * in order to remove these old dependencies.  If you do not have this
 * helper program, simply emerge the 'gentoolkit' package.
 *
 *   # revdep-rebuild --library libltdl.so.3
 *
 * Once you've finished running revdep-rebuild, it should be safe to
 * delete the old libraries.  Here is a copy & paste for the lazy:
 *   # rm '/usr/lib64/libltdl.so.3'

下了 revdep-rebuild –library libltdl.so.3 會

 * Configuring search environment for revdep-rebuild

 * Checking reverse dependencies
 * Packages containing binaries and libraries using libltdl.so.3
 * will be emerged.

 * Collecting system binaries and libraries
 * Generated new 1_files.rr
 * Checking dynamic linking
[ 55% ]  *   found /usr/lib64/apache2/modules/libphp5.so
[ 80% ]  *   found /usr/lib64/php5/bin/php
[ 100% ]
 * Generated new 3_broken.rr
 * Assigning files to packages
 *   /usr/lib64/apache2/modules/libphp5.so -> dev-lang/php
 *   /usr/lib64/php5/bin/php -> dev-lang/php
 * Generated new 4_raw.rr and 4_owners.rr
 * Cleaning list of packages to rebuild
 * Generated new 4_pkgs.rr
 * Assigning packages to ebuilds
 * Generated new 4_ebuilds.rr
 * Evaluating package order
 * Generated new 5_order.rr
 * All prepared. Starting rebuild
emerge --oneshot  dev-lang/php:5
..........

常下的查網路狀態的指令 Analyzing network traffic

tcpdump -nn -i eth1 -c 10000 port 9000 | awk '{print $5}' | cut -d. -f1-4 | sort | uniq -c | sort -n

tcpdump -nn -e -i eth1 port 9000

arping -I eth1 172.25.1.131

Protected: sqlrelay server install steps

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


Protected: oracle problem 2010.0131

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


把 fstab 改壞了, 怎麼辦? Booting into Rescue Mode

開機進入 single user mode 了, 那 / 都 mount 成了 read-only 怎改 /etc/fstab 呢?

mount -o remount,rw /

另外可以參考這篇講 Redhat 的 rescue mode steps : http://bbs.518z.net/read-htm-tid-242.html

memcached 真的很有意思 …

這個版本 support multiple instance

 * With this version of Memcached Gentoo now supports multiple instances.
 * To enable this you should create a symlink in /etc/init.d/ for each instance
 * to /etc/init.d/memcached and create the matching conf files in /etc/conf.d/
 * Please see Gentoo bug #122246 for more info

05929b98e034c6f1fb1ddd8e4f5d3c2b

1ed5bf4a492226219ef0f75806f020e2

MEMCACHED_BINARY="/usr/bin/memcached"
MEMUSAGE="64"
MEMCACHED_RUNAS="memcached"
MAXCONN="1024"
LISTENON="172.30.0.43"
PORT="11212"  <---- 改!
UDPPORT="${PORT}"
PIDBASE="/var/run/memcached/memcached"
MISC_OPTS=""

啟動後:

 9312 ?        Ssl    0:00 /usr/bin/memcached -d -p 11211 -U 11211 -l 172.30.0.43 -m 64 -c 1024 -u memcached -P /var/run/memcached/memcached-.memcached1.pid
 9366 ?        Ssl    0:00 /usr/bin/memcached -d -p 11212 -U 11212 -l 172.30.0.43 -m 64 -c 1024 -u memcached -P /var/run/memcached/memcached-.memcached2.pid
 9420 ?        Ssl    0:00 /usr/bin/memcached -d -p 11213 -U 11213 -l 172.30.0.43 -m 64 -c 1024 -u memcached -P /var/run/memcached/memcached-.memcached3.pid
 9474 ?        Ssl    0:00 /usr/bin/memcached -d -p 11214 -U 11214 -l 172.30.0.43 -m 64 -c 1024 -u memcached -P /var/run/memcached/memcached-.memcached4.pid
 

下 , netstat -t -u -an 可以看到 ….

c295476c11cc99e65c30b962974254b9

它的 memcache client API for php 有新舊兩個版, 之前只參考到 PHP 官網的 manual 寫的 function 用了它的舊 API call , 造成 connection 不會自動斷線, 需要改用新的才行.

另外, memcache 改用 UDP protocol 比較省 CPU cost , 不過 memcached 的 CPU cost 本來就很低, 所以省的部份是在 memcache client 端, 也就是前台 web server 的 CPU cost 可以省一些.

這個就是 "隱藏版" 的 manual , 竟然要到 cvs 去才看得到 ORZ

http://cvs.php.net/viewvc.cgi/pecl/memcache/README?revision=1.3.2.1&view=markup

initial revision

memcached module for PHP

————————

This module requires zlib library, used for on-the-fly data (de)compression.

Also, you’ll need memcached to use it =)

The memcached website is here:

http://www.danga.com/memcached/

You will probably need libevent to install memcached:

You can download it here: http://www.monkey.org/~provos/libevent/

New API in 3.0

————————

Version 3 introduces a new class "MemcachePool" which implements the new API, the

old class "Memcache" is still retained (but is deprecated) with the same interface

for backwards compatibility. Please note that you need a new memcached version to

use the CAS, default value to increment/decrement, append and prepend, and binary

protocol features.

New INI directives are available to allow control over protocol, redundancy and hash

strategy selection. These are

# The binary protocol results in less traffic and is more efficient

# for the client and server to generate/parse

memcache.protocol = {ascii, binary} # default ascii

# When enabled the client sends requests to N servers in parallel, resulting in

# a somewhat crude reduncancy or mirroring, suitable when used as a session

# storage.

#

# If data integrity is of greater importance a real replicating memcached

# backend such as "repcached" (http://sourceforge.net/projects/repcached/) is

# recommended

memcache.redundancy = <int> # default 1

memcache.session_redundancy = <int> # default 2

# Hash strategy and function selection. The consistent hashing strategy

# is now the default as it allows servers to be added and removed from

# the pool without resulting in all or most keys being re-mapped to

# other server (ie. voiding the cache)

memcache.hash_strategy = {standard, consistent} # default consistent

memcache.hash_function = {crc32, fnv} # default crc32

The directives are used by the MemcachePool constructor so you can instantiate

several pools with different settings by using ini_set() creativly. For example

ini_set(‘memcache.protocol’, ‘binary’);

$binarypool = new MemcachePool();

$binarypool->addServer(…)

ini_set(‘memcache.protocol’, ‘ascii’);

ini_set(‘memcache.redundancy’, ’2′);

$redundantpool = new MemcachePool();

$redundantpool->addServer(…)

ini_set(‘memcache.redundancy’, ’1′);

The new interface looks like

class MemcachePool() {

bool connect(string host, int tcp_port = 11211, int udp_port = 0, bool persistent = true, int weight = 1, int timeout = 1, int retry_interval = 15)

bool addServer(string host, int tcp_port = 11211, int udp_port = 0, bool persistent = true, int weight = 1, int timeout = 1, int retry_interval = 15, bool status = true)

bool setServerParams(string host, int tcp_port = 11211, int timeout = 1, int retry_interval = 15, bool status = true)

/**

* Supports fetching flags and CAS values

*/

mixed get(mixed key, mixed &flags = null, mixed &cas = null)

/**

* Supports multi-set, for example

* $memcache->set(array(‘key1′ => ‘val1′, ‘key2′ => ‘val1′), null, 0, 60)

*/

bool add(mixed key, mixed var = null, int flag = 0, int exptime = 0)

bool set(mixed key, mixed var = null, int flag = 0, int exptime = 0)

bool replace(mixed key, mixed var = null, int flag = 0, int exptime = 0)

/**

* Compare-and-Swap, uses the CAS param from MemcachePool::get()

*/

bool cas(mixed key, mixed var = null, int flag = 0, int exptime = 0, int cas = 0)

/**

* Prepends/appends a value to an existing one

*/

bool append(mixed key, mixed var = null, int flag = 0, int exptime = 0)

bool prepend(mixed key, mixed var = null, int flag = 0, int exptime = 0)

/**

* Supports multi-key operations, for example

    * $memcache->delete(array(‘key1′, ‘key2′))

    */

    bool delete(mixed key, int exptime = 0)

    /**

    * Supports multi-key operations, for example

    * $memcache->increment(array(‘key1′, ‘key2′), 1, 0, 0)

    *

    * The new defval (default value) and exptime (expiration time) are used

    * if the key doesn’t already exist. They must be supplied (even if 0) for

    * this to be enabled.

    */

    mixed increment(mixed key, int value = 1, int defval = 0, int exptime = 0)

    mixed decrement(mixed key, int value = 1, int defval = 0, int exptime = 0)

    /**

    * Assigns a pool-specific failure callback which will be called when

    * a request fails. May be null in order to disable callbacks. The callback

    * receive arguments like

    *

    * function mycallback($host, $tcp_port, $udp_port, $error, $errnum)

    *

    * Where $host and $error are strings or null, the other params are integers.

    */

    bool setFailureCallback(function callback)

    }

在這邊看到 兩個 memcache php client 的比較表 : http://code.google.com/p/memcached/wiki/PHPClientComparison

PHP Client Comparison

There are primarily two clients used with PHP. One is the older, more widespread pecl/memcache and the other is the newer, less used, more feature rich pecl/memcached.

Both support the basics such as multiple servers, setting vaules, getting values, increment, decrement and getting stats.

Here are some more advanced features and information.

pecl/memcache pecl/memcached
First Release Date 2004-06-08 2009-01-29 (beta)
Actively Developed? Yes Yes
External Dependency None libmemcached
Features
Automatic Key Fixup1 Yes No
Append/Prepend No Yes
Automatic Serialzation2 Yes Yes
Binary Protocol No Optional
CAS No Yes
Compression Yes Yes
Communication Timeout Connect Only Various Options
Consistent Hashing Yes Yes
Delayed Get No Yes
Multi-Get Yes Yes
Session Support Yes Yes
Set/Get to a specific server No Yes
Stores Numerics Converted to Strings Yes
  1. pecl/memcache will convert an invalid key into a valid key for you. pecl/memcached will return false when trying to set/get a key that is not valid.
  2. You do not have to serialize your objects or arrays before sending them to the set commands. Both clients will do this for you.