2012年5月29日 星期二
在 Apache 伺服器上使用 memcached ( LAMP 優化 )
CentOS 5.8 升級 Apache
因為 mod_memcached_cache 這個 Apache模組,僅支援 2.2.4 之後的版本方可使用,
CentOS 5.8 的預設內建的 Apache 版本為 2.2.3-xx.
故無法使用 memcached 的外掛模組.需透過下方網站所提供的方式,
透過YUM的方式將 Apache 升級至2.2.22的版本.方可啟用 memcached 功能.
http://www.jasonlitka.com/yum-repository/
rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
vi /etc/yum.repos.d/utterramblings.repo
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
RHEL 5 / CentOS 5 :
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
httpd upgrade to 2.2.22
#yum upgrade --enablerepo=utterramblings httpd*
#yum upgrade --enablerepo=utterramblings mod_*
Source
#wget http://apache.stu.edu.tw//httpd/httpd-2.2.22.tar.gz
#tar -zvxf http://apache.stu.edu.tw//httpd/httpd-2.2.22.tar.gz
Install apr_memcache
#wget http://www.outoforder.cc/downloads/apr_memcache/apr_memcache-0.7.0.tar.bz2
#tar -jvxf apr_memcache-0.7.0.tar.bz2
#cd apr_memcache-0.7.0/
#./configure --prefix=/usr/local/ --exec-prefix=/usr/local/
#make
#make install
Install mod_memcached_cache
#wget http://modmemcachecache.googlecode.com/files/mod_memcached_cache-0.1.0.tar.bz2
#tar -jxvf mod_memcached_cache-0.1.0.tar.bz2
#cd mod_memcached_cache-0.1.0
#CFLAGS="-I/usr/local/src/httpd-2.2.22/modules/cache/" ./configure --with-apxs=/usr/sbin/apxs --with-apr-memcache=/usr/local/
#make
#make install
....
* Apache Modules Directory: /usr/lib/httpd/modules
....
讓 php 支援 memcached & memcache
yum install --enablerepo=remi memcache*
yum install --enablerepo=remi libmemcached*
yum install --enablerepo=remi php-pecl-memcached
yum install --enablerepo=remi php-pecl-memcache
[root@apache]# rpm -qa | grep mem
php-pecl-memcached-2.0.1-1.el5.remi
libmemcached-1.0.4-1.el5.remi
libmemcached-devel-1.0.4-1.el5.remi
memcached-1.4.5-2.el5.remi
memcached-devel-1.4.5-2.el5.remi
php-pecl-memcache-3.0.6-2.el5.remi
mamcached 可使用系統預設的 1.4.5 版本
或 http://memcached.org/ 所提供的 v1.4.13 的版本
在這裡我是以membase取代memcached
url為 http://www.couchbase.com/membase
download url 為 http://www.couchbase.com/download
Install membase
[root@naginx ~]# rpm -ivh couchbase-server-community_x86_1.8.0.rpm
Preparing... ########################################### [100%]
1:couchbase-server ########################################### [100%]
Starting couchbase-server[ OK ]
You have successfully installed Couchbase Server.
Please browse to http://apache:8091/ to configure your server.
Please refer to http://couchbase.com/ for additional resources.
Please note that you have to update your firewall configuration to
allow connections to the following ports: 11211, 11210, 4369, 8091
and from 21100 to 21299.
By using this software you agree to the End User License Agreement.
See /opt/couchbase/LICENSE.txt.
[root@apache ~]# netstat -an | grep 11211
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN
[root@apache ~]#
vi /etc/httpd/conf/httpd.conf
======================
LoadModule memcached_cache_module modules/mod_memcached_cache.so
<IfModule mod_memcached_cache.c>
CacheEnable memcached /
MemcachedCacheServer localhost:11211
MemcachedMaxServers 10
MemcachedMinConnections 10
MemcachedSMaxConnections 10
MemcachedMaxConnections 10
MemcachedConnectionTTL 10
MemcachedCacheMinFileSize 1
MemcachedCacheMaxFileSize 2097152
CacheDisable /admin/
CacheDisable /server-status/
</IfModule>
============================
service httpd restart
============================
mod_memcached_cache 安裝參考的URL為
http://www.mabishu.com/blog/2009/12/08/using-memcache-server-as-apache-content-cach/
將 membase & memcached 加入 Cacti 監控
新增 cacti 的 manager monitor port
[root@apache scripts]# pwd
/var/www/html/cacti/scripts
[root@apache scripts]# vi ports.inc
80#HTTP
443#HTTP SSL
110#POP
995#POP SSL
25#SMTP
21#FTPD
53#DNS
389#LDAP
23#Telnet
22#SSH
3306#MYSQL
143#IMAP
993#IMAP SSL
514#RSH
8003#NAV GW
10000#Ipsec
8090#X-Ray
8080#Zope
5903#VNC
11211#memcached
8091#CouchbaseConsole
再進入 cacti \ console \ device \ TCP (Verbose Query) \ 再點選新增的監控服務即可
Cacti Manage Monitor
Couchbase Console
訂閱:
張貼留言 (Atom)
這個.. 我的apache 是2.2.3,要“升級”到 2.2.2?
回覆刪除