Redhat/CentOS下yum完美配置方案(顺带yum安装memcached)

看到好多筒子们yum安装memcached不成功,不幸的是,我也遇到了,由于各种原因,花了七八个小时才搞定。

看坛子里好多筒子都有贴处理经验,貌似不是很详细彻底,我索性总结下,希望大家少走弯路。

条条大道通罗马,但是最顺畅的只有一条。。。

我的系统版本为:rhel5.3 32


如果你用的是Redhat,或者是CentOS,那你可能会碰到以下两种情况导致你yum安装memcached失败:


  1. [root@biao ~]# yum install memcached
  2. Loaded plugins: rhnplugin, security
  3. This system is not registered with RHN.
  4. RHN support will be disabled.
  5. Setting up Install Process
  6. No package memcached available.
  7. Nothing to do
复制代码
或者:

  1. [root@biao ~]# yum install memcached
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. Setting up Install Process
  5. No package memcached available.
  6. Nothing to do
复制代码


CentOS不注册的话,yum是用不了,Redhat即使注册了,貌似yum还是用不了。不知道rhel官方yum源是不是要另外收费的?哪位筒子给我扫下盲。。

可以尝试一下以下方法:

如果是CentOS,或者遇到第二个错误,可以直接跳到步骤8,如果是Redhat,或者遇到第一个错误,需要按着顺序一步一步来。其他系统,不确定。

步骤1-7就是将Redhat中的yum改为CentOS的yum。


1
、先查看下系统当前yum服务的相关的包:


  1. [root@biao ~]# rpm -qa|grep yum
  2. yum-updatesd-0.9-2.el5
  3. yum-metadata-parser-1.1.2-2.el5
  4. yum-3.2.19-18.el5
  5. yum-security-1.1.16-13.el5
  6. yum-rhn-plugin-0.5.3-30.el5
复制代码


2
、卸载这些包:


  1. [root@biao ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
复制代码


3
、下载新的yum包:

  1. [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
  2. [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
  3. [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
复制代码

注意:有可能会碰到版本更改导致找到不到源,可以进到官网上确认下:


  1. http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/
复制代码

如果过是64位系统,则i386要改为x86_64,貌似,这个没什么好说的,你懂的。。

log
如下:


  1. [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
  2. --16:03:37--  http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
  3. Resolving centos.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
  4. Connecting to centos.ustc.edu.cn|202.141.160.110|:80... connected.
  5. HTTP request sent, awaiting response... 200 OK
  6. Length: 1034902 (1011K) [application/x-redhat-package-manager]
  7. Saving to: `yum-3.2.22-39.el5.centos.noarch.rpm'

  8. 100%[====================================================================================>] 1,034,902   29.0K/s   in 34s   

  9. 16:04:28 (29.4 KB/s) - `yum-3.2.22-39.el5.centos.noarch.rpm' saved [1034902/1034902]

  10. [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
  11. --16:06:17--  http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
  12. Resolving centos.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
  13. Connecting to centos.ustc.edu.cn|202.141.160.110|:80... connected.
  14. HTTP request sent, awaiting response... 200 OK
  15. Length: 21033 (21K) [application/x-redhat-package-manager]
  16. Saving to: `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm'

  17. 100%[====================================================================================>] 21,033      29.9K/s   in 0.7s   

  18. 16:06:48 (29.9 KB/s) - `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm' saved [21033/21033]

  19. [root@biao ~]# wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
  20. --16:07:35--  http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
  21. Resolving centos.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
  22. Connecting to centos.ustc.edu.cn|202.141.160.110|:80... connected.
  23. HTTP request sent, awaiting response... 200 OK
  24. Length: 26053 (25K) [application/x-redhat-package-manager]
  25. Saving to: `yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm'

  26. 100%[====================================================================================>] 26,053      71.3K/s   in 0.4s   

  27. 16:07:51 (71.3 KB/s) - `yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm' saved [26053/26053]

  28. [root@biao ~]#
复制代码
如上,就表示下载OK了。。


4
、安装下载的yum包:


  1. [root@biao ~]# rpm -ivh yum-*
  2. warning: yum-3.2.22-39.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
  3. Preparing...                ########################################### [100%]
  4.    1:yum-metadata-parser    ########################################### [ 33%]
  5.    2:yum-fastestmirror      ########################################### [ 67%]
  6.    3:yum                    ########################################### [100%]
  7. [root@biao ~]#
复制代码


5
、下载yum配置源:
下载到/etc/yum.repos.d/目录下:

  1. wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
复制代码


详细操作:


  1. [root@biao ~]# cd /etc/yum.repos.d/
  2. [root@biao yum.repos.d]# ll
  3. total 8
  4. -rw-r--r-- 1 root root 254 Dec 16  2008 rhel-debuginfo.repo
  5. [root@biao yum.repos.d]# mv rhel-debuginfo.repo rhel-debuginfo.repo.bak
  6. [root@biao yum.repos.d]# wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
  7. --16:37:58--  http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
  8. Resolving docs.linuxtone.org... 119.57.20.28
  9. Connecting to docs.linuxtone.org|119.57.20.28|:80... connected.
  10. HTTP request sent, awaiting response... 200 OK
  11. Length: 1426 (1.4K) [application/octet-stream]
  12. Saving to: `CentOS-Base.repo'

  13. 100%[====================================================================================>] 1,426       --.-K/s   in 0s     

  14. 16:38:25 (552 MB/s) - `CentOS-Base.repo' saved [1426/1426]

  15. [root@biao yum.repos.d]# ll
  16. total 12
  17. -rw-r--r-- 1 root root 1426 May 24  2009 CentOS-Base.repo
  18. -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太多了,只贴个命令:


  1. [root@biao ~]# yum update
复制代码


7、运行yum makecache生成缓存:


  1. [root@biao ~]# yum makecache
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. addons                                                                                                | 1.9 kB     00:00     
  5. addons/other_db                                                                                       |  552 B     00:00     
  6. base                                                                                                  | 1.1 kB     00:00     
  7. base/other                                                                                            |  10 MB     00:39     
  8. base/group                                                                                            | 1.1 MB     00:15     
  9. extras                                                                                                | 2.1 kB     00:00     
  10. extras/other_db                                                                                       | 448 kB     00:05     
  11. extras/group                                                                                          | 9.7 kB     00:00     
  12. update                                                                                                | 1.9 kB     00:00     
  13. update/other_db                                                                                       |  22 MB     01:58     
  14. base                                                                                                               2725/2725
  15. Metadata Cache Created
复制代码


8、测试下yum,yum安装memcached:


  1. [root@biao ~]# yum search mysql
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. ====================================================== Matched: mysql =======================================================
  5. mod_auth_mysql.i386 : Basic authentication for the Apache web server using a MySQL database.
  6. qt-MySQL.i386 : MySQL drivers for Qt's SQL classes.
  7. MySQL-python.i386 : An interface to MySQL
  8. apr-util-mysql.i386 : APR utility library MySQL DBD driver
  9. bytefx-data-mysql.i386 : MySQL database connectivity for Mono
  10. freeradius-mysql.i386 : MySQL bindings for freeradius
  11. freeradius2-mysql.i386 : MySQL support for freeradius
  12. libdbi-dbd-mysql.i386 : MySQL plugin for libdbi
  13. mysql.i386 : MySQL client programs and shared libraries
  14. mysql-bench.i386 : MySQL benchmark scripts and data
  15. mysql-connector-odbc.i386 : ODBC driver for MySQL
  16. mysql-connector-odbc64.i386 : ODBC driver for MySQL
  17. mysql-devel.i386 : Files for development of MySQL applications
  18. mysql-server.i386 : The MySQL server and related files
  19. mysql-test.i386 : The test suite distributed with MySQL
  20. pdns-backend-mysql.i386 : MySQL backend for pdns
  21. perl-DBD-MySQL.i386 : A MySQL interface for perl
  22. php-mysql.i386 : A module for PHP applications that use MySQL databases.
  23. php-pdo.i386 : A database access abstraction module for PHP applications
  24. php-pear-MDB2-Driver-mysql.noarch : MySQL MDB2 driver
  25. php53-mysql.i386 : A module for PHP applications that use MySQL databases
  26. php53-pdo.i386 : A database access abstraction module for PHP applications
  27. qt4-mysql.i386 : MySQL drivers for Qt's SQL classes
  28. rsyslog.i386 : Enhanced system logging and kernel message trapping daemon
  29. rsyslog-mysql.i386 : MySQL support for rsyslog
  30. unixODBC.i386 : A complete ODBC driver manager for Linux
  31. unixODBC64.i386 : A complete ODBC driver manager for Linux
  32. [root@biao ~]# yum search memcached
  33. Loaded plugins: fastestmirror
  34. Loading mirror speeds from cached hostfile
  35. ==================================================== Matched: memcached =====================================================
  36. php-pecl-memcache.i386 : Extension to work with the Memcached caching daemon
复制代码

可以看到,yum是配置好了,但是貌似找不memchaced,可以再确认下:


  1. [root@biao ~]# yum install memcached
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. Setting up Install Process
  5. No package memcached available.
  6. Nothing to do
复制代码
memcached就是安装不了。

这是因为缺少了扩展包 EPEL(Extra Packages for Enterprise Linux),可以用 yum repolist 命令检查下。


解决方法很简单,再安装一个包,


  1. [root@biao ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  2. Retrieving http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  3. warning: /var/tmp/rpm-xfer.DFnB18: Header V3 DSA signature: NOKEY, key ID 217521f6
  4. Preparing...                ########################################### [100%]
  5.    1:epel-release           ########################################### [100%]
复制代码
我的系统版本5,如果是6的话,执行这一句:

  1. rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
复制代码
但是进到rpm -ivh http://dl.fedoraproject.org/pub/epel/6目录下,找不到相关的memcached包,用6的筒子可以试下。


repolist检查下:

  1. [root@biao ~]# yum repolist
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * epel: mirrors.ustc.edu.cn
  5. repo id repo name status
  6. addons CentOS-5 - Addons 0
  7. base CentOS-5 - Base 2,725
  8. epel Extra Packages for Enterprise Linux 5 - i386 5,873
  9. extras CentOS-5 - Extras 286
  10. update CentOS-5 - Updates 993
  11. repolist: 9,877
复制代码
出现 epel Extra Packages for Enterprise Linux 5 - i386 5,873 即表示epel安装成功。

再次安装memcached:

  1. [root@biao ~]# yum install memcached
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * epel: mirrors.ustc.edu.cn
  5. epel                                                                                                  | 3.7 kB     00:00     
  6. epel/primary_db                                                                                       | 3.1 MB     00:03     
  7. Setting up Install Process
  8. Resolving Dependencies
  9. --> Running transaction check
  10. ---> Package memcached.i386 0:1.4.5-1.el5 set to be updated
  11. --> Finished Dependency Resolution

  12. Dependencies Resolved

  13. =============================================================================================================================
  14. Package                        Arch                      Version                            Repository                 Size
  15. =============================================================================================================================
  16. Installing:
  17. memcached                      i386                      1.4.5-1.el5                        epel                       71 k

  18. Transaction Summary
  19. =============================================================================================================================
  20. Install       1 Package(s)
  21. Upgrade       0 Package(s)

  22. Total download size: 71 k
  23. Is this ok [y/N]: y
  24. Downloading Packages:
  25. memcached-1.4.5-1.el5.i386.rpm                                                                        |  71 kB     00:02     
  26. warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 217521f6
  27. epel/gpgkey                                                                                           | 1.7 kB     00:00     
  28. Importing GPG key 0x217521F6 "Fedora EPEL <epel@fedoraproject.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
  29. Is this ok [y/N]: y
  30. Running rpm_check_debug
  31. Running Transaction Test
  32. Finished Transaction Test
  33. Transaction Test Succeeded
  34. Running Transaction
  35.   Installing     : memcached                                                                                             1/1

  36. Installed:
  37.   memcached.i386 0:1.4.5-1.el5                                                                                               

  38. Complete!
复制代码

9、测试下memcached的使用:
1)、启动服务:
  1. [root@biao ~]# /etc/rc.d/init.d/memcached start
  2. Starting memcached:                                        [  OK  ]
复制代码
启动是OK的,可以再确认下进程是否启动:
  1. [root@biao ~]# pstree
  2. ...
  3. ├─memcached───5*[{memcached}]
  4. ...
复制代码
看到memcached服务已经启动了,也可以通过ps aux|grep命令确认:
  1. [root@biao ~]# ps aux|grep memcached
  2. 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
  3. root     24457  0.0  0.0   4020   712 pts/3    S+   11:52   0:00 grep memcached
复制代码
2)、连接并测试memcached:
  1. [root@biao ~]# telnet 127.0.0.1 11211
  2. Trying 127.0.0.1...
  3. Connected to localhost.localdomain (127.0.0.1).
  4. Escape character is '^]'.
  5. set test 0 0 4
  6. tttt
  7. STORED
  8. get test
  9. VALUE test 0 4
  10. tttt
  11. END
复制代码
memcached运行正常。


至此,yum配置成功,yum安装memcached成功。




From:http://f.dataguru.cn/forum.php?mod=viewthread&tid=44212&fromuid=4771



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值