How to install Memcached Server on Fedora and RHEL/CentOS
To install Memcached Server
This article is about how to install process of Memcached Server on Fedora 17-12 and RHEL/CentOS 6.3/5.8 using YUM command. Memcached is memory object caching program. It is an open source program which helps to speed up the performance.
To Enable EPEL repository under RHEL/CentOS 6.3 or 5.8
For RHEL/CentOS 6 ( 64-Bit )
wget http://mirrors.kernel.org/fedora-epel/6/x86_64/epel-release-6-7.noarch.rpm
rpm -Uvh epel-release-6-7.noarch.rpm
For RHEL/CentOS 6 ( 32-Bit )
wget http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh epel-release-6-7.noarch.rpm
For RHEL/CentOS 5 ( 64-Bit )
wget http://mirrors.kernel.org/fedora-epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
For RHEL/CentOS 5 ( 32-Bit )
wget http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
To Install Memcached
The Memcached command can be installed using the YUM tool
[root@linuxhelp~]# yum install memcached
Loaded plugins: fastestmirror
Determining fastest mirrors
epel: kartolo.sby.datautama.net.id
Dependencies Resolved
=====================================================================================================
Package Arch Version Repository Size
=====================================================================================================
Installing:
memcached i386 1.4.5-1.el5 epel 71 k
Transaction Summary
=====================================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 71 k
Is this ok [y/N]: y
Downloading Packages:
memcached-1.4.5-1.el5.i386.rpm | 71 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : memcached 1/1
Installed:
memcached.i386 0:1.4.5-1.el5
Complete!
To configure Memcached
This is the basic configuration file for memcached server and we can edit the contents which suits our set up. Here I have configured to my own set up it can be varied.
[root@linuxhelp~]# vi /etc/sysconfig/memcached
To Set or update parameters
# Running on Port 11211
PORT=" 11211"
# Start as memcached daemon
USER=" memcached"
# Set max simultaneous connections to 1024
MAXCONN=" 1024"
# Set Memory size to 2048 - 4GB(4096)
CACHESIZE=" 2048"
#Set server IP address
OPTIONS=" 192.168.5.220"
Here, I have changed the default port number 11211 to 11222 and mentioned server’ s IP address as 192.168.5.220
Options
PORT : Runs the memcached
USER : The start-up daemon for memcached service.
MAXCONN : The value used to set max simultaneous connections to 1024.
CACHESIZE : cache size memory can be set to 2048. For busy servers you can increase upto 4GB.
OPTIONS : Apache or Nginx web servers can connect by Setting IP address of the server
To start Memcached
To start and restart the Memcached daemon
[root@linuxhelp~]# chkconfig --levels 235 memcached on
[root@linuxhelp~]# /etc/init.d/memcached start
[root@linuxhelp~]# /etc/init.d/memcached restart
To stop and check status
/etc/init.d/memcached stop
/etc/init.d/memcached status
To Verify Memcached
[root@linuxhelp~]# netstat -tulpn | grep :11222
tcp 0 0 0.0.0:11222 0.0.0.0:* LISTEN 10388/memcached
udp 0 0 0.0.0.0:11222 0.0.0.0:* 10388/memcached
To Check the stats of the server
memcached-tool 192.168.5.220 stats
To install Memcached PHP extension
yum install php-pecl-memcache
To install Memcached Perl Library
yum install perl-Cache-Memcached
To install Memcached Python Library
yum install python-memcached
To configure Firewall to Secure Memcached Server
vi /etc/sysconfig/iptables
To Enable access on IP
## Enable access on IP ranges from 172.16.1.1 to 172.16.1.10 for Port 11211 ##
# iptables -A INPUT -p tcp --destination-port 11211 -m state --state NEW -m iprange --src-range 192.168.1.1-192.168.1.10 -j ACCEPT
# iptables -A INPUT -p udp --destination-port 11211 -m state --state NEW -m iprange --src-range 192.168.1.1-192.168.1.10 -j ACCEPT
Restart the iptables service to save changes
service iptables restart
OR
/etc/init.d/iptables restart
Comments ( 0 )
No comments available