項目中需要用到Memcached,前期的測試,都是在Win上做的.而我們的服務器卻是Solaris的.為了測試在Solaris上的性能.則需要在服務器上安裝Memcached.因為之前沒有弄過這個東西,所以安裝的過程也遇到了很多的問題.
還好在Solaris下,有一個專門的工具
Cool Stack,它是一個Apache,PHP,MySql的簡易安裝包.現在的版本是1.3.1.很慶幸,在這個安裝包中,同樣也包含Memcached.
從
http://cooltools.sunsource.net/coolstack/下載Cool Stack的運行環境和Memcached的安裝包.
分別是:CSKruntime_1.3.1_i386.pkg.bz2和CSKmemcached_1.3.1_i386.pkg.bz2.
下載后上傳到Solaris上.
之后進行解壓.
bunzip2 CSKruntime_1.3.1_i386.pkg.bz2
bunzip2 CSKmemcached_1.3.1_i386.pkg.bz2
解壓后,
使用Root賬號登錄.
之后使用pkgadd來安裝兩個包,記住要加-d.
pkgadd -d CSKruntime_1.3.1_i386.pkg
pkgadd -d CSKmemcached_1.3.1_i386.pkg
很容易的就安裝成功了.
之后進入到目錄:/opt/coolstack/bin中.
你就會看到目錄里有一個memcached了.
執行./memcached -h
如果你能看到像下面的內容一樣,就證明你安裝成功了.
1
memcached 1.2.5
2
-p <num> TCP port number to listen on (default: 11211)
3
-U <num> UDP port number to listen on (default: 0, off)
4
-s <file> unix socket path to listen on (disables network support)
5
-a <mask> access mask for unix socket, in octal (default 0700)
6
-l <ip_addr> interface to listen on, default is INDRR_ANY
7
-d run as a daemon
8
-r maximize core file limit
9
-u <username> assume identity of <username> (only when run as root)
10
-m <num> max memory to use for items in megabytes, default is 64 MB
11
-M return error on memory exhausted (rather than removing items)
12
-c <num> max simultaneous connections, default is 1024
13
-k lock down all paged memory. Note that there is a
14
limit on how much memory you may lock. Trying to
15
allocate more than that would fail, so be sure you
16
set the limit correctly for the user you started
17
the daemon with (not for -u <username> user;
18
under sh this is done with 'ulimit -S -l NUM_KB').
19
-v verbose (print errors/warnings while in event loop)
20
-vv very verbose (also print client commands/reponses)
21
-h print this help and exit
22
-i print memcached and libevent license
23
-b run a managed instanced (mnemonic: buckets)
24
-P <file> save PID in <file>, only used with -d option
25
-f <factor> chunk size growth factor, default 1.25
26
-n <bytes> minimum space allocated for key+value+flags, default 48
27
-L Try to use large memory pages (if available). Increasing
28
the memory page size could reduce the number of TLB misses
29
and improve the performance. In order to get large pages
30
from the OS, memcached will allocate the total item-cache
31
in one large chunk.
32
-t <num> number of threads to use, default 4
哈.現在你可以將Memcached啟動起來進行測試啦.
./memcached -d -m 2048 -l 10.10.13.240 -P 11211
關于Memcached的使用.網上有很多教程.
可以參見.
PS:這兩天被這個問題給郁悶壞了.
新裝的Solaris服務器.
要安裝Memcached,首先要安裝libevent.
網上提供的都是需要自己編譯,安裝的.
這就需要在系統中安裝gcc和make.
裝這兩個東西倒沒有什么問題.
可是在安裝libevent的時候,遇到了好多的問題.
做C的同事也幫著弄了好久,才勉強將它安裝上,其間還改了源代碼....
可是Memcached卻始終提示找不到libevent.
無論你是否指定libevent的路徑.都不行.
我在自己的Ubuntu上裝了一下,一點問題也沒有.
快要放棄的時候,在Sun的網站上看到了可以使用Cool Stack來安裝Memcached.
才讓自己看了希望.
還好,功夫不負有心人.
現在已經開始進行Memcached的測試了.
終于把這個狗屎問題解決了.