memcached 安装问题解答
操作环境:CentOS 5.4
安装详细请见:http://blog.csdn.net/yima1006/article/details/9263409
如果你所使用的RedHat Linux 或者是CentOS ,当你直接通过yum安装memcached时会出现以下问题:
[root@h3 ~]# yum install memcached
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.163.com
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Install Process
No package memcached available.
Nothing to do
[root@h3 ~]#
解决办法:
第一步,升级(或者重新安装yum),运行命令:
[root@h3 ~]# yum update yum
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.esocc.com
* base: mirror.esocc.com
* extras: mirror.esocc.com
* updates: mirror.esocc.com
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package yum.noarch 0:3.2.22-40.el5.centos set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
yum noarch 3.2.22-40.el5.centos base 1.0 M
Transaction Summary
================================================================================
Install 0 Package(s)
Upgrade 1 Package(s)
Total download size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
yum-3.2.22-40.el5.centos.noarch.rpm | 1.0 MB 00:08
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : yum 1/2
Cleanup : yum 2/2
Updated:
yum.noarch 0:3.2.22-40.el5.centos
Complete!
当然,有些朋友直接yum update 命令,这样需要好几个小时,据我的理解,其实只需要升级一下yum就行了。
第二步,yum makecache创建缓存.
[root@h3 ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.esocc.com
* base: mirror.esocc.com
* extras: mirror.esocc.com
* updates: mirror.esocc.com
addons | 1.9 kB 00:00
addons/filelists_db | 573 B 00:00
addons/other_db | 554 B 00:00
base | 1.1 kB 00:00
base/filelists | 3.0 MB 00:28
base/other | 11 MB 01:26
extras | 2.1 kB 00:00
extras/filelists_db | 213 kB 00:01
extras/other_db | 439 kB 00:03
updates | 1.9 kB 00:00
updates/filelists_db | 2.6 MB 00:18
updates/other_db | 12 MB 01:32
base 2770/2770
base 2770/2770
Metadata Cache Created
第三步,查找memcached包是否已经存在。
[root@h3 ~]# yum search memcached
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.neusoft.edu.cn
* base: mirrors.neusoft.edu.cn
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.neusoft.edu.cn
================================ Matched: memcached =================================
php-pecl-memcache.i386 : Extension to work with the Memcached caching daemon
很是兴奋,找到了,安装以下试试看:
[root@h3 ~]# yum install memcached
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.esocc.com
* base: mirror.esocc.com
* extras: mirror.esocc.com
* updates: mirror.esocc.com
Setting up Install Process
No package memcached available.
Nothing to do
结果很出乎意料之外,安装不了,这是因为缺少了扩展包 EPEL(Extra Packages for Enterprise Linux),可以用 yum repolist 命令检查下。
解决方法很简单,再安装一个包:
[root@h3 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-xfer.OplvnY: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
如果是CentOS 6.x的,执行以下代码:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
yum repolist 检查下:
[root@h3 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.163.com
* base: mirrors.163.com
* epel: mirrors.neusoft.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
epel | 3.6 kB 00:00
epel/primary_db | 3.1 MB 00:26
repo id repo name status
addons CentOS-5 - Addons 0
base CentOS-5 - Base 2,770
epel Extra Packages for Enterprise Linux 5 - i386 5,981
extras CentOS-5 - Extras 276
updates CentOS-5 - Updates 375
repolist: 9,402
最后一步,安装memcached:
[root@h3 ~]# yum install memcached
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.neusoft.edu.cn
* base: mirrors.neusoft.edu.cn
* epel: mirrors.neusoft.edu.cn
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.neusoft.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package memcached.i386 0:1.4.5-1.el5 set to be updated
--> Finished Dependency Resolution
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
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 217521f6
epel/gpgkey | 1.7 kB 00:00
Importing GPG key 0x217521F6 "Fedora EPEL <epel@fedoraproject.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]: y
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!
安装完成, 测试一下:
[root@h3 ~]# /etc/rc.d/init.d/memcached start
Starting memcached: [ OK ]
[root@h3 ~]# telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
set key 0 0 2
ok
STORED
get key
VALUE key 0 2
ok
END
完成操作,希望会对你有所帮助!