看到好多筒子们yum安装memcached不成功,不幸的是,我也遇到了,由于各种原因,花了七八个小时才搞定。
看坛子里好多筒子都有贴处理经验,貌似不是很详细彻底,我索性总结下,希望大家少走弯路。
条条大道通罗马,但是最顺畅的只有一条。。。
我的系统版本为:rhel5.3 32
如果你用的是Redhat,或者是CentOS,那你可能会碰到以下两种情况导致你yum安装memcached失败:
- [root@biao ~]# yum install memcached
- Loaded plugins: rhnplugin, security
- This system is not registered with RHN.
- RHN support will be disabled.
- Setting up Install Process
- No package memcached available.
- Nothing to do
- [root@biao ~]# yum install memcached
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- Setting up Install Process
- No package memcached available.
- Nothing to do
CentOS不注册的话,yum是用不了,Redhat即使注册了,貌似yum还是用不了。不知道rhel官方yum源是不是要另外收费的?哪位筒子给我扫下盲。。
可以尝试一下以下方法:
如果是CentOS,或者遇到第二个错误,可以直接跳到步骤8,如果是Redhat,或者遇到第一个错误,需要按着顺序一步一步来。其他系统,不确定。
步骤1-7就是将Redhat中的yum改为CentOS的yum。
1、先查看下系统当前yum服务的相关的包:
- [root@biao ~]# rpm -qa|grep yum
- yum-updatesd-0.9-2.el5
- yum-metadata-parser-1.1.2-2.el5
- yum-3.2.19-18.el5
- yum-security-1.1.16-13.el5
- yum-rhn-plugin-0.5.3-30.el5
2、卸载这些包:
- [root@biao ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
3、下载新的yum包:
- [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
- [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
- [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
注意:有可能会碰到版本更改导致找到不到源,可以进到官网上确认下:
- http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/
如果过是64位系统,则i386要改为x86_64,貌似,这个没什么好说的,你懂的。。
log如下:
- [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
- --16:03:37-- http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
- Resolving centos.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
- Connecting to centos.ustc.edu.cn|202.141.160.110|:80... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 1034902 (1011K) [application/x-redhat-package-manager]
- Saving to: `yum-3.2.22-39.el5.centos.noarch.rpm'
- 100%[====================================================================================>] 1,034,902 29.0K/s in 34s
- 16:04:28 (29.4 KB/s) - `yum-3.2.22-39.el5.centos.noarch.rpm' saved [1034902/1034902]
- [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
- --16:06:17-- http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
- Resolving centos.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
- Connecting to centos.ustc.edu.cn|202.141.160.110|:80... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 21033 (21K) [application/x-redhat-package-manager]
- Saving to: `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm'
- 100%[====================================================================================>] 21,033 29.9K/s in 0.7s
- 16:06:48 (29.9 KB/s) - `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm' saved [21033/21033]
- [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
- --16:07:35-- http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
- Resolving centos.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
- Connecting to centos.ustc.edu.cn|202.141.160.110|:80... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 26053 (25K) [application/x-redhat-package-manager]
- Saving to: `yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm'
- 100%[====================================================================================>] 26,053 71.3K/s in 0.4s
- 16:07:51 (71.3 KB/s) - `yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm' saved [26053/26053]
- [root@biao ~]#
4、安装下载的yum包:
- [root@biao ~]# rpm -ivh yum-*
- warning: yum-3.2.22-39.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
- Preparing... ########################################### [100%]
- 1:yum-metadata-parser ########################################### [ 33%]
- 2:yum-fastestmirror ########################################### [ 67%]
- 3:yum ########################################### [100%]
- [root@biao ~]#
5、下载yum配置源:
下载到/etc/yum.repos.d/目录下:
- wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
详细操作:
- [root@biao ~]# cd /etc/yum.repos.d/
- [root@biao yum.repos.d]# ll
- total 8
- -rw-r--r-- 1 root root 254 Dec 16 2008 rhel-debuginfo.repo
- [root@biao yum.repos.d]# mv rhel-debuginfo.repo rhel-debuginfo.repo.bak
- [root@biao yum.repos.d]# wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
- --16:37:58-- http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
- Resolving docs.linuxtone.org... 119.57.20.28
- Connecting to docs.linuxtone.org|119.57.20.28|:80... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 1426 (1.4K) [application/octet-stream]
- Saving to: `CentOS-Base.repo'
- 100%[====================================================================================>] 1,426 --.-K/s in 0s
- 16:38:25 (552 MB/s) - `CentOS-Base.repo' saved [1426/1426]
- [root@biao yum.repos.d]# ll
- total 12
- -rw-r--r-- 1 root root 1426 May 24 2009 CentOS-Base.repo
- -rw-r--r-- 1 root root 254 Dec 16 2008 rhel-debuginfo.repo.bak
6、运行yum update更新:
PS:不确定这一步,是不是必须的,但是,既然一次性搞,就索性更新一把吧,但是前提是要你网速跟得上,有700M的包要下载。
如果你的宽带提供商是 中国毛线通信 ,请慎重!除下载外,安装也挺久。下载我花了半个小时,安装花了将近一个小时,懒得等的,可以跳过这一步试试。
一共下载了595个包,更新了1170项。
期间有两次提示你选择y/N,输入y回车即可。
log太多了,只贴个命令:
- [root@biao ~]# yum update
7、运行yum makecache生成缓存:
- [root@biao ~]# yum makecache
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- addons | 1.9 kB 00:00
- addons/other_db | 552 B 00:00
- base | 1.1 kB 00:00
- base/other | 10 MB 00:39
- base/group | 1.1 MB 00:15
- extras | 2.1 kB 00:00
- extras/other_db | 448 kB 00:05
- extras/group | 9.7 kB 00:00
- update | 1.9 kB 00:00
- update/other_db | 22 MB 01:58
- base 2725/2725
- Metadata Cache Created
8、测试下yum,yum安装memcached:
- [root@biao ~]# yum search mysql
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- ====================================================== Matched: mysql =======================================================
- mod_auth_mysql.i386 : Basic authentication for the Apache web server using a MySQL database.
- qt-MySQL.i386 : MySQL drivers for Qt's SQL classes.
- MySQL-python.i386 : An interface to MySQL
- apr-util-mysql.i386 : APR utility library MySQL DBD driver
- bytefx-data-mysql.i386 : MySQL database connectivity for Mono
- freeradius-mysql.i386 : MySQL bindings for freeradius
- freeradius2-mysql.i386 : MySQL support for freeradius
- libdbi-dbd-mysql.i386 : MySQL plugin for libdbi
- mysql.i386 : MySQL client programs and shared libraries
- mysql-bench.i386 : MySQL benchmark scripts and data
- mysql-connector-odbc.i386 : ODBC driver for MySQL
- mysql-connector-odbc64.i386 : ODBC driver for MySQL
- mysql-devel.i386 : Files for development of MySQL applications
- mysql-server.i386 : The MySQL server and related files
- mysql-test.i386 : The test suite distributed with MySQL
- pdns-backend-mysql.i386 : MySQL backend for pdns
- perl-DBD-MySQL.i386 : A MySQL interface for perl
- php-mysql.i386 : A module for PHP applications that use MySQL databases.
- php-pdo.i386 : A database access abstraction module for PHP applications
- php-pear-MDB2-Driver-mysql.noarch : MySQL MDB2 driver
- php53-mysql.i386 : A module for PHP applications that use MySQL databases
- php53-pdo.i386 : A database access abstraction module for PHP applications
- qt4-mysql.i386 : MySQL drivers for Qt's SQL classes
- rsyslog.i386 : Enhanced system logging and kernel message trapping daemon
- rsyslog-mysql.i386 : MySQL support for rsyslog
- unixODBC.i386 : A complete ODBC driver manager for Linux
- unixODBC64.i386 : A complete ODBC driver manager for Linux
- [root@biao ~]# yum search memcached
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- ==================================================== Matched: memcached =====================================================
- php-pecl-memcache.i386 : Extension to work with the Memcached caching daemon
可以看到,yum是配置好了,但是貌似找不memchaced,可以再确认下:
- [root@biao ~]# yum install memcached
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- Setting up Install Process
- No package memcached available.
- Nothing to do
这是因为缺少了扩展包 EPEL(Extra Packages for Enterprise Linux),可以用 yum repolist 命令检查下。
解决方法很简单,再安装一个包,
- [root@biao ~]# 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.DFnB18: Header V3 DSA signature: NOKEY, key ID 217521f6
- Preparing... ########################################### [100%]
- 1:epel-release ########################################### [100%]
- rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
repolist检查下:
- [root@biao ~]# yum repolist
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * epel: mirrors.ustc.edu.cn
- repo id repo name status
- addons CentOS-5 - Addons 0
- base CentOS-5 - Base 2,725
- epel Extra Packages for Enterprise Linux 5 - i386 5,873
- extras CentOS-5 - Extras 286
- update CentOS-5 - Updates 993
- repolist: 9,877
再次安装memcached:
- [root@biao ~]# yum install memcached
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * epel: mirrors.ustc.edu.cn
- epel | 3.7 kB 00:00
- epel/primary_db | 3.1 MB 00:03
- 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:02
- 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!
9、测试下memcached的使用:
1)、启动服务:
- [root@biao ~]# /etc/rc.d/init.d/memcached start
- Starting memcached: [ OK ]
- [root@biao ~]# pstree
- ...
- ├─memcached───5*[{memcached}]
- ...
- [root@biao ~]# ps aux|grep memcached
- 101 24352 0.0 0.0 54356 684 ? Ssl 11:49 0:00 memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid
- root 24457 0.0 0.0 4020 712 pts/3 S+ 11:52 0:00 grep memcached
- [root@biao ~]# telnet 127.0.0.1 11211
- Trying 127.0.0.1...
- Connected to localhost.localdomain (127.0.0.1).
- Escape character is '^]'.
- set test 0 0 4
- tttt
- STORED
- get test
- VALUE test 0 4
- tttt
- END
至此,yum配置成功,yum安装memcached成功。