RedHat6.5虚拟机架设Redis和Kafka伪集群

时间:2021-02-20 17:10:46

架设Redis:

虚拟机架设,桥接模式下要保证实体机能上网,这样虚拟机才会分配到一个ip(这里是192.168.43.105),方便下面的集群配置每个节点ip,伪集群都设置成一个,

但要保证这个ip网络畅通,cluster的各个节点才可按照该ip彼此访问.


普通用户xiaobai,copy Redis.tar文件,解压到/usr/local失败:


Linux怎么在文件系统/usr/local中复制进文件,总是显示没有权限?


发布于2016-08-27 11:36对usr文件夹进行操作需要有超级管理员的权限才行,你可以切换为超级管理员进行操作,或者在命令前面加 sudo;

如 sudo cp 1.txt usr/local

添加sudo用户:


配置sudo必须通过编辑/etc/sudoers文件,而且只有超级用户才可以修改它,还必须使用visudo编辑。之所以使用visudo有两个原因,一是它能够防止两个用户同时修改它;二是它也能进行有限的语法检查。所以,即使只有你一个超级用户,你也最好用visudo来检查一下语法。

解决办法如下

1.打开sudoers文件

切换到root用户下,cd root,运行visudo命令,visudo命令是用来编辑修改/etc/sudoers配置文件

[root@master ~]# visudo

2.修改suduers文件

找到如下图所示,标出红线的一行

root  ALL=(ALL)    ALL
 
 
  • 1
RedHat6.5虚拟机架设Redis和Kafka伪集群

给liudiwei添加sudo权限 
在“root ALL=(ALL) ALL”这一行下面,再加入一行:

liudiwei ALL=(ALL)     ALL

3.测试是否成功

切换到普通用户

su liudiwei
cd ~
sudo mkdir test
  • 1
  • 2
  • 3
RedHat6.5虚拟机架设Redis和Kafka伪集群

恭喜,验证密码后,通过!

好了,我们限制一下foobar的权利,不让他为所欲为。比如我们只想让他像root那样使用ls和ifconfig,把那一行改为: foobar localhost= /sbin/ifconfig, /bin/ls

现在让我们来看一下那三个ALL到底是什么意思。第一个ALL是指网络中的主机,我们后面把它改成了主机名,它指明foobar可以在此主机上执行后面的命令。第二个括号里的ALL是指目标用户,也就是以谁的身份去执行命令。最后一个ALL当然就是指命令名了。例如,我们想让foobar用户在linux主机上以jimmy或rene的身份执行kill命令,这样编写配置文件: foobar linux=(jimmy,rene) /bin/kill 但这还有个问题,foobar到底以jimmy还是rene的身份执行?这时我们应该想到了sudo -u了,它正是用在这种时候。 foobar可以使用sudo -u jimmy kill PID或者sudo -u rene kill PID,但这样挺麻烦,其实我们可以不必每次加-u,把rene或jimmy设为默认的目标用户即可。再在上面加一行: Defaults:foobar runas_default=rene Defaults后面如果有冒号,是对后面用户的默认,如果没有,则是对所有用户的默认。就像配置文件中自带的一行: Defaults env_reset 另一个问题是,很多时候,我们本来就登录了,每次使用sudo还要输入密码就显得烦琐了。我们可不可以不再输入密码呢?当然可以,我们这样修改配置文件: foobar localhost=NOPASSWD: /bin/cat, /bin/ls 再来sudo一下: [foobar@localhost ~]$ sudo ls /rootanaconda-ks.cfg Desktop install.log install.log.syslog 当然,你也可以说“某些命令用户foobar不可以运行”,通过使用!操作符,但这不是一个好主意。因为,用!操作符来从ALL中“剔出”一些命令一般是没什么效果的,一个用户完全可以把那个命令拷贝到别的地方,换一个名字后再来运行。

再次运行,以sudo前缀解压:

sudo tar -zvxf redis /usr/local


解压仍失败,忘了解压的-C参数:

Not found in archive

查了一下,原来是要在命令中加上-C这个参数.

又查了一下,C这个参数是“创建新的档案文件”。


再次解压成功

切换到/usr/local/redis目录,发现可以进入,查看该目录权限发现:

drwxrwxr-x. 6 root root  4096 Jul 14 19:28 redis-4.0.0


原来xiaobai添加到sudo,sudo安装,该目录other成员也有r-x权限,说明可以进入


在解压好的redis目录执行make && make install,安装失败,切换到root仍然提示:

[root@RedHat-BG redis-4.0.0]# pwd
/usr/local/redis-4.0.0
[root@RedHat-BG redis-4.0.0]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis-4.0.0/src'


Hint: It's a good idea to run 'make test' ;)


make[1]: Leaving directory `/usr/local/redis-4.0.0/src'
[root@RedHat-BG redis-4.0.0]# make install
cd src && make install
make[1]: Entering directory `/usr/local/redis-4.0.0/src'


Hint: It's a good idea to run 'make test' ;)


    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/redis-4.0.0/src'

解决:

解压缩

tar -zxvf redis-3.0.7.tar.gz

cd redis-3.0.7

这全很正常没有什么可以说的,主要是下面,进入到redis-3.0.7目录之后,要是执行

make

make install 会把redis默认安装到/usr/local/bin/redis下

但是我只是一个普通的redis用户,我不想给他sudo权限也不想用root去执行怎么办呢

方法是:

bash-4.1$ PREFIX=/opt/redis make
bash
-4.1$ PREFIX=/opt/redis make install

指定到你想要安装的目录下就可以了,大功告成


[root@RedHat-BG redis-4.0.0]# make PREFIX=/usr/local/redis install
cd src && make install
make[1]: Entering directory `/usr/local/redis-4.0.0/src'


Hint: It's a good idea to run 'make test' ;)


    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/redis-4.0.0/src'
[root@RedHat-BG redis-4.0.0]# su xiaobai
[xiaobai@RedHat-BG redis-4.0.0]$ make
cd src && make all
make[1]: Entering directory `/usr/local/redis-4.0.0/src'


Hint: It's a good idea to run 'make test' ;)


make[1]: Leaving directory `/usr/local/redis-4.0.0/src'
[xiaobai@RedHat-BG redis-4.0.0]$ ll
total 272
-rw-rw-r--.  1 root root 124870 Jul 14 19:28 00-RELEASENOTES
-rw-rw-r--.  1 root root     53 Jul 14 19:28 BUGS
-rw-rw-r--.  1 root root   1815 Jul 14 19:28 CONTRIBUTING
-rw-rw-r--.  1 root root   1487 Jul 14 19:28 COPYING
drwxrwxr-x.  6 root root   4096 Sep 10 09:57 deps
-rw-rw-r--.  1 root root     11 Jul 14 19:28 INSTALL
-rw-rw-r--.  1 root root    151 Jul 14 19:28 Makefile
-rw-rw-r--.  1 root root   4223 Jul 14 19:28 MANIFESTO
-rw-rw-r--.  1 root root  20530 Jul 14 19:28 README.md
-rw-rw-r--.  1 root root  57764 Jul 14 19:28 redis.conf
-rwxrwxr-x.  1 root root    271 Jul 14 19:28 runtest
-rwxrwxr-x.  1 root root    280 Jul 14 19:28 runtest-cluster
-rwxrwxr-x.  1 root root    281 Jul 14 19:28 runtest-sentinel
-rw-rw-r--.  1 root root   7606 Jul 14 19:28 sentinel.conf
drwxrwxr-x.  3 root root   4096 Sep 10 10:00 src
drwxrwxr-x. 10 root root   4096 Jul 14 19:28 tests
drwxrwxr-x.  8 root root   4096 Jul 14 19:28 utils
[xiaobai@RedHat-BG redis-4.0.0]$ pwd
/usr/local/redis-4.0.0
[xiaobai@RedHat-BG redis-4.0.0]$ cd ../
[xiaobai@RedHat-BG local]$ ll'
> ^C
[xiaobai@RedHat-BG local]$ ll
total 64
drwxr-xr-x. 2 root root  4096 Sep 10 10:03 bin
drwxr-xr-x. 2 root root  4096 Jun 28  2011 etc
drwxr-xr-x. 2 root root  4096 Jun 28  2011 games
drwxr-xr-x. 2 root root  4096 Jun 28  2011 include
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib64
drwxr-xr-x. 2 root root  4096 Jun 28  2011 libexec
drwx------. 2 root root 16384 Sep  2 21:21 lost+found
drwxr-xr-x. 3 root root  4096 Sep 10 10:08 redis
drwxrwxr-x. 6 root root  4096 Jul 14 19:28 redis-4.0.0
drwxr-xr-x. 2 root root  4096 Jun 28  2011 sbin
drwxr-xr-x. 5 root root  4096 Sep  2 21:37 share
drwxr-xr-x. 2 root root  4096 Jun 28  2011 src
[xiaobai@RedHat-BG local]$ cd redsi
bash: cd: redsi: No such file or directory
[xiaobai@RedHat-BG local]$ cd redis
[xiaobai@RedHat-BG redis]$ ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
[xiaobai@RedHat-BG redis]$ cd bin
[xiaobai@RedHat-BG bin]$ ll
total 35400
-rwxr-xr-x. 1 root root 5597438 Sep 10 10:08 redis-benchmark
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-aof
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-rdb
-rwxr-xr-x. 1 root root 5728350 Sep 10 10:08 redis-cli
lrwxrwxrwx. 1 root root      12 Sep 10 10:08 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-server
[xiaobai@RedHat-BG bin]$ ./redis-server
9081:C 10 Sep 10:15:34.045 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9081:C 10 Sep 10:15:34.045 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=9081, just started
9081:C 10 Sep 10:15:34.045 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
9081:M 10 Sep 10:15:34.046 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
9081:M 10 Sep 10:15:34.046 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
9081:M 10 Sep 10:15:34.046 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.0 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 9081
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               


注意上面,执行成功的是root用户,查看指定的redis目录:

[xiaobai@RedHat-BG redis-4.0.0]$ pwd
/usr/local/redis-4.0.0
[xiaobai@RedHat-BG redis-4.0.0]$ cd ../redis
[xiaobai@RedHat-BG redis]$ ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
[xiaobai@RedHat-BG redis]$ cd bin
[xiaobai@RedHat-BG bin]$ ll
total 35400
-rwxr-xr-x. 1 root root 5597438 Sep 10 10:08 redis-benchmark
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-aof
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-rdb
-rwxr-xr-x. 1 root root 5728350 Sep 10 10:08 redis-cli
lrwxrwxrwx. 1 root root      12 Sep 10 10:08 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-server


bin和bin里面的可执行文件,所属用户和用户组都是root

但其他用户拥有可执行文件的可执行权限,所以可以启动redis:

[xiaobai@RedHat-BG bin]$ pwd
/usr/local/redis/bin
[xiaobai@RedHat-BG bin]$ ./redis-server
9465:C 10 Sep 10:35:40.749 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9465:C 10 Sep 10:35:40.749 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=9465, just started
9465:C 10 Sep 10:35:40.749 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
9465:M 10 Sep 10:35:40.750 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
9465:M 10 Sep 10:35:40.750 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
9465:M 10 Sep 10:35:40.750 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.0 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 9465
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               


9465:M 10 Sep 10:35:40.764 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
9465:M 10 Sep 10:35:40.764 # Server initialized
9465:M 10 Sep 10:35:40.764 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
9465:M 10 Sep 10:35:40.764 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
9465:M 10 Sep 10:35:40.764 * Ready to accept connections


但它没办法用Ctrl+C结束redis:

^C9465:signal-handler (1505010993) Received SIGINT scheduling shutdown...
9465:M 10 Sep 10:36:33.462 # User requested shutdown...
9465:M 10 Sep 10:36:33.462 * Saving the final RDB snapshot before exiting.
9465:M 10 Sep 10:36:33.462 # Failed opening the RDB file dump.rdb (in server root dir /usr/local/redis/bin) for saving: Permission denied
9465:M 10 Sep 10:36:33.462 # Error trying to save the DB, can't exit.
9465:M 10 Sep 10:36:33.462 # SIGTERM received but errors trying to shut down the server, check the logs for more information

可进入bin,但缺少执行bin中某个save操作可执行文件的权限

集群架设:


从现在开始全部用root操作,普通用户各种权限不足:

创建 Redis 节点

首先在 192.168.31.245 机器上 /root/software/redis-3.2.4 目录下创建 redis_cluster 目录;

mkdir redis_cluster  

在 redis_cluster 目录下,创建名为7000、7001、7002的目录,并将 redis.conf 拷贝到这三个目录中

mkdir 7000 7001 7002<br>cp redis.conf redis_cluster/7000
cp redis.conf redis_cluster
/7001
cp redis.conf redis_cluster
/7002  



[xiaobai@RedHat-BG bin]$ ps -ef|grep redis
xiaobai    9465   9316  0 10:35 pts/1    00:00:00 ./redis-server *:6379
xiaobai    9612   9563  0 10:43 pts/0    00:00:00 grep redis
[xiaobai@RedHat-BG bin]$ kill -9 9465
[xiaobai@RedHat-BG bin]$ pwd
/usr/local/redis/bin
[xiaobai@RedHat-BG bin]$ cd ../
[xiaobai@RedHat-BG redis]$ ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
[xiaobai@RedHat-BG redis]$ pwd
/usr/local/redis
[xiaobai@RedHat-BG redis]$ mkdir /redis-cluster
mkdir: cannot create directory `/redis-cluster': Permission denied
[xiaobai@RedHat-BG redis]$ su root
Password: 
[root@RedHat-BG redis]# pwad
bash: pwad: command not found
[root@RedHat-BG redis]# pwd
/usr/local/redis
[root@RedHat-BG redis]# mkdir /redis-cluster
[root@RedHat-BG redis]# ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
[root@RedHat-BG redis]# cd /
[root@RedHat-BG /]# ll
total 106
dr-xr-xr-x.   2 root root  4096 Sep  2 22:54 bin
dr-xr-xr-x.   5 root root  1024 Sep  3 00:03 boot
drwxr-xr-x.  10 root root  4096 Sep  2 23:56 cgroup
drwxr-xr-x.  19 root root  3980 Sep 10 08:47 dev
drwxr-xr-x. 152 root root 12288 Sep 10 09:23 etc
drwxr-xr-x.   5 root root  4096 Sep  2 23:34 home
dr-xr-xr-x.  13 root root  4096 Sep  2 22:53 lib
dr-xr-xr-x.  11 root root 12288 Sep  2 22:53 lib64
drwx------.   2 root root 16384 Sep  2 21:21 lost+found
drwxr-xr-x.   3 root root  4096 Sep 10 08:48 media
drwxr-xr-x.   2 root root     0 Sep 10 08:47 misc
drwxr-xr-x.   3 root root  4096 Sep  2 17:19 mnt
drwxr-xr-x.   2 root root     0 Sep 10 08:47 net
drwxr-xr-x.   4 root root  4096 Sep  2 22:09 opt
dr-xr-xr-x. 261 root root     0 Sep 10 08:46 proc
drwxr-xr-x.   2 root root  4096 Sep 10 10:47 redis-cluster
dr-xr-x---.  32 root root  4096 Sep 10 10:47 root
dr-xr-xr-x.   2 root root 12288 Sep  2 22:53 sbin
drwxr-xr-x.   7 root root     0 Sep 10 08:46 selinux
drwxr-xr-x.   2 root root  4096 Jun 28  2011 srv
drwxr-xr-x.  13 root root     0 Sep 10 08:46 sys
drwxrwxrwt.  43 root root  4096 Sep 10 10:47 tmp
drwxr-xr-x.  15 root root  4096 Sep  8 22:25 usr
drwxr-xr-x.  25 root root  4096 Sep  2 22:09 var
[root@RedHat-BG /]# rm redis-cluster/
rm: cannot remove `redis-cluster/': Is a directory
[root@RedHat-BG /]# rm /redis-cluster
rm: cannot remove `/redis-cluster': Is a directory
[root@RedHat-BG /]# rm -d /redis-cluster
rm: cannot remove `/redis-cluster': Is a directory
[root@RedHat-BG /]# rmdir redis-cluster/
[root@RedHat-BG /]# ll
total 102
dr-xr-xr-x.   2 root root  4096 Sep  2 22:54 bin
dr-xr-xr-x.   5 root root  1024 Sep  3 00:03 boot
drwxr-xr-x.  10 root root  4096 Sep  2 23:56 cgroup
drwxr-xr-x.  19 root root  3980 Sep 10 08:47 dev
drwxr-xr-x. 152 root root 12288 Sep 10 09:23 etc
drwxr-xr-x.   5 root root  4096 Sep  2 23:34 home
dr-xr-xr-x.  13 root root  4096 Sep  2 22:53 lib
dr-xr-xr-x.  11 root root 12288 Sep  2 22:53 lib64
drwx------.   2 root root 16384 Sep  2 21:21 lost+found
drwxr-xr-x.   3 root root  4096 Sep 10 08:48 media
drwxr-xr-x.   2 root root     0 Sep 10 08:47 misc
drwxr-xr-x.   3 root root  4096 Sep  2 17:19 mnt
drwxr-xr-x.   2 root root     0 Sep 10 08:47 net
drwxr-xr-x.   4 root root  4096 Sep  2 22:09 opt
dr-xr-xr-x. 261 root root     0 Sep 10 08:46 proc
dr-xr-x---.  32 root root  4096 Sep 10 10:47 root
dr-xr-xr-x.   2 root root 12288 Sep  2 22:53 sbin
drwxr-xr-x.   7 root root     0 Sep 10 08:46 selinux
drwxr-xr-x.   2 root root  4096 Jun 28  2011 srv
drwxr-xr-x.  13 root root     0 Sep 10 08:46 sys
drwxrwxrwt.  43 root root  4096 Sep 10 10:47 tmp
drwxr-xr-x.  15 root root  4096 Sep  8 22:25 usr
drwxr-xr-x.  25 root root  4096 Sep  2 22:09 var
[root@RedHat-BG /]# cd /usr/local/redis
[root@RedHat-BG redis]# ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
[root@RedHat-BG redis]# mkdir redis-cluster
[root@RedHat-BG redis]# ll
total 8
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
drwxr-xr-x. 2 root root 4096 Sep 10 10:49 redis-cluster
[root@RedHat-BG redis]# cd redis-cluster/
[root@RedHat-BG redis-cluster]# mkdir 7001
[root@RedHat-BG redis-cluster]# mkdir 7002
[root@RedHat-BG redis-cluster]# mkdir 7003
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cp /usr/local/redis-4.0.0/redis.conf 7001
[root@RedHat-BG redis-cluster]# l
bash: l: command not found
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:51 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cd 7001
[root@RedHat-BG 7001]# ll
total 60
-rw-r--r--. 1 root root 57764 Sep 10 10:51 redis.conf
[root@RedHat-BG 7001]# cp /usr/local/redis-4.0.0/redis.conf 7002
[root@RedHat-BG 7001]# cp /usr/local/redis-4.0.0/redis.conf 7003


分别修改这三个配置文件,修改如下内容

RedHat6.5虚拟机架设Redis和Kafka伪集群
port  7000                                        //端口7000,7002,7003        
bind 本机ip //默认ip为127.0.0.1 需要改为其他节点机器可访问的ip 否则创建集群时无法访问对应的端口,无法创建集群
daemonize yes //redis后台运行
pidfile /var/run/redis_7000.pid //pidfile文件对应7000,7001,7002
cluster-enabled yes //开启集群 把注释#去掉
cluster-config-file nodes_7000.conf //集群的配置 配置文件首次启动自动生成 7000,7001,7002
cluster-node-timeout 15000 //请求超时 默认15秒,可自行设置
appendonly yes //aof日志开启 有需要就开启,它会每次写操作都记录一条日志

bind 192.168.43.105

protected-mode no

port 7001

daemonize yes

pidfile /var/run/redis_7001.pid

appendonly yes

cluster-enabled yes

cluster-config-file nodes-7001.conf

cluster-node-timeout 15000


操作:

[root@RedHat-BG /]# cd /usr/local/redis
[root@RedHat-BG redis]# ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
[root@RedHat-BG redis]# mkdir redis-cluster
[root@RedHat-BG redis]# ll
total 8
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
drwxr-xr-x. 2 root root 4096 Sep 10 10:49 redis-cluster
[root@RedHat-BG redis]# cd redis-cluster/
[root@RedHat-BG redis-cluster]# mkdir 7001
[root@RedHat-BG redis-cluster]# mkdir 7002
[root@RedHat-BG redis-cluster]# mkdir 7003
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cp /usr/local/redis-4.0.0/redis.conf 7001
[root@RedHat-BG redis-cluster]# l
bash: l: command not found
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:51 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cd 7001
[root@RedHat-BG 7001]# ll
total 60
-rw-r--r--. 1 root root 57764 Sep 10 10:51 redis.conf
[root@RedHat-BG 7001]# cp /usr/local/redis-4.0.0/redis.conf 7002
[root@RedHat-BG 7001]# cp /usr/local/redis-4.0.0/redis.conf 7003
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# 
[root@RedHat-BG 7001]# pwd
/usr/local/redis/redis-cluster/7001
[root@RedHat-BG 7001]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:52 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cd 7001
[root@RedHat-BG 7001]# ll
total 180
-rw-r--r--. 1 root root 57764 Sep 10 10:52 7002
-rw-r--r--. 1 root root 57764 Sep 10 10:52 7003
-rw-r--r--. 1 root root 57764 Sep 10 10:51 redis.conf
[root@RedHat-BG 7001]# pwd
/usr/local/redis/redis-cluster/7001
[root@RedHat-BG 7001]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:52 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cd 7002
[root@RedHat-BG 7002]# ll
total 0
[root@RedHat-BG 7002]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:52 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cd 7001
[root@RedHat-BG 7001]# ll
total 180
-rw-r--r--. 1 root root 57764 Sep 10 10:52 7002
-rw-r--r--. 1 root root 57764 Sep 10 10:52 7003
-rw-r--r--. 1 root root 57764 Sep 10 10:51 redis.conf
[root@RedHat-BG 7001]# rmdir -rf 7002
rmdir: invalid option -- 'r'
Try `rmdir --help' for more information.
[root@RedHat-BG 7001]# rm -rf 7002
[root@RedHat-BG 7001]# rm -rf 7003
[root@RedHat-BG 7001]# ll
total 60
-rw-r--r--. 1 root root 57764 Sep 10 10:51 redis.conf
[root@RedHat-BG 7001]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:58 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:50 7003
[root@RedHat-BG redis-cluster]# cp /usr/local/redis-4.0.0/redis.conf 7002
[root@RedHat-BG redis-cluster]# cp /usr/local/redis-4.0.0/redis.conf 7003
[root@RedHat-BG redis-cluster]# cd 7002
[root@RedHat-BG 7002]# ll
total 60
-rw-r--r--. 1 root root 57764 Sep 10 10:59 redis.conf
[root@RedHat-BG 7002]# cd ../
[root@RedHat-BG redis-cluster]# cd 7003
[root@RedHat-BG 7003]# ll
total 60
-rw-r--r--. 1 root root 57764 Sep 10 10:59 redis.conf
[root@RedHat-BG 7003]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 10:58 7001
drwxr-xr-x. 2 root root 4096 Sep 10 10:59 7002
drwxr-xr-x. 2 root root 4096 Sep 10 10:59 7003
[root@RedHat-BG redis-cluster]# cd 7001
[root@RedHat-BG 7001]# vim redis.conf 


继续操作,启动每个redis,查看是否成功启动:

[root@RedHat-BG local]# cd redis
[root@RedHat-BG redis]# ll
total 8
drwxr-xr-x. 2 root root 4096 Sep 10 10:08 bin
drwxr-xr-x. 5 root root 4096 Sep 10 10:50 redis-cluster
[root@RedHat-BG redis]# cd bin
[root@RedHat-BG bin]# ll
total 35400
-rwxr-xr-x. 1 root root 5597438 Sep 10 10:08 redis-benchmark
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-aof
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-rdb
-rwxr-xr-x. 1 root root 5728350 Sep 10 10:08 redis-cli
lrwxrwxrwx. 1 root root      12 Sep 10 10:08 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-server
[root@RedHat-BG bin]# ./redis-server ../redis-cluster/7001/redis.conf&
[1] 10323
[root@RedHat-BG bin]# 10323:C 10 Sep 11:24:43.553 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10323:C 10 Sep 11:24:43.553 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=10323, just started
10323:C 10 Sep 11:24:43.553 # Configuration loaded
[root@RedHat-BG bin]# ps -ef|grep redis
root      10324      1  0 11:24 ?        00:00:00 ./redis-server 192.168.43.105:7001 [cluster]   
root      10339   9671  0 11:25 pts/0    00:00:00 grep redis
[1]+  Done                    ./redis-server ../redis-cluster/7001/redis.conf
[root@RedHat-BG bin]# ./redis-server ../redis-cluster/7002/redis.conf&
[1] 10341
[root@RedHat-BG bin]# 10341:C 10 Sep 11:25:43.966 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10341:C 10 Sep 11:25:43.966 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=10341, just started
10341:C 10 Sep 11:25:43.966 # Configuration loaded
^C
[1]+  Done                    ./redis-server ../redis-cluster/7002/redis.conf
[root@RedHat-BG bin]# ps -ef|grep redis
root      10324      1  0 11:24 ?        00:00:00 ./redis-server 192.168.43.105:7001 [cluster]   
root      10342      1  0 11:25 ?        00:00:00 ./redis-server 192.168.43.105:7002 [cluster]   
root      10356   9671  0 11:26 pts/0    00:00:00 grep redis
[root@RedHat-BG bin]# ./redis-server ../redis-cluster/7003/redis.conf&
[1] 10357
[root@RedHat-BG bin]# 10357:C 10 Sep 11:26:39.166 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10357:C 10 Sep 11:26:39.166 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=10357, just started
10357:C 10 Sep 11:26:39.166 # Configuration loaded


[1]+  Done                    ./redis-server ../redis-cluster/7003/redis.conf
[root@RedHat-BG bin]# 
[root@RedHat-BG bin]# ps -ef|grep redis
root      10324      1  0 11:24 ?        00:00:00 ./redis-server 192.168.43.105:7001 [cluster]   
root      10342      1  0 11:25 ?        00:00:00 ./redis-server 192.168.43.105:7002 [cluster]   
root      10358      1  0 11:26 ?        00:00:00 ./redis-server 192.168.43.105:7003 [cluster]   
root      10392   9671  0 11:27 pts/0    00:00:00 grep redis


继续操作,创建另外3个节点,一般在另一台机器,但这里都在这台虚拟机上,伪集群方式:


[root@RedHat-BG bin]# pwd
/usr/local/redis/bin
[root@RedHat-BG bin]# cd ../
[root@RedHat-BG redis]# ll
total 8
drwxr-xr-x. 2 root root 4096 Sep 10 11:26 bin
drwxr-xr-x. 5 root root 4096 Sep 10 10:50 redis-cluster
[root@RedHat-BG redis]# cd redis-cluster/
[root@RedHat-BG redis-cluster]# ll
total 12
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
[root@RedHat-BG redis-cluster]# cp -R 7001 7004
[root@RedHat-BG redis-cluster]# ll
total 16
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
drwxr-xr-x. 2 root root 4096 Sep 10 11:30 7004
[root@RedHat-BG redis-cluster]# cd 7004
[root@RedHat-BG 7004]# ll
total 60
-rw-r--r--. 1 root root 57764 Sep 10 11:30 redis.conf
[root@RedHat-BG 7004]# vim redis.conf 
[root@RedHat-BG 7004]# pwd
/usr/local/redis/redis-cluster/7004
[root@RedHat-BG 7004]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 16
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7004
[root@RedHat-BG redis-cluster]# cp -R 7004 7005
[root@RedHat-BG redis-cluster]# ll
total 20
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7004
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7005
[root@RedHat-BG redis-cluster]# cp -R 7004 7006
[root@RedHat-BG redis-cluster]# ll
total 24
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7004
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7005
drwxr-xr-x. 2 root root 4096 Sep 10 11:44 7006
[root@RedHat-BG redis-cluster]# cd 7005
[root@RedHat-BG 7005]# vim redis.conf 
[root@RedHat-BG 7005]# cd ../\
> ^C
[root@RedHat-BG 7005]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 24
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7004
drwxr-xr-x. 2 root root 4096 Sep 10 11:45 7005
drwxr-xr-x. 2 root root 4096 Sep 10 11:44 7006
[root@RedHat-BG redis-cluster]# cd 7006
[root@RedHat-BG 7006]# vim redis.conf 
[root@RedHat-BG 7006]# cd ../
[root@RedHat-BG redis-cluster]# ll
total 24
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7004
drwxr-xr-x. 2 root root 4096 Sep 10 11:45 7005
drwxr-xr-x. 2 root root 4096 Sep 10 11:47 7006
[root@RedHat-BG redis-cluster]# pwd
/usr/local/redis/redis-cluster
[root@RedHat-BG redis-cluster]# ll
total 24
drwxr-xr-x. 2 root root 4096 Sep 10 11:12 7001
drwxr-xr-x. 2 root root 4096 Sep 10 11:17 7002
drwxr-xr-x. 2 root root 4096 Sep 10 11:20 7003
drwxr-xr-x. 2 root root 4096 Sep 10 11:43 7004
drwxr-xr-x. 2 root root 4096 Sep 10 11:45 7005
drwxr-xr-x. 2 root root 4096 Sep 10 11:47 7006
[root@RedHat-BG redis-cluster]# cd ../
[root@RedHat-BG redis]# ll
total 8
drwxr-xr-x. 2 root root 4096 Sep 10 11:26 bin
drwxr-xr-x. 8 root root 4096 Sep 10 11:44 redis-cluster
[root@RedHat-BG redis]# cd bin
[root@RedHat-BG bin]# ll
total 35412
-rw-r--r--. 1 root root       0 Sep 10 11:24 appendonly.aof
-rw-r--r--. 1 root root     114 Sep 10 11:24 nodes-7001.conf
-rw-r--r--. 1 root root     114 Sep 10 11:25 nodes-7002.conf
-rw-r--r--. 1 root root     114 Sep 10 11:26 nodes-7003.conf
-rwxr-xr-x. 1 root root 5597438 Sep 10 10:08 redis-benchmark
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-aof
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-check-rdb
-rwxr-xr-x. 1 root root 5728350 Sep 10 10:08 redis-cli
lrwxrwxrwx. 1 root root      12 Sep 10 10:08 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:08 redis-server
[root@RedHat-BG bin]# ./redis-server ../redis-cluster/7004/redis.conf&
[1] 10730
[root@RedHat-BG bin]# 10730:C 10 Sep 11:48:10.750 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10730:C 10 Sep 11:48:10.750 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=10730, just started
10730:C 10 Sep 11:48:10.750 # Configuration loaded
^C
[1]+  Done                    ./redis-server ../redis-cluster/7004/redis.conf
[root@RedHat-BG bin]# ./redis-server ../redis-cluster/7005/redis.conf&
[1] 10736
[root@RedHat-BG bin]# 10736:C 10 Sep 11:48:24.000 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10736:C 10 Sep 11:48:24.000 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=10736, just started
10736:C 10 Sep 11:48:24.000 # Configuration loaded
^C
[1]+  Done                    ./redis-server ../redis-cluster/7005/redis.conf
[root@RedHat-BG bin]# ./redis-server ../redis-cluster/7006/redis.conf&
[1] 10741
[root@RedHat-BG bin]# 10741:C 10 Sep 11:48:32.730 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10741:C 10 Sep 11:48:32.730 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=10741, just started
10741:C 10 Sep 11:48:32.730 # Configuration loaded
^C
[1]+  Done                    ./redis-server ../redis-cluster/7006/redis.conf
[root@RedHat-BG bin]# ps -ef|grep redis|grep -v grep
root      10324      1  0 11:24 ?        00:00:02 ./redis-server 192.168.43.105:7001 [cluster]   
root      10342      1  0 11:25 ?        00:00:02 ./redis-server 192.168.43.105:7002 [cluster]   
root      10358      1  0 11:26 ?        00:00:01 ./redis-server 192.168.43.105:7003 [cluster]   
root      10731      1  0 11:48 ?        00:00:00 ./redis-server 192.168.43.105:7004 [cluster]   
root      10737      1  0 11:48 ?        00:00:00 ./redis-server 192.168.43.105:7005 [cluster]   
root      10742      1  0 11:48 ?        00:00:00 ./redis-server 192.168.43.105:7006 [cluster] 


需要注意的两点:

1.cp -R是递归复制目录内容,复制其他节点改好的内容快一些,只要改端口相关即可,顺便在改的过程中查看这个被复制节点的配置是否正确,因为当前就是它配置的拷贝


2.启动时指定不同配置文件,命令都是bin目录下的redis-server,注意./方式执行可执行文件,&符号的添加是为了可以退出到命令行而redis不会被结束


这样创建了6个cluster模式的节点,太少不行,redis集群有一个最小节点数限制。


执行redis的创建集群命令创建集群

cd /usr/local/redis3.0/src

./redis-trib.rb  create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

6.1执行上面的命令的时候会报错,因为是执行的ruby的脚本,需要ruby的环境

错误内容:/usr/bin/env: ruby: No such file or directory

所以需要安装ruby的环境,这里推荐使用yum install ruby安装

yum install ruby

 

6.2然后再执行第6步的创建集群命令,还会报错,提示缺少rubygems组件,使用yum安装

 

错误内容:

./redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)

from ./redis-trib.rb:24

yum install rubygems

6.3再次执行第6步的命令,还会报错,提示不能加载redis,是因为缺少redisruby的接口,使用gem 安装

错误内容:

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)

from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

from ./redis-trib.rb:25

 

gem install  redis --version 3.0.0

注意:gem install redis --version 3.0.0 失败的话,需要修改一下gem的源
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/


无法执行yum安装:


redhat6.5 配置使用centos的yum源2014-09-11 16:11:39 标签:yum redhat6 centos源

新安装了redhat6.5.安装后,登录系统,使用yum update 更新系统。提示:

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

无法更新。

redhat 默认自带的 yum 源需要注册,才能更新。我们想不花钱也可以更新,需要替换掉redhat的yum源。

1.检查是否安装yum包

查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:

[root@localhost ~]# rpm -qa |grep yum

yum-metadata-parser-1.0-8.fc6

yum-3.0.1-5.el5

yum-rhn-plugin-0.4.3-1.el5

yum-updatesd-3.0.1-5.el5

2 删除redhat自带的yum包

卸载上面显示的所有yum包:

[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)

再用

[root@localhost ~]# rpm -qa |grep yum

[root@localhost ~]# 

查看,无信息显示表示已经卸载完成。

3.下载新的yum包。使用Centos6.5的yum包

123 # wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm# wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-3.2.29-40.el6.centos.noarch.rpm# wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm


安装yum软件包

注意:单个的安装包可能会依赖其它包(例如yum和yum-fastestmirror会相互依赖),所以我们可以把所有这些包放在一起,用一行命令将它们同时安装即可:

1 # rpm -ivh yum-metadata-parser-1.1.2-16.el6.i686.rpm yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

4.更换yum源。使用163的源

123 # cd /etc/yum.repos.d/# wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo# vi CentOS6-Base-163.repo

编辑文件,把文件里面的$releasever全部替换为版本号,即6.5 最后保存!或者直接把下面的内存拷贝到CentOS6-Base-163.repo文件中即可(已经修改好)

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 # CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client.  You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead.## [base]name=CentOS-6 - Base - 163.combaseurl=http://mirrors.163.com/centos/6/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates]name=CentOS-6 - Updates - 163.combaseurl=http://mirrors.163.com/centos/6/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful[extras]name=CentOS-6 - Extras - 163.combaseurl=http://mirrors.163.com/centos/6/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages[centosplus]name=CentOS-6 - Plus - 163.combaseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users[contrib]name=CentOS-6 - Contrib - 163.combaseurl=http://mirrors.163.com/centos/6/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

5.清除原有缓存

1 # yum clean all

重建缓存,以提高搜索安装软件的速度

1 # yum makecache

6.更新系统

1 # yum update

操作:
[root@RedHat-BG bin]# ll
total 35400
-rwxr-xr-x. 1 root root 5597438 Sep 10 10:03 redis-benchmark
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-check-aof
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-check-rdb
-rwxr-xr-x. 1 root root 5728350 Sep 10 10:03 redis-cli
lrwxrwxrwx. 1 root root      12 Sep 10 10:03 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-server
[root@RedHat-BG bin]# pwd
/usr/local/bin
[root@RedHat-BG bin]# cp /usr/local/redis-4.0.0/src/redis-trib.rb 
cp: missing destination file operand after `/usr/local/redis-4.0.0/src/redis-trib.rb'
Try `cp --help' for more information.
[root@RedHat-BG bin]# cp /usr/local/redis-4.0.0/src/redis-trib.rb .
[root@RedHat-BG bin]# ll
total 35460
-rwxr-xr-x. 1 root root 5597438 Sep 10 10:03 redis-benchmark
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-check-aof
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-check-rdb
-rwxr-xr-x. 1 root root 5728350 Sep 10 10:03 redis-cli
lrwxrwxrwx. 1 root root      12 Sep 10 10:03 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-server
-rwxr-xr-x. 1 root root   60843 Sep 10 11:59 redis-trib.rb
[root@RedHat-BG bin]# redis-trib.rb  create  --replicas  1 192.168.43.105:7001 192.168.43.105:7002 192.168.43.105:7003 192.168.43.105:7004 192.168.43.105:7005 192.168.43.105:7006
/usr/local/bin/redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from /usr/local/bin/redis-trib.rb:24
[root@RedHat-BG bin]# yum install rubygems
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
No package rubygems available.
Error: Nothing to do
[root@RedHat-BG bin]# pwd
/usr/local/bin
[root@RedHat-BG bin]# cd /
[root@RedHat-BG /]# ll
total 102
dr-xr-xr-x.   2 root root  4096 Sep  2 22:54 bin
dr-xr-xr-x.   5 root root  1024 Sep  3 00:03 boot
drwxr-xr-x.  10 root root  4096 Sep  2 23:56 cgroup
drwxr-xr-x.  19 root root  3980 Sep 10 08:47 dev
drwxr-xr-x. 152 root root 12288 Sep 10 09:23 etc
drwxr-xr-x.   5 root root  4096 Sep  2 23:34 home
dr-xr-xr-x.  13 root root  4096 Sep  2 22:53 lib
dr-xr-xr-x.  11 root root 12288 Sep  2 22:53 lib64
drwx------.   2 root root 16384 Sep  2 21:21 lost+found
drwxr-xr-x.   3 root root  4096 Sep 10 08:48 media
drwxr-xr-x.   2 root root     0 Sep 10 08:47 misc
drwxr-xr-x.   3 root root  4096 Sep  2 17:19 mnt
drwxr-xr-x.   2 root root     0 Sep 10 08:47 net
drwxr-xr-x.   4 root root  4096 Sep  2 22:09 opt
dr-xr-xr-x. 268 root root     0 Sep 10 08:46 proc
dr-xr-x---.  32 root root  4096 Sep 10 11:47 root
dr-xr-xr-x.   2 root root 12288 Sep  2 22:53 sbin
drwxr-xr-x.   7 root root     0 Sep 10 08:46 selinux
drwxr-xr-x.   2 root root  4096 Jun 28  2011 srv
drwxr-xr-x.  13 root root     0 Sep 10 08:46 sys
drwxrwxrwt.  43 root root  4096 Sep 10 11:33 tmp
drwxr-xr-x.  15 root root  4096 Sep  8 22:25 usr
drwxr-xr-x.  25 root root  4096 Sep  2 22:09 var
[root@RedHat-BG /]# cd usr
[root@RedHat-BG usr]# ll
total 304
dr-xr-xr-x.   2 root root  73728 Sep  8 22:18 bin
drwxr-xr-x.   2 root root   4096 Jun 28  2011 etc
drwxr-xr-x.   2 root root   4096 Jun 28  2011 games
drwxr-xr-x. 146 root root  12288 Sep  2 22:09 include
drwxr-xr-x.   3 root root   4096 Sep  8 22:26 java
dr-xr-xr-x.  34 root root   4096 Sep  2 17:19 lib
dr-xr-xr-x. 152 root root 131072 Sep  3 08:26 lib64
drwxr-xr-x.  35 root root  12288 Sep  2 20:16 libexec
drwxr-xr-x.  15 root root   4096 Sep 10 10:08 local
drwx------.   2 root root  16384 Sep  2 21:21 lost+found
dr-xr-xr-x.   2 root root  20480 Sep  3 08:26 sbin
drwxr-xr-x. 293 root root  12288 Sep  2 22:11 share
drwxr-xr-x.   4 root root   4096 Sep  2 21:37 src
lrwxrwxrwx.   1 root root     10 Sep  2 21:37 tmp -> ../var/tmp
[root@RedHat-BG usr]# cd local
[root@RedHat-BG local]# ll
total 64
drwxr-xr-x. 2 root root  4096 Sep 10 11:59 bin
drwxr-xr-x. 2 root root  4096 Jun 28  2011 etc
drwxr-xr-x. 2 root root  4096 Jun 28  2011 games
drwxr-xr-x. 2 root root  4096 Jun 28  2011 include
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib64
drwxr-xr-x. 2 root root  4096 Jun 28  2011 libexec
drwx------. 2 root root 16384 Sep  2 21:21 lost+found
drwxr-xr-x. 4 root root  4096 Sep 10 10:49 redis
drwxrwxr-x. 6 root root  4096 Jul 14 19:28 redis-4.0.0
drwxr-xr-x. 2 root root  4096 Jun 28  2011 sbin
drwxr-xr-x. 5 root root  4096 Sep  2 21:37 share
drwxr-xr-x. 2 root root  4096 Jun 28  2011 src
[root@RedHat-BG local]# wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm
--2017-09-10 12:11:06--  http://mirrors.163.com/centos/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.209, 123.58.190.235, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27140 (27K) [application/x-redhat-package-manager]
Saving to: “yum-metadata-parser-1.1.2-16.el6.i686.rpm”


100%[==============================================================================================================================>] 27,140      --.-K/s   in 0.1s    


2017-09-10 12:11:06 (221 KB/s) - “yum-metadata-parser-1.1.2-16.el6.i686.rpm” saved [27140/27140]


[root@RedHat-BG local]# ll
total 92
drwxr-xr-x. 2 root root  4096 Sep 10 11:59 bin
drwxr-xr-x. 2 root root  4096 Jun 28  2011 etc
drwxr-xr-x. 2 root root  4096 Jun 28  2011 games
drwxr-xr-x. 2 root root  4096 Jun 28  2011 include
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib64
drwxr-xr-x. 2 root root  4096 Jun 28  2011 libexec
drwx------. 2 root root 16384 Sep  2 21:21 lost+found
drwxr-xr-x. 4 root root  4096 Sep 10 10:49 redis
drwxrwxr-x. 6 root root  4096 Jul 14 19:28 redis-4.0.0
drwxr-xr-x. 2 root root  4096 Jun 28  2011 sbin
drwxr-xr-x. 5 root root  4096 Sep  2 21:37 share
drwxr-xr-x. 2 root root  4096 Jun 28  2011 src
-rw-r--r--. 1 root root 27140 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.i686.rpm
[root@RedHat-BG local]# wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
--2017-09-10 12:11:32--  http://mirrors.163.com/centos/6/os/i386/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
Resolving mirrors.163.com... 123.58.190.228, 123.58.190.234, 123.58.190.236, ...
Connecting to mirrors.163.com|123.58.190.228|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-09-10 12:11:33 ERROR 404: Not Found.


[root@RedHat-BG local]# wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
--2017-09-10 12:11:51--  http://mirrors.163.com/centos/6/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.228, 123.58.190.234, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-09-10 12:11:51 ERROR 404: Not Found.


[root@RedHat-BG local]# wget http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
--2017-09-10 12:12:41--  http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
Resolving mirrors.kernel.org... 198.145.21.9, 2001:19d0:306:6:0:1994:3:14
Connecting to mirrors.kernel.org|198.145.21.9|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-09-10 12:12:42 ERROR 404: Not Found.


[root@RedHat-BG local]# wget http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
--2017-09-10 12:13:07--  http://mirrors.kernel.org/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
Resolving mirrors.kernel.org... 198.145.21.9, 2001:19d0:306:6:0:1994:3:14
Connecting to mirrors.kernel.org|198.145.21.9|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-09-10 12:13:07 ERROR 404: Not Found.


[root@RedHat-BG local]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
--2017-09-10 12:13:57--  http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
Resolving mirrors.163.com... 123.58.190.209, 123.58.190.237, 123.58.190.228, ...
Connecting to mirrors.163.com|123.58.190.209|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-09-10 12:13:57 ERROR 404: Not Found.


[root@RedHat-BG local]# wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
--2017-09-10 12:14:49--  http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
Resolving mirrors.aliyun.com... 115.28.122.210, 112.124.140.210
Connecting to mirrors.aliyun.com|115.28.122.210|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-09-10 12:14:49 ERROR 404: Not Found.


[root@RedHat-BG local]# wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
--2017-09-10 12:15:19--  http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
Resolving mirrors.aliyun.com... 112.124.140.210, 115.28.122.210
Connecting to mirrors.aliyun.com|112.124.140.210|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-09-10 12:15:20 ERROR 404: Not Found.

卸载和安装yum,python:

[xiaobai@RedHat-BG local]$ rpm -qa |grep yum
yum-utils-1.1.30-14.el6.noarch
yum-3.2.29-40.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
PackageKit-yum-plugin-0.5.8-21.el6.x86_64
yum-rhn-plugin-0.9.1-48.el6.noarch
PackageKit-yum-0.5.8-21.el6.x86_64
yum-plugin-security-1.1.30-14.el6.noarch
[xiaobai@RedHat-BG local]$ rpm -qa|grep yum|xargs rpm -e --nodeps
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
xargs: rpm: exited with status 255; aborting
[xiaobai@RedHat-BG local]$ su root
Password: 
[root@RedHat-BG local]# rpm -qa|grep yum|xargs rpm -e --nodeps
[root@RedHat-BG local]# rpm -qa |grep yum
[root@RedHat-BG local]# ll
total 92
drwxr-xr-x. 2 root root  4096 Sep 10 11:59 bin
drwxr-xr-x. 2 root root  4096 Jun 28  2011 etc
drwxr-xr-x. 2 root root  4096 Jun 28  2011 games
drwxr-xr-x. 2 root root  4096 Jun 28  2011 include
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib
drwxr-xr-x. 2 root root  4096 Jun 28  2011 lib64
drwxr-xr-x. 2 root root  4096 Jun 28  2011 libexec
drwx------. 2 root root 16384 Sep  2 21:21 lost+found
drwxr-xr-x. 4 root root  4096 Sep 10 10:49 redis
drwxrwxr-x. 6 root root  4096 Jul 14 19:28 redis-4.0.0
drwxr-xr-x. 2 root root  4096 Jun 28  2011 sbin
drwxr-xr-x. 5 root root  4096 Sep  2 21:37 share
drwxr-xr-x. 2 root root  4096 Jun 28  2011 src
-rw-r--r--. 1 root root 27140 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.i686.rpm
[root@RedHat-BG local]# cd /home/xiaobai/Desktop/
[root@RedHat-BG Desktop]# mv yum /usr/local
[root@RedHat-BG Desktop]# ll
total 8
-rwxr-xr-x. 1 xiaobai xiaobai 6333 Sep  3 15:49 gnome-terminal.desktop
[root@RedHat-BG Desktop]# cd /usr/local
[root@RedHat-BG local]# ll
total 96
drwxr-xr-x. 2 root    root     4096 Sep 10 11:59 bin
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 etc
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 games
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 include
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 lib
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 lib64
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 libexec
drwx------. 2 root    root    16384 Sep  2 21:21 lost+found
drwxr-xr-x. 4 root    root     4096 Sep 10 10:49 redis
drwxrwxr-x. 6 root    root     4096 Jul 14 19:28 redis-4.0.0
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 sbin
drwxr-xr-x. 5 root    root     4096 Sep  2 21:37 share
drwxr-xr-x. 2 root    root     4096 Jun 28  2011 src
drwxrwxrwx. 2 xiaobai xiaobai  4096 Mar 14  2016 yum
-rw-r--r--. 1 root    root    27140 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.i686.rpm
[root@RedHat-BG local]# cd yun
bash: cd: yun: No such file or directory
[root@RedHat-BG local]# cd yum
[root@RedHat-BG yum]# ll
total 1444
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm 
warning: yum-3.4.3-132.el7.centos.0.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
pyliblzma is needed by yum-3.4.3-132.el7.centos.0.1.noarch
python(abi) = 2.7 is needed by yum-3.4.3-132.el7.centos.0.1.noarch
pyxattr is needed by yum-3.4.3-132.el7.centos.0.1.noarch
libpython2.7.so.1.0()(64bit) is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
python(abi) = 2.7 is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
[root@RedHat-BG yum]# mkdir /usr/local/src/python
[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
--2017-09-10 14:23:12--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.228, 123.58.190.236, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 77968 (76K) [application/x-redhat-package-manager]
Saving to: “python-2.6.6-66.el6_8.x86_64.rpm”


100%[===================================================================================================================>] 77,968       282K/s   in 0.3s    


2017-09-10 14:23:13 (282 KB/s) - “python-2.6.6-66.el6_8.x86_64.rpm” saved [77968/77968]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
--2017-09-10 14:23:13--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
Resolving mirrors.163.com... 123.58.190.235, 123.58.190.209, 123.58.190.234, ...
Connecting to mirrors.163.com|123.58.190.235|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 37052 (36K) [application/x-redhat-package-manager]
Saving to: “python-iniparse-0.3.1-2.1.el6.noarch.rpm”


100%[===================================================================================================================>] 37,052       154K/s   in 0.2s    


2017-09-10 14:23:13 (154 KB/s) - “python-iniparse-0.3.1-2.1.el6.noarch.rpm” saved [37052/37052]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
--2017-09-10 14:23:13--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.235, 123.58.190.209, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 78448 (77K) [application/x-redhat-package-manager]
Saving to: “python-pycurl-7.19.0-9.el6.x86_64.rpm”


100%[===================================================================================================================>] 78,448       279K/s   in 0.3s    


2017-09-10 14:23:14 (279 KB/s) - “python-pycurl-7.19.0-9.el6.x86_64.rpm” saved [78448/78448]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
--2017-09-10 14:23:14--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.228, 123.58.190.237, 123.58.190.235, ...
Connecting to mirrors.163.com|123.58.190.228|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 176932 (173K) [application/x-redhat-package-manager]
Saving to: “python-devel-2.6.6-66.el6_8.x86_64.rpm”


100%[===================================================================================================================>] 176,932      368K/s   in 0.5s    


2017-09-10 14:23:15 (368 KB/s) - “python-devel-2.6.6-66.el6_8.x86_64.rpm” saved [176932/176932]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
--2017-09-10 14:23:15--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.236, 123.58.190.228, 123.58.190.237, ...
Connecting to mirrors.163.com|123.58.190.236|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5589812 (5.3M) [application/x-redhat-package-manager]
Saving to: “python-libs-2.6.6-66.el6_8.x86_64.rpm”


100%[==============================================================================================================================>] 5,589,812    289K/s   in 18s     


2017-09-10 14:23:32 (309 KB/s) - “python-libs-2.6.6-66.el6_8.x86_64.rpm” saved [5589812/5589812]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
--2017-09-10 14:23:32--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
Resolving mirrors.163.com... 123.58.190.234, 123.58.190.236, 123.58.190.228, ...
Connecting to mirrors.163.com|123.58.190.234|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 87660 (86K) [application/x-redhat-package-manager]
Saving to: “python-urlgrabber-3.9.1-11.el6.noarch.rpm”


100%[==============================================================================================================================>] 87,660       253K/s   in 0.3s    


2017-09-10 14:23:33 (253 KB/s) - “python-urlgrabber-3.9.1-11.el6.noarch.rpm” saved [87660/87660]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/rpm-python-4.8.0-55.el6.x86_64.rpm
--2017-09-10 14:23:49--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/rpm-python-4.8.0-55.el6.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.209, 123.58.190.234, 123.58.190.236, ...
Connecting to mirrors.163.com|123.58.190.209|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 61520 (60K) [application/x-redhat-package-manager]
Saving to: “rpm-python-4.8.0-55.el6.x86_64.rpm”


100%[==============================================================================================================================>] 61,520       319K/s   in 0.2s    


2017-09-10 14:23:50 (319 KB/s) - “rpm-python-4.8.0-55.el6.x86_64.rpm” saved [61520/61520]


[root@RedHat-BG yum]# ll
total 7432
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# pwd
/usr/local/yum
[root@RedHat-BG yum]#  cd /usr/local/src/python
[root@RedHat-BG python]# ll
total 0
[root@RedHat-BG python]# rpm -ivh python-*   rpm-python-* 
error: File not found by glob: python-*
error: File not found by glob: rpm-python-*
[root@RedHat-BG python]# 




安装新的yum提示python依赖,卸载旧python安装新的:

[root@RedHat-BG yum]# ll
total 1444
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm 
warning: yum-3.4.3-132.el7.centos.0.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
pyliblzma is needed by yum-3.4.3-132.el7.centos.0.1.noarch
python(abi) = 2.7 is needed by yum-3.4.3-132.el7.centos.0.1.noarch
pyxattr is needed by yum-3.4.3-132.el7.centos.0.1.noarch
libpython2.7.so.1.0()(64bit) is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
python(abi) = 2.7 is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
[root@RedHat-BG yum]# mkdir /usr/local/src/python
[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
--2017-09-10 14:23:12--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.228, 123.58.190.236, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 77968 (76K) [application/x-redhat-package-manager]
Saving to: “python-2.6.6-66.el6_8.x86_64.rpm”


100%[===================================================================================================================>] 77,968       282K/s   in 0.3s    


2017-09-10 14:23:13 (282 KB/s) - “python-2.6.6-66.el6_8.x86_64.rpm” saved [77968/77968]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
--2017-09-10 14:23:13--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
Resolving mirrors.163.com... 123.58.190.235, 123.58.190.209, 123.58.190.234, ...
Connecting to mirrors.163.com|123.58.190.235|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 37052 (36K) [application/x-redhat-package-manager]
Saving to: “python-iniparse-0.3.1-2.1.el6.noarch.rpm”


100%[===================================================================================================================>] 37,052       154K/s   in 0.2s    


2017-09-10 14:23:13 (154 KB/s) - “python-iniparse-0.3.1-2.1.el6.noarch.rpm” saved [37052/37052]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
--2017-09-10 14:23:13--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.235, 123.58.190.209, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 78448 (77K) [application/x-redhat-package-manager]
Saving to: “python-pycurl-7.19.0-9.el6.x86_64.rpm”


100%[===================================================================================================================>] 78,448       279K/s   in 0.3s    


2017-09-10 14:23:14 (279 KB/s) - “python-pycurl-7.19.0-9.el6.x86_64.rpm” saved [78448/78448]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
--2017-09-10 14:23:14--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.228, 123.58.190.237, 123.58.190.235, ...
Connecting to mirrors.163.com|123.58.190.228|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 176932 (173K) [application/x-redhat-package-manager]
Saving to: “python-devel-2.6.6-66.el6_8.x86_64.rpm”


100%[===================================================================================================================>] 176,932      368K/s   in 0.5s    


2017-09-10 14:23:15 (368 KB/s) - “python-devel-2.6.6-66.el6_8.x86_64.rpm” saved [176932/176932]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
--2017-09-10 14:23:15--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.236, 123.58.190.228, 123.58.190.237, ...
Connecting to mirrors.163.com|123.58.190.236|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5589812 (5.3M) [application/x-redhat-package-manager]
Saving to: “python-libs-2.6.6-66.el6_8.x86_64.rpm”


100%[==============================================================================================================================>] 5,589,812    289K/s   in 18s     


2017-09-10 14:23:32 (309 KB/s) - “python-libs-2.6.6-66.el6_8.x86_64.rpm” saved [5589812/5589812]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
--2017-09-10 14:23:32--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
Resolving mirrors.163.com... 123.58.190.234, 123.58.190.236, 123.58.190.228, ...
Connecting to mirrors.163.com|123.58.190.234|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 87660 (86K) [application/x-redhat-package-manager]
Saving to: “python-urlgrabber-3.9.1-11.el6.noarch.rpm”


100%[==============================================================================================================================>] 87,660       253K/s   in 0.3s    


2017-09-10 14:23:33 (253 KB/s) - “python-urlgrabber-3.9.1-11.el6.noarch.rpm” saved [87660/87660]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/rpm-python-4.8.0-55.el6.x86_64.rpm
--2017-09-10 14:23:49--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/rpm-python-4.8.0-55.el6.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.209, 123.58.190.234, 123.58.190.236, ...
Connecting to mirrors.163.com|123.58.190.209|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 61520 (60K) [application/x-redhat-package-manager]
Saving to: “rpm-python-4.8.0-55.el6.x86_64.rpm”


100%[==============================================================================================================================>] 61,520       319K/s   in 0.2s    


2017-09-10 14:23:50 (319 KB/s) - “rpm-python-4.8.0-55.el6.x86_64.rpm” saved [61520/61520]


[root@RedHat-BG yum]# ll
total 7432
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# pwd
/usr/local/yum
[root@RedHat-BG yum]#  cd /usr/local/src/python
[root@RedHat-BG python]# ll
total 0
[root@RedHat-BG python]# rpm -ivh python-*   rpm-python-* 
error: File not found by glob: python-*
error: File not found by glob: rpm-python-*
[root@RedHat-BG python]# rpm -ivh /usr/local/yum/python-*   /usr/local/yum/rpm-python-* 
warning: /usr/local/yum/python-2.6.6-66.el6_8.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
python < 2.6.6-66.el6_8 conflicts with python-devel-2.6.6-66.el6_8.x86_64
rpm = 4.8.0-55.el6 is needed by rpm-python-4.8.0-55.el6.x86_64
[root@RedHat-BG python]# rpm -qa|grep python|xargs rpm -e --allmatches --nodeps








[root@RedHat-BG python]# 
[root@RedHat-BG python]# 
[root@RedHat-BG python]# 
[root@RedHat-BG python]# 
[root@RedHat-BG python]# whereis python|xargs rm -fr
[root@RedHat-BG python]# rpm -ivh /usr/local/yum/python-*   /usr/local/yum/rpm-python-* 
warning: /usr/local/yum/python-2.6.6-66.el6_8.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
rpm = 4.8.0-55.el6 is needed by rpm-python-4.8.0-55.el6.x86_64
[root@RedHat-BG python]# mv /home/xiaobai/Desktop/rpm-python-4.2.2-15mdk.x86_64.rpm .
[root@RedHat-BG python]# ll
total 124
-rwxrw-rw-. 1 xiaobai xiaobai 126460 Sep 10 14:36 rpm-python-4.2.2-15mdk.x86_64.rpm
[root@RedHat-BG python]# pwd
/usr/local/src/python
[root@RedHat-BG python]# mv rpm-python-4.2.2-15mdk.x86_64.rpm /usr/local/yum
[root@RedHat-BG python]# ll
total 0
[root@RedHat-BG python]# rpm -ivh /usr/local/yum/python-*   /usr/local/yum/rpm-python-4.2.2-15mdk.x86_64.rpm 
warning: /usr/local/yum/python-2.6.6-66.el6_8.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
warning: /usr/local/yum/rpm-python-4.2.2-15mdk.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 70771ff3: NOKEY
error: Failed dependencies:
rpm = 4.2.2-15mdk is needed by rpm-python-4.2.2-15mdk.x86_64
python-base >= 2.3 is needed by rpm-python-4.2.2-15mdk.x86_64
librpm-4.2.so()(64bit) is needed by rpm-python-4.2.2-15mdk.x86_64
librpmdb-4.2.so()(64bit) is needed by rpm-python-4.2.2-15mdk.x86_64
librpmio-4.2.so()(64bit) is needed by rpm-python-4.2.2-15mdk.x86_64
[root@RedHat-BG python]# mv /home/xiaobai/Desktop/rpm-python-4.13.0.1-1.fc24.i686.rpm /home/xiaobai/Desktop/rpm-python-4.13.0.1-1.fc24.x86_64.rpm /usr/local/yum
[root@RedHat-BG python]# rpm -ivh /usr/local/yum/python-*   /usr/local/yum/rpm-python-4.13.0.1-1.fc24.i686.rpm 
warning: /usr/local/yum/python-2.6.6-66.el6_8.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
warning: /usr/local/yum/rpm-python-4.13.0.1-1.fc24.i686.rpm: Header V3 RSA/SHA256 Signature, key ID 81b46521: NOKEY
error: Failed dependencies:
libpython2.7.so.1.0 is needed by rpm-python-4.13.0.1-1.fc24.i686
librpm.so.7 is needed by rpm-python-4.13.0.1-1.fc24.i686
librpmbuild.so.7 is needed by rpm-python-4.13.0.1-1.fc24.i686
librpmio.so.7 is needed by rpm-python-4.13.0.1-1.fc24.i686
librpmsign.so.7 is needed by rpm-python-4.13.0.1-1.fc24.i686
python(abi) = 2.7 is needed by rpm-python-4.13.0.1-1.fc24.i686
rpm = 4.13.0.1-1.fc24 is needed by rpm-python-4.13.0.1-1.fc24.i686
[root@RedHat-BG python]# rpm -ivh /usr/local/yum/python-*   /usr/local/yum/rpm-python-4.13.0.1-1.fc24.x86_64.rpm 
warning: /usr/local/yum/python-2.6.6-66.el6_8.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
warning: /usr/local/yum/rpm-python-4.13.0.1-1.fc24.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 81b46521: NOKEY
error: Failed dependencies:
libpython2.7.so.1.0()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpm.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpmbuild.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpmio.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpmsign.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
python(abi) = 2.7 is needed by rpm-python-4.13.0.1-1.fc24.x86_64
rpm = 4.13.0.1-1.fc24 is needed by rpm-python-4.13.0.1-1.fc24.x86_64
[root@RedHat-BG python]# rpm -ivh /usr/local/yum/python-*
warning: /usr/local/yum/python-2.6.6-66.el6_8.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:python-libs            ########################################### [ 17%]
   2:python                 ########################################### [ 33%]
   3:python-pycurl          ########################################### [ 50%]
   4:python-urlgrabber      ########################################### [ 67%]
   5:python-devel           ########################################### [ 83%]
   6:python-iniparse        ########################################### [100%]
[root@RedHat-BG python]# 

其实就是yum和python版本不匹配的问题,python安装中还有和其他依赖包版本冲突的问题

继续仍然失败,无奈从同一篇帖子同时下载匹配的yum和python:

[root@RedHat-BG python]# pwd
/usr/local/src/python
[root@RedHat-BG python]# cd /usr/local/yum
[root@RedHat-BG yum]# ll
total 7764
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  102550 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  103374 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  126460 Sep 10 14:36 rpm-python-4.2.2-15mdk.x86_64.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm 
warning: yum-3.4.3-132.el7.centos.0.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
pyliblzma is needed by yum-3.4.3-132.el7.centos.0.1.noarch
python(abi) = 2.7 is needed by yum-3.4.3-132.el7.centos.0.1.noarch
pyxattr is needed by yum-3.4.3-132.el7.centos.0.1.noarch
rpm-python is needed by yum-3.4.3-132.el7.centos.0.1.noarch
libpython2.7.so.1.0()(64bit) is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
python(abi) = 2.7 is needed by yum-metadata-parser-1.1.4-10.el7.x86_64
[root@RedHat-BG yum]# mkdir /usr/local/src/yum
[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm  
--2017-09-10 14:52:17--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.236, 123.58.190.234, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1042364 (1018K) [application/x-redhat-package-manager]
Saving to: “yum-3.2.29-81.el6.centos.noarch.rpm”


100%[==============================================================================================================================>] 1,042,364    210K/s   in 4.9s    


2017-09-10 14:52:22 (206 KB/s) - “yum-3.2.29-81.el6.centos.noarch.rpm” saved [1042364/1042364]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm  
--2017-09-10 14:52:22--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
Resolving mirrors.163.com... 123.58.190.209, 123.58.190.235, 123.58.190.228, ...
Connecting to mirrors.163.com|123.58.190.209|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27224 (27K) [application/x-redhat-package-manager]
Saving to: “yum-metadata-parser-1.1.2-16.el6.x86_64.rpm”


100%[==============================================================================================================================>] 27,224      --.-K/s   in 0.1s    


2017-09-10 14:52:23 (179 KB/s) - “yum-metadata-parser-1.1.2-16.el6.x86_64.rpm” saved [27224/27224]


[root@RedHat-BG yum]# 
[root@RedHat-BG yum]# wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
--2017-09-10 14:52:25--  http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
Resolving mirrors.163.com... 123.58.190.237, 123.58.190.209, 123.58.190.235, ...
Connecting to mirrors.163.com|123.58.190.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 33524 (33K) [application/x-redhat-package-manager]
Saving to: “yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm”


100%[==============================================================================================================================>] 33,524       194K/s   in 0.2s    


2017-09-10 14:52:26 (194 KB/s) - “yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm” saved [33524/33524]


[root@RedHat-BG yum]# ll
total 8848
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  102550 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  103374 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  126460 Sep 10 14:36 rpm-python-4.2.2-15mdk.x86_64.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rw-r--r--. 1 root    root    1042364 Mar 23 23:04 yum-3.2.29-81.el6.centos.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rw-r--r--. 1 root    root      27224 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--. 1 root    root      33524 Mar 23 23:00 yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
rpm-python is needed by yum-3.2.29-81.el6.centos.noarch
[root@RedHat-BG yum]# 


缺少刚才没安装成功的rpm-python


源帖子:

centos 卸载python和yum之后的解决办法

网上看到有同学yum不能使用的消息,出现了下面的结果

RedHat6.5虚拟机架设Redis和Kafka伪集群

 

无赖的使用了网上的很多方法,还是不行。

于是我卸载了python和yum,觉得自己重新安装python和yum。

步骤1:卸载python

rpm -qa|grep python|xargs rpm -e --allmatches --nodeps

whereis python|xargs rm -fr

步骤2:卸载yum

rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps

rm -rf /etc/yum.repos.d/*

whereis yum|xargs rm -fr

步骤3:安装python

在任何一个镜像站中找到你系统对应版本的python rpm包(我的是centos 6.9的64位系统,使用的镜像是http://mirrors.163.com/centos/6.9/os/x86_64/Packages/)

按 Ctrl+C 复制代码wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/rpm-python-4.8.0-55.el6.x86_64.rpm按 Ctrl+C 复制代码

 

切换到/usr/local/src/python路径下

rpm -ivh python-*   rpm-python-* 

如果中间过程出现了类似下面的代码,这是包与包之间的依赖关系,只需要卸载已经安装的包(rpm -e 包名(没有.rpm后缀)),然后先安装依赖包

如:

      rpm -e yum-metadata-parser-1.1.2-16.el6.x86_64       rpm -ivh /yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

RedHat6.5虚拟机架设Redis和Kafka伪集群

步骤4:安装yum

按 Ctrl+C 复制代码wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm  


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm  


wget http://mirrors.163.com/centos/6.9/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm按 Ctrl+C 复制代码

切换到/usr/local/src/python路径下

rpm -ivh yum-*

步骤5:测试

运行

yum

(成功)

 RedHat6.5虚拟机架设Redis和Kafka伪集群


继续安装,仍然依赖缺少或冲突,重装了一个rpm仍然冲突,无奈最后绝招:加--nodeps 或--force强行安装,成功:


[root@RedHat-BG yum]# ll
total 8848
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  102550 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  103374 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  126460 Sep 10 14:36 rpm-python-4.2.2-15mdk.x86_64.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rw-r--r--. 1 root    root    1042364 Mar 23 23:04 yum-3.2.29-81.el6.centos.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rw-r--r--. 1 root    root      27224 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--. 1 root    root      33524 Mar 23 23:00 yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh rpm-python-4.8.0-55.el6.x86_64.rpm 
warning: rpm-python-4.8.0-55.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
rpm = 4.8.0-55.el6 is needed by rpm-python-4.8.0-55.el6.x86_64
[root@RedHat-BG yum]# mv /home/xiaobai/Desktop/rpm-4.8.0-55.el6.x86_64.rpm .
[root@RedHat-BG yum]# ll
total 9756
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  927420 Sep 10 15:09 rpm-4.8.0-55.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  102550 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  103374 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  126460 Sep 10 14:36 rpm-python-4.2.2-15mdk.x86_64.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rw-r--r--. 1 root    root    1042364 Mar 23 23:04 yum-3.2.29-81.el6.centos.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rw-r--r--. 1 root    root      27224 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--. 1 root    root      33524 Mar 23 23:00 yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh rpm-4.8.0-55.el6.x86_64.rpm 
warning: rpm-4.8.0-55.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
file /bin/rpm from install of rpm-4.8.0-55.el6.x86_64 conflicts with file from package rpm-4.8.0-37.el6.x86_64
file /usr/bin/rpm2cpio from install of rpm-4.8.0-55.el6.x86_64 conflicts with file from package rpm-4.8.0-37.el6.x86_64
file /usr/lib/rpm/macros from install of rpm-4.8.0-55.el6.x86_64 conflicts with file from package rpm-4.8.0-37.el6.x86_64
file /usr/share/man/man8/rpm.8.gz from install of rpm-4.8.0-55.el6.x86_64 conflicts with file from package rpm-4.8.0-37.el6.x86_64
[root@RedHat-BG yum]# rpm -ivh rpm-python-4.8.0-55.el6.x86_64.rpm 
warning: rpm-python-4.8.0-55.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
rpm = 4.8.0-55.el6 is needed by rpm-python-4.8.0-55.el6.x86_64
[root@RedHat-BG yum]# rpm -ivh rpm-python-4.8.0-55.el6.x86_64.rpm 
warning: rpm-python-4.8.0-55.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
rpm = 4.8.0-55.el6 is needed by rpm-python-4.8.0-55.el6.x86_64
[root@RedHat-BG yum]# mv /home/xiaobai/Desktop/rpm-4.8.0-55.el6.i686.rpm .
[root@RedHat-BG yum]# ll
total 10664
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  926332 Sep 10 15:12 rpm-4.8.0-55.el6.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  927420 Sep 10 15:09 rpm-4.8.0-55.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  102550 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  103374 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  126460 Sep 10 14:36 rpm-python-4.2.2-15mdk.x86_64.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rw-r--r--. 1 root    root    1042364 Mar 23 23:04 yum-3.2.29-81.el6.centos.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rw-r--r--. 1 root    root      27224 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--. 1 root    root      33524 Mar 23 23:00 yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh rpm-4.8.0-55.el6.i686.rpm 
warning: rpm-4.8.0-55.el6.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
libacl.so.1 is needed by rpm-4.8.0-55.el6.i686
libbz2.so.1 is needed by rpm-4.8.0-55.el6.i686
libcap.so.2 is needed by rpm-4.8.0-55.el6.i686
libdb-4.7.so is needed by rpm-4.8.0-55.el6.i686
libelf.so.1 is needed by rpm-4.8.0-55.el6.i686
liblua-5.1.so is needed by rpm-4.8.0-55.el6.i686
liblzma.so.0 is needed by rpm-4.8.0-55.el6.i686
libmagic.so.1 is needed by rpm-4.8.0-55.el6.i686
libnss3.so is needed by rpm-4.8.0-55.el6.i686
libpopt.so.0 is needed by rpm-4.8.0-55.el6.i686
libpopt.so.0(LIBPOPT_0) is needed by rpm-4.8.0-55.el6.i686
librpm.so.1 is needed by rpm-4.8.0-55.el6.i686
librpmbuild.so.1 is needed by rpm-4.8.0-55.el6.i686
librpmio.so.1 is needed by rpm-4.8.0-55.el6.i686
libselinux.so.1 is needed by rpm-4.8.0-55.el6.i686
libz.so.1 is needed by rpm-4.8.0-55.el6.i686
[root@RedHat-BG yum]# ll
total 10664
-rw-r--r--. 1 root    root      77968 Aug 19  2016 python-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root     176932 Aug 19  2016 python-devel-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      37052 Jul  3  2011 python-iniparse-0.3.1-2.1.el6.noarch.rpm
-rw-r--r--. 1 root    root    5589812 Aug 19  2016 python-libs-2.6.6-66.el6_8.x86_64.rpm
-rw-r--r--. 1 root    root      78448 May 12  2016 python-pycurl-7.19.0-9.el6.x86_64.rpm
-rw-r--r--. 1 root    root      87660 May 12  2016 python-urlgrabber-3.9.1-11.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  926332 Sep 10 15:12 rpm-4.8.0-55.el6.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  927420 Sep 10 15:09 rpm-4.8.0-55.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  102550 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  103374 Sep 10 14:40 rpm-python-4.13.0.1-1.fc24.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  126460 Sep 10 14:36 rpm-python-4.2.2-15mdk.x86_64.rpm
-rw-r--r--. 1 root    root      61520 May 12  2016 rpm-python-4.8.0-55.el6.x86_64.rpm
-rw-r--r--. 1 root    root    1042364 Mar 23 23:04 yum-3.2.29-81.el6.centos.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai 1272736 Mar 14  2016 yum-3.4.3-132.el7.centos.0.1.noarch.rpm
-rw-r--r--. 1 root    root      27224 Sep 26  2011 yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   28348 Mar 14  2016 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--. 1 root    root      33524 Mar 23 23:00 yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   30600 Mar 14  2016 yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai   23432 Mar 14  2016 yum-updateonboot-1.1.31-34.el7.noarch.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  115904 Mar 14  2016 yum-utils-1.1.31-34.el7.noarch.rpm
[root@RedHat-BG yum]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
rpm-python is needed by yum-3.2.29-81.el6.centos.noarch
[root@RedHat-BG yum]# rpm -ivh rpm-python-4.13.0.1-1.fc24.x86_64.rpm 
warning: rpm-python-4.13.0.1-1.fc24.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 81b46521: NOKEY
error: Failed dependencies:
libpython2.7.so.1.0()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpm.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpmbuild.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpmio.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
librpmsign.so.7()(64bit) is needed by rpm-python-4.13.0.1-1.fc24.x86_64
python(abi) = 2.7 is needed by rpm-python-4.13.0.1-1.fc24.x86_64
rpm = 4.13.0.1-1.fc24 is needed by rpm-python-4.13.0.1-1.fc24.x86_64
[root@RedHat-BG yum]# rpm -ivh rpm-python-4.8.0-55.el6.x86_64.rpm 
warning: rpm-python-4.8.0-55.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
rpm = 4.8.0-55.el6 is needed by rpm-python-4.8.0-55.el6.x86_64
[root@RedHat-BG yum]# rpm -ivh rpm-python-4.8.0-55.el6.x86_64.rpm –nodeps
warning: rpm-python-4.8.0-55.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: open of –nodeps failed: No such file or directory
[root@RedHat-BG yum]# rpm -ivh rpm-python-4.8.0-55.el6.x86_64.rpm --nodeps
warning: rpm-python-4.8.0-55.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:rpm-python             ########################################### [100%]
[root@RedHat-BG yum]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:yum-metadata-parser    ########################################### [ 33%]
   2:yum-plugin-fastestmirro########################################### [ 67%]
   3:yum                    ########################################### [100%]
[root@RedHat-BG yum]# 


相关帖子:

linux下安装rpm遇到的包依赖问题 10

[root@localhost test]# rpm -ivh gcc-c++-3.4.6-11.i386.rpm 
warning: gcc-c++-3.4.6-11.i386.rpm: Header V3 DSA/SHA1 Signature, key ID 82fd17b2: NOKEY
error: Failed dependencies:
gcc = 3.4.6-11 is needed by gcc-c++-3.4.6-11.i386
libstdc++ = 3.4.6 is needed by gcc-c++-3.4.6-11.i386
libstdc++-devel = 3.4.6 is needed by gcc-c++-3.4.6-11.i386
gcc-c++ < 4.0.0 conflicts with binutils-2.20.51.0.2-5.36.el6.i686
[root@localhost test]# rpm -ivh libstdc++-devel-4.1.2-52.el5.i386.rpm 
warning: libstdc++-devel-4.1.2-52.el5.i386.rpm: Header V3 DSA/SHA1 Signature, key ID e8562897: NOKEY
error: Failed dependencies:
libstdc++ = 4.1.2-52.el5 is needed by libstdc++-devel-4.1.2-52.el5.i386
[root@localhost test]# 
这是错误提示,大侠帮忙看看如何解决。谢谢!
收起
加上 --nodeps,意思不考虑依赖2.更狠的--force,强制安装你可以在这两个之前试试--aid自己解决依赖


然而最终rpm方式安装仍然不起作用:新安装的yum还是无法联网获取任何东西进行安装,无奈直接安装Redis集群所缺少的ruby相关,rpm方式仍然提示依赖缺少或冲突问题,

上网找到源码编译安装rubygem的方式:


redhat下安装ruby2.2以及安装rubygems


刚开始尝试通过yum安装ruby,结果安装以后发现安装的ruby版本是1.9.7,通过通过gem install rest-lient的时候说ruby版本过低,于是只好从头再来通过源代码编译的方式安装ruby。

一.安装ruby

1.实现去ruby官网下载最新的稳定版本:

https://www.ruby-lang.org/en/downloads/

    2.通过filezila将tar包上传到linux上面

RedHat6.5虚拟机架设Redis和Kafka伪集群

3.执行以下命令

tar xzvf ruby-2.2.0.tar.gzcd ruby-2.2.0./configure –prefix=/usr/local/rubymake && make instal-prefix是将ruby安装到指定目录,安装的时候开始没有使用root用户安装,出现问题,于是切换到root用户执行 make && make install,完成。4.添加环境变量编辑/etc/profile文件:vim /etc/profile添加在最后添加export RUBY_HOME=/usr/local/ruby2.2.0export PAHT:RUBY_HOME/bin保存。source /etc/profileruby --version二.安装rubygems1.下载rubygems: http://www.oschina.net/news/19237/rubygems-v-1852.tar xzvf rubygems-1.8.5.tgzcd rubygems-1.8.5/ruby setup.rbgem --version
     **安装三个包

gem install  spreadsheet

gem install  pry

gem install rest-client




操作:

[root@RedHat-BG yum]# cd /usr/local/bin
[root@RedHat-BG bin]# ll
total 35460
-rwxr-xr-x. 1 root root 5597438 Sep 10 10:03 redis-benchmark
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-check-aof
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-check-rdb
-rwxr-xr-x. 1 root root 5728350 Sep 10 10:03 redis-cli
lrwxrwxrwx. 1 root root      12 Sep 10 10:03 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8303723 Sep 10 10:03 redis-server
-rwxr-xr-x. 1 root root   60843 Sep 10 11:59 redis-trib.rb
[root@RedHat-BG bin]# redis-trib.rb  create  --replicas  1 192.168.43.105:7001  192.168.43.105:7002 192.168.43.105:7003 192.168.43.105:7004 192.168.43.105:7005 192.168.43.105:7006
/usr/local/bin/redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from /usr/local/bin/redis-trib.rb:24
[root@RedHat-BG bin]# yum -y install ruby ruby-devel rubygems rpm-build
Plugin "product-id" can't be imported
Plugin "subscription-manager" can't be imported
Loaded plugins: fastestmirror
Setting up Install Process
No package ruby-devel available.
No package rubygems available.
Nothing to do
[root@RedHat-BG bin]# yum install ruby  
Plugin "product-id" can't be imported
Plugin "subscription-manager" can't be imported
Loaded plugins: fastestmirror
Setting up Install Process
Nothing to do
[root@RedHat-BG bin]# mv /home/xiaobai/Desktop/ruby-2.4.1-83.fc28.i686.rpm /home/xiaobai/Desktop/rubygems-2.6.13-100.fc28.noarch.rpm .
[root@RedHat-BG bin]# ll
total 35840
-rwxr-xr-x. 1 root    root    5597438 Sep 10 10:03 redis-benchmark
-rwxr-xr-x. 1 root    root    8303723 Sep 10 10:03 redis-check-aof
-rwxr-xr-x. 1 root    root    8303723 Sep 10 10:03 redis-check-rdb
-rwxr-xr-x. 1 root    root    5728350 Sep 10 10:03 redis-cli
lrwxrwxrwx. 1 root    root         12 Sep 10 10:03 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root    root    8303723 Sep 10 10:03 redis-server
-rwxr-xr-x. 1 root    root      60843 Sep 10 11:59 redis-trib.rb
-rwxrw-rw-. 1 xiaobai xiaobai   81120 Sep 10 15:30 ruby-2.4.1-83.fc28.i686.rpm
-rwxrw-rw-. 1 xiaobai xiaobai  304580 Sep 10 15:31 rubygems-2.6.13-100.fc28.noarch.rpm
[root@RedHat-BG bin]# mv ./ruby-2.4.1-83.fc28.i686.rpm ./rubygems-2.6.13-100.fc28.noarch.rpm /usr/local/yum
[root@RedHat-BG bin]# rpm -ivh /usr/local/yum/rubygems-2.6.13-100.fc28.noarch.rpm 
warning: /usr/local/yum/rubygems-2.6.13-100.fc28.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 9db62fb1: NOKEY
error: Failed dependencies:
ruby(release) is needed by rubygems-2.6.13-100.fc28.noarch
rubygem(openssl) >= 2.0.2 is needed by rubygems-2.6.13-100.fc28.noarch
rubygem(psych) >= 2.2.2 is needed by rubygems-2.6.13-100.fc28.noarch
[root@RedHat-BG bin]# rpm -ivh /usr/local/yum/ruby-2.4.1-83.fc28.i686.rpm 
warning: /usr/local/yum/ruby-2.4.1-83.fc28.i686.rpm: Header V3 RSA/SHA256 Signature, key ID 9db62fb1: NOKEY
error: Failed dependencies:
libruby.so.2.4 is needed by ruby-2.4.1-83.fc28.i686
ruby-libs(x86-32) = 2.4.1-83.fc28 is needed by ruby-2.4.1-83.fc28.i686
[root@RedHat-BG bin]# pwd
/usr/local/bin
[root@RedHat-BG bin]# mv /home/xiaobai/Desktop/rubygems-1.8.5.tgz /home/soft
[root@RedHat-BG bin]# cd /home/soft
[root@RedHat-BG soft]# ll
total 303256
-rwxrw-rw-.  1 xiaobai xiaobai  54294367 Jun 25 16:27 apache-activemq-5.14.5-bin.tar.gz
-rwxrw-rw-.  1 xiaobai xiaobai   9375265 Apr 17 19:26 apache-tomcat-8.5.13.tar.gz
-rwxrw-rw-.  1 xiaobai xiaobai 185515842 Sep  8 21:41 jdk-8u144-linux-x64.tar.gz
-rwxrw-rw-.  1 xiaobai xiaobai  36644420 Sep  8 19:36 kafka_2.12-0.11.0.0.tgz
-rwxrw-rw-.  1 xiaobai xiaobai   1710169 Jul 17 18:18 redis-4.0.0.tar.gz
drwxr-xr-x.  2 root    root         4096 Sep  2 23:34 rpm_zh_CN
-rwxrw-rw-.  1 xiaobai xiaobai    249170 Sep 10 15:39 rubygems-1.8.5.tgz
drwxr-xr-x.  9 root    root         4096 Mar 17 22:10 vmware-tools-distrib
drwxr-xr-x. 26 root    root         4096 Sep  2 20:02 xfsprogs-3.2.3
-rwxrw-rw-.  1 xiaobai xiaobai  22724574 Sep  8 19:50 zookeeper-3.4.9.tar.gz
[root@RedHat-BG soft]# tar -zvxf rubygems-1.8.5.tgz 
rubygems-1.8.5/
rubygems-1.8.5/.autotest
rubygems-1.8.5/.document
rubygems-1.8.5/.gemtest
rubygems-1.8.5/bin/
rubygems-1.8.5/ci_build.sh
rubygems-1.8.5/cruise_config.rb
rubygems-1.8.5/hide_lib_for_update/
rubygems-1.8.5/History.txt
rubygems-1.8.5/lib/
rubygems-1.8.5/LICENSE.txt
rubygems-1.8.5/Manifest.txt
rubygems-1.8.5/MIT.txt
rubygems-1.8.5/Rakefile
rubygems-1.8.5/README.rdoc
rubygems-1.8.5/setup.rb
rubygems-1.8.5/test/
rubygems-1.8.5/UPGRADING.rdoc
rubygems-1.8.5/util/
rubygems-1.8.5/util/CL2notes
rubygems-1.8.5/util/gem_prelude.rb
rubygems-1.8.5/test/rubygems/
rubygems-1.8.5/test/rubygems/bogussources.rb
rubygems-1.8.5/test/rubygems/data/
rubygems-1.8.5/test/rubygems/fake_certlib/
rubygems-1.8.5/test/rubygems/fix_openssl_warnings.rb
rubygems-1.8.5/test/rubygems/foo/
rubygems-1.8.5/test/rubygems/insure_session.rb
rubygems-1.8.5/test/rubygems/plugin/
rubygems-1.8.5/test/rubygems/private_key.pem
rubygems-1.8.5/test/rubygems/public_cert.pem
rubygems-1.8.5/test/rubygems/rubygems/
rubygems-1.8.5/test/rubygems/rubygems_plugin.rb
rubygems-1.8.5/test/rubygems/sff/
rubygems-1.8.5/test/rubygems/simple_gem.rb
rubygems-1.8.5/test/rubygems/test_config.rb
rubygems-1.8.5/test/rubygems/test_gem.rb
rubygems-1.8.5/test/rubygems/test_gem_builder.rb
rubygems-1.8.5/test/rubygems/test_gem_command.rb
rubygems-1.8.5/test/rubygems/test_gem_command_manager.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_build_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_cert_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_check_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_cleanup_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_contents_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_dependency_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_environment_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_fetch_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_generate_index_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_help_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_install_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_list_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_lock_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_outdated_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_owner_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_pristine_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_push_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_query_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_server_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_sources_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_specification_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_stale_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_uninstall_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_unpack_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_update_command.rb
rubygems-1.8.5/test/rubygems/test_gem_commands_which_command.rb
rubygems-1.8.5/test/rubygems/test_gem_config_file.rb
rubygems-1.8.5/test/rubygems/test_gem_dependency.rb
rubygems-1.8.5/test/rubygems/test_gem_dependency_installer.rb
rubygems-1.8.5/test/rubygems/test_gem_dependency_list.rb
rubygems-1.8.5/test/rubygems/test_gem_doc_manager.rb
rubygems-1.8.5/test/rubygems/test_gem_ext_configure_builder.rb
rubygems-1.8.5/test/rubygems/test_gem_ext_ext_conf_builder.rb
rubygems-1.8.5/test/rubygems/test_gem_ext_rake_builder.rb
rubygems-1.8.5/test/rubygems/test_gem_format.rb
rubygems-1.8.5/test/rubygems/test_gem_gem_path_searcher.rb
rubygems-1.8.5/test/rubygems/test_gem_gem_runner.rb
rubygems-1.8.5/test/rubygems/test_gem_gemcutter_utilities.rb
rubygems-1.8.5/test/rubygems/test_gem_indexer.rb
rubygems-1.8.5/test/rubygems/test_gem_install_update_options.rb
rubygems-1.8.5/test/rubygems/test_gem_installer.rb
rubygems-1.8.5/test/rubygems/test_gem_local_remote_options.rb
rubygems-1.8.5/test/rubygems/test_gem_package_tar_header.rb
rubygems-1.8.5/test/rubygems/test_gem_package_tar_input.rb
rubygems-1.8.5/test/rubygems/test_gem_package_tar_output.rb
rubygems-1.8.5/test/rubygems/test_gem_package_tar_reader.rb
rubygems-1.8.5/test/rubygems/test_gem_package_tar_reader_entry.rb
rubygems-1.8.5/test/rubygems/test_gem_package_tar_writer.rb
rubygems-1.8.5/test/rubygems/test_gem_package_task.rb
rubygems-1.8.5/test/rubygems/test_gem_path_support.rb
rubygems-1.8.5/test/rubygems/test_gem_platform.rb
rubygems-1.8.5/test/rubygems/test_gem_remote_fetcher.rb
rubygems-1.8.5/test/rubygems/test_gem_requirement.rb
rubygems-1.8.5/test/rubygems/test_gem_security.rb
rubygems-1.8.5/test/rubygems/test_gem_server.rb
rubygems-1.8.5/test/rubygems/test_gem_silent_ui.rb
rubygems-1.8.5/test/rubygems/test_gem_source_index.rb
rubygems-1.8.5/test/rubygems/test_gem_spec_fetcher.rb
rubygems-1.8.5/test/rubygems/test_gem_specification.rb
rubygems-1.8.5/test/rubygems/test_gem_stream_ui.rb
rubygems-1.8.5/test/rubygems/test_gem_text.rb
rubygems-1.8.5/test/rubygems/test_gem_uninstaller.rb
rubygems-1.8.5/test/rubygems/test_gem_validator.rb
rubygems-1.8.5/test/rubygems/test_gem_version.rb
rubygems-1.8.5/test/rubygems/test_gem_version_option.rb
rubygems-1.8.5/test/rubygems/test_kernel.rb
rubygems-1.8.5/test/rubygems/sff/discover.rb
rubygems-1.8.5/test/rubygems/rubygems/commands/
rubygems-1.8.5/test/rubygems/rubygems/commands/crash_command.rb
rubygems-1.8.5/test/rubygems/plugin/exception/
rubygems-1.8.5/test/rubygems/plugin/load/
rubygems-1.8.5/test/rubygems/plugin/standarderror/
rubygems-1.8.5/test/rubygems/plugin/standarderror/rubygems_plugin.rb
rubygems-1.8.5/test/rubygems/plugin/load/rubygems_plugin.rb
rubygems-1.8.5/test/rubygems/plugin/exception/rubygems_plugin.rb
rubygems-1.8.5/test/rubygems/foo/discover.rb
rubygems-1.8.5/test/rubygems/fake_certlib/openssl.rb
rubygems-1.8.5/test/rubygems/data/gem-private_key.pem
rubygems-1.8.5/test/rubygems/data/gem-public_cert.pem
rubygems-1.8.5/lib/gauntlet_rubygems.rb
rubygems-1.8.5/lib/rbconfig/
rubygems-1.8.5/lib/rubygems/
rubygems-1.8.5/lib/rubygems.rb
rubygems-1.8.5/lib/ubygems.rb
rubygems-1.8.5/lib/rubygems/builder.rb
rubygems-1.8.5/lib/rubygems/command.rb
rubygems-1.8.5/lib/rubygems/command_manager.rb
rubygems-1.8.5/lib/rubygems/commands/
rubygems-1.8.5/lib/rubygems/config_file.rb
rubygems-1.8.5/lib/rubygems/custom_require.rb
rubygems-1.8.5/lib/rubygems/defaults.rb
rubygems-1.8.5/lib/rubygems/dependency.rb
rubygems-1.8.5/lib/rubygems/dependency_installer.rb
rubygems-1.8.5/lib/rubygems/dependency_list.rb
rubygems-1.8.5/lib/rubygems/deprecate.rb
rubygems-1.8.5/lib/rubygems/doc_manager.rb
rubygems-1.8.5/lib/rubygems/errors.rb
rubygems-1.8.5/lib/rubygems/exceptions.rb
rubygems-1.8.5/lib/rubygems/ext/
rubygems-1.8.5/lib/rubygems/ext.rb
rubygems-1.8.5/lib/rubygems/format.rb
rubygems-1.8.5/lib/rubygems/gem_openssl.rb
rubygems-1.8.5/lib/rubygems/gem_path_searcher.rb
rubygems-1.8.5/lib/rubygems/gem_runner.rb
rubygems-1.8.5/lib/rubygems/gemcutter_utilities.rb
rubygems-1.8.5/lib/rubygems/indexer.rb
rubygems-1.8.5/lib/rubygems/install_update_options.rb
rubygems-1.8.5/lib/rubygems/installer.rb
rubygems-1.8.5/lib/rubygems/installer_test_case.rb
rubygems-1.8.5/lib/rubygems/local_remote_options.rb
rubygems-1.8.5/lib/rubygems/mock_gem_ui.rb
rubygems-1.8.5/lib/rubygems/old_format.rb
rubygems-1.8.5/lib/rubygems/package/
rubygems-1.8.5/lib/rubygems/package.rb
rubygems-1.8.5/lib/rubygems/package_task.rb
rubygems-1.8.5/lib/rubygems/path_support.rb
rubygems-1.8.5/lib/rubygems/platform.rb
rubygems-1.8.5/lib/rubygems/remote_fetcher.rb
rubygems-1.8.5/lib/rubygems/require_paths_builder.rb
rubygems-1.8.5/lib/rubygems/requirement.rb
rubygems-1.8.5/lib/rubygems/security.rb
rubygems-1.8.5/lib/rubygems/server.rb
rubygems-1.8.5/lib/rubygems/source_index.rb
rubygems-1.8.5/lib/rubygems/spec_fetcher.rb
rubygems-1.8.5/lib/rubygems/specification.rb
rubygems-1.8.5/lib/rubygems/test_case.rb
rubygems-1.8.5/lib/rubygems/test_utilities.rb
rubygems-1.8.5/lib/rubygems/text.rb
rubygems-1.8.5/lib/rubygems/uninstaller.rb
rubygems-1.8.5/lib/rubygems/user_interaction.rb
rubygems-1.8.5/lib/rubygems/validator.rb
rubygems-1.8.5/lib/rubygems/version.rb
rubygems-1.8.5/lib/rubygems/version_option.rb
rubygems-1.8.5/lib/rubygems/package/f_sync_dir.rb
rubygems-1.8.5/lib/rubygems/package/tar_header.rb
rubygems-1.8.5/lib/rubygems/package/tar_input.rb
rubygems-1.8.5/lib/rubygems/package/tar_output.rb
rubygems-1.8.5/lib/rubygems/package/tar_reader/
rubygems-1.8.5/lib/rubygems/package/tar_reader.rb
rubygems-1.8.5/lib/rubygems/package/tar_test_case.rb
rubygems-1.8.5/lib/rubygems/package/tar_writer.rb
rubygems-1.8.5/lib/rubygems/package/tar_reader/entry.rb
rubygems-1.8.5/lib/rubygems/ext/builder.rb
rubygems-1.8.5/lib/rubygems/ext/configure_builder.rb
rubygems-1.8.5/lib/rubygems/ext/ext_conf_builder.rb
rubygems-1.8.5/lib/rubygems/ext/rake_builder.rb
rubygems-1.8.5/lib/rubygems/commands/build_command.rb
rubygems-1.8.5/lib/rubygems/commands/cert_command.rb
rubygems-1.8.5/lib/rubygems/commands/check_command.rb
rubygems-1.8.5/lib/rubygems/commands/cleanup_command.rb
rubygems-1.8.5/lib/rubygems/commands/contents_command.rb
rubygems-1.8.5/lib/rubygems/commands/dependency_command.rb
rubygems-1.8.5/lib/rubygems/commands/environment_command.rb
rubygems-1.8.5/lib/rubygems/commands/fetch_command.rb
rubygems-1.8.5/lib/rubygems/commands/generate_index_command.rb
rubygems-1.8.5/lib/rubygems/commands/help_command.rb
rubygems-1.8.5/lib/rubygems/commands/install_command.rb
rubygems-1.8.5/lib/rubygems/commands/list_command.rb
rubygems-1.8.5/lib/rubygems/commands/lock_command.rb
rubygems-1.8.5/lib/rubygems/commands/outdated_command.rb
rubygems-1.8.5/lib/rubygems/commands/owner_command.rb
rubygems-1.8.5/lib/rubygems/commands/pristine_command.rb
rubygems-1.8.5/lib/rubygems/commands/push_command.rb
rubygems-1.8.5/lib/rubygems/commands/query_command.rb
rubygems-1.8.5/lib/rubygems/commands/rdoc_command.rb
rubygems-1.8.5/lib/rubygems/commands/search_command.rb
rubygems-1.8.5/lib/rubygems/commands/server_command.rb
rubygems-1.8.5/lib/rubygems/commands/setup_command.rb
rubygems-1.8.5/lib/rubygems/commands/sources_command.rb
rubygems-1.8.5/lib/rubygems/commands/specification_command.rb
rubygems-1.8.5/lib/rubygems/commands/stale_command.rb
rubygems-1.8.5/lib/rubygems/commands/uninstall_command.rb
rubygems-1.8.5/lib/rubygems/commands/unpack_command.rb
rubygems-1.8.5/lib/rubygems/commands/update_command.rb
rubygems-1.8.5/lib/rubygems/commands/which_command.rb
rubygems-1.8.5/lib/rbconfig/datadir.rb
rubygems-1.8.5/hide_lib_for_update/note.txt
rubygems-1.8.5/bin/gem
rubygems-1.8.5/bin/update_rubygems
[root@RedHat-BG soft]# ll
total 303260
-rwxrw-rw-.  1 xiaobai xiaobai  54294367 Jun 25 16:27 apache-activemq-5.14.5-bin.tar.gz
-rwxrw-rw-.  1 xiaobai xiaobai   9375265 Apr 17 19:26 apache-tomcat-8.5.13.tar.gz
-rwxrw-rw-.  1 xiaobai xiaobai 185515842 Sep  8 21:41 jdk-8u144-linux-x64.tar.gz
-rwxrw-rw-.  1 xiaobai xiaobai  36644420 Sep  8 19:36 kafka_2.12-0.11.0.0.tgz
-rwxrw-rw-.  1 xiaobai xiaobai   1710169 Jul 17 18:18 redis-4.0.0.tar.gz
drwxr-xr-x.  2 root    root         4096 Sep  2 23:34 rpm_zh_CN
drwxr-xr-x.  7   12498   40000      4096 Jun  1  2011 rubygems-1.8.5
-rwxrw-rw-.  1 xiaobai xiaobai    249170 Sep 10 15:39 rubygems-1.8.5.tgz
drwxr-xr-x.  9 root    root         4096 Mar 17 22:10 vmware-tools-distrib
drwxr-xr-x. 26 root    root         4096 Sep  2 20:02 xfsprogs-3.2.3
-rwxrw-rw-.  1 xiaobai xiaobai  22724574 Sep  8 19:50 zookeeper-3.4.9.tar.gz
[root@RedHat-BG soft]# cd rubygems-1.8.5
[root@RedHat-BG rubygems-1.8.5]# ll
total 116
drwxr-xr-x. 2 12498 40000  4096 Sep 10 15:41 bin
-rwxr-xr-x. 1 12498 40000  1018 May 19  2011 ci_build.sh
-rw-r--r--. 1 12498 40000  1159 May 19  2011 cruise_config.rb
drwxr-xr-x. 2 12498 40000  4096 Sep 10 15:41 hide_lib_for_update
-rw-r--r--. 1 12498 40000 51951 Jun  1  2011 History.txt
drwxr-xr-x. 4 12498 40000  4096 Sep 10 15:41 lib
-rw-r--r--. 1 12498 40000  2460 May 19  2011 LICENSE.txt
-rw-r--r--. 1 12498 40000  6898 May 19  2011 Manifest.txt
-rw-r--r--. 1 12498 40000  1088 May 19  2011 MIT.txt
-rw-r--r--. 1 12498 40000  7629 May 20  2011 Rakefile
-rw-r--r--. 1 12498 40000  1480 May 19  2011 README.rdoc
-rw-r--r--. 1 12498 40000   890 May 26  2011 setup.rb
drwxr-xr-x. 3 12498 40000  4096 Sep 10 15:41 test
-rw-r--r--. 1 12498 40000  2198 May 19  2011 UPGRADING.rdoc
drwxr-xr-x. 2 12498 40000  4096 Jun  1  2011 util
[root@RedHat-BG rubygems-1.8.5]# ruby setup.rb 
RubyGems 1.8.5 installed


=== 1.8.4 / 2011-05-31


* 1 minor enhancement:


  * The -u option to 'update local source cache' is official deprecated.
  * Remove has_rdoc deprecations from Specification.


* 2 bug fixes:


  * Handle bad specs more gracefully.
  * Reset any Gem paths changed in the installer.




------------------------------------------------------------------------------


RubyGems installed the following executables:
/usr/bin/gem


[root@RedHat-BG rubygems-1.8.5]# gem --version
1.8.5
[root@RedHat-BG rubygems-1.8.5]# gem install  spreadsheet








Fetching: ruby-ole-1.2.12.1.gem (100%)






Fetching: spreadsheet-1.1.4.gem ( 25%)












Fetching: spreadsheet-1.1.4.gem ( 51%)






Fetching: spreadsheet-1.1.4.gem (100%)
Successfully installed ruby-ole-1.2.12.1
Successfully installed spreadsheet-1.1.4
2 gems installed
ERROR:  While executing gem ... (Gem::DocumentError)
    ERROR: RDoc documentation generator not installed: no such file to load -- rdoc/rdoc
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# 
[root@RedHat-BG rubygems-1.8.5]# gem install  pry



再次执行集群搭建,提示缺少ruby,卸载当前所有ruby相关,触类旁通吧:

rpm -qa|grep ruby|xargs rpm -e --allmatches --nodeps

whereis ruby|xargs rm -fr

注意有时复制命令出错是因为复制的"--"出现问题,手动修改为两个杠线

--

完全卸载后重装:

执行以下命令

tar xzvf ruby-2.2.0.tar.gz cd ruby-2.2.0 ./configure –prefix=/usr/local/ruby make && make instal -prefix是将ruby安装到指定目录,安装的时候开始没有使用root用户安装,出现问题,于是切换到root用户执行 make && make install,完成。

安装ruby 1.9.3p551版本,并先创建上面的文件夹,亲爱的。

设置PATH路径,把自己安装的ruby放在系统PATH前面,避免调用操作系统自带的ruby  
export PATH=/usr/local/ruby/bin:$PATH


查看:

[root@RedHat-BG ruby]# vim /etc/profile
[root@RedHat-BG ruby]# source /etc/profile
[root@RedHat-BG ruby]# ruby -v
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]


集群命令仍然不成功,提示安装rubygems:

tar xzvf rubygems-1.8.5.tgz cd rubygems-1.8.5/ ruby setup.rb gem --version
     **安装三个包

gem install  spreadsheet

gem install  pry

gem install rest-client

安装gem的问题:

 

RubyGems

 185人阅读 评论(0) 收藏 举报 RedHat6.5虚拟机架设Redis和Kafka伪集群 分类:

ruby官方下载安装最新ruby .

Ruby1.9.1 以后的版本自带RubyGems,直接在CMD窗口下输入指令 gem update --system 升级到最新版即可

升级出现以下情况:

While executing gem ... (Gem::RemoteFetcher::FetchError)


Rubygems官方网站被Wall了,导致在线安装软件gem包的时候无法顺利进行,往往需要借助VPN才能成功安装,所以带来了很大的不便。

解决方法:更换为国内源.

1. http://ruby.taobao.org/

2. https://gems.ruby-china.org

gem source   查看源列表

更换源命令:gem source -a http://ruby.taobao.org

删除源命令:gem source -r https://rubygems.org/ 

更新源命令:gem source -u 

若报错Error fetching url地址 SSL_connect 则将https该为http

更新了gem:


------------------------------------------------------------------------------


RubyGems installed the following executables:
/usr/local/ruby/bin/gem


Ruby Interactive (ri) documentation was installed. ri is kind of like man 
pages for ruby libraries. You may access it like this:
  ri Classname
  ri Classname.class_method
  ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.


RubyGems system software updated
[root@RedHat-BG rubygems-1.8.5]# gem -v
/usr/local/ruby/lib/ruby/1.9.1/yaml.rb:84:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
2.6.13
[root@RedHat-BG rubygems-1.8.5]# cd /usr/local/bin
[root@RedHat-BG bin]# redis-trib.rb  create  --replicas  1 192.168.43.105:7001  192.168.43.105:7002 192.168.43.105:7003 192.168.43.105:7004 192.168.43.105:7005 192.168.43.105:7006
/usr/local/ruby/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError)
from /usr/local/ruby/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/bin/redis-trib.rb:25:in `<main>'
[root@RedHat-BG bin]# redis-trib.rb  create  --replicas  1 192.168.43.105:7001  192.168.43.105:7002 192.168.43.105:7003 192.168.43.105:7004 192.168.43.105:7005 192.168.43.105:7006^C
[root@RedHat-BG bin]# gem install redis
/usr/local/ruby/lib/ruby/1.9.1/yaml.rb:84:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
Fetching: redis-4.0.0.gem (100%)
ERROR:  Error installing redis:
redis requires Ruby version >= 2.2.2.


 

执行redis-trib.rb时遇到的问题

 7365人阅读 评论(1) 收藏 举报

执行redis-trib.rb时遇到的问题

redis-trib.rb是Redis Cluster的一个常用工具。下面记录了执行此命令时遇到的一系列错误。

redis-trib.rb create --replicas 1  127.0.0.1:7379 127.0.0.1:7380 127.0.0.1:7381 127.0.0.1:7382 127.0.0.1:7383 127.0.0.1:7384 /usr/bin/env: ruby: 没有那个文件或目录

看来是ruby没有安装,于是执行:

yum install -y ruby//安装ruby redis-trib.rb create --replicas 1  127.0.0.1:7379 127.0.0.1:7380 127.0.0.1:7381 127.0.0.1:7382 127.0.0.1:7383 127.0.0.1:7384 redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)         from src/redis-trib.rb:24

ruby安装成功,但是rubygem没有安装,所以导致了上述错误,于是继续:

yum install -y rubygems//安装rubygem redis-trib.rb create --replicas 1  127.0.0.1:7379 127.0.0.1:7380 127.0.0.1:7381 127.0.0.1:7382 127.0.0.1:7383 127.0.0.1:7384 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)         from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'         from src/redis-trib.rb:25

rubygem安装成功,但是新的错误又出现了。google了一下,发现是ruby版本太低了。yum安装的版本是1.8.7,但是redis需要的是1.9.3或者更高,于是升级ruby版本到1.9.3.

curl -L get.rvm.io | bash -s stable source /etc/profile.d/rvm.sh//安装rvm rvm install 1.9.3//安装ruby1.9.3 rvm use 1.9.3 --default//设置ruby1.9.3为默认的ruby,因为还安装有1.8.3 gem install redis ERROR:  Could not find a valid gem 'redis' (>= 0), here is why:           Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Connection timed out - connect(2) (https://api.rubygems.org/latest_specs.4.8.gz) ERROR:  Possible alternatives: redis

又遇到新的错误了,看来是连接gem源出错了,于是增加新的gem源:

gem sources -a http://ruby.taobao.org///添加淘宝的gem源

然后”gem install redis“执行成功,之后的”redis-trib.rb create ......“也ok了。

BTW:其实ruby1.8.7也支持redis-trib.rb,也就是说在ruby1.8.7上执行”redis-trib.rb create ......“时出现的错误是由于没有安装针对redis的gem包,所以只要成功执行”gem install redis"即可。不过不建议使用ruby1.8.7,因为这个版本有点老了,使用rvm安装ruby1.8.7时,提示对此版本已经不提供支持了。

那么大哥我的redis-4.0.0有点太高了。ruby好不容易安装上1.9.3我是不会卸载重装了,决定降低redis版本到3.0


删除redis:

删除/usr/local/lib 目录下与redis 相关的命令

也就是你安装在/usr/local/redis/bin中生成的那些redis相关可执行文件

重装3.0.0:


PREFIX=/usr/local/redis make

PREFIX=/usr/local/redis make install


然后/usr/local/redis/bin中又会生成那些redis命令

尝试启动redis-server成功


原来配置集群的那些配置文件不变,尝试每个启动

启动失败:

[root@RedHat-BG bin]# ./redis-server ../redis-cluster/7002/redis.conf


*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 88
>>> 'protected-mode no'
Bad directive or wrong number of arguments


比较了3.0.0版本的配置文件,发现没有这个protected-mode配置,其他基本一样,于是把每个配置文件中该配置去掉


然而最终太多不同,还是挨个拷贝的3.0.0版本配置文件改的,启动,然后gem install redis时仍然提示需要ruby 2.2.2以上版本,于是

一整天白折腾了


删除ruby。。。。

重装2.2.2,按照配置安装位置,make,make install,配置ruby的path路径依次操作,非常顺利,可能此前缺失的一些lib在重启虚拟机后生效了

查看ruby 版本:

[root@RedHat-BG ruby-2.2.2]# ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]


安装gem更新源:

[root@RedHat-BG ruby-2.2.2]# gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem source -a https://gems.ruby-china.org
source https://gems.ruby-china.org already present in the cache
[root@RedHat-BG ruby-2.2.2]# gem source -r https://rubygems.org/ 
source https://rubygems.org/ not present in cache
[root@RedHat-BG ruby-2.2.2]# gem source -u
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ENETUNREACH: Network is unreachable - connect(2) for "rubygems.org" port 80 (http://rubygems.org/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem install redis
ERROR:  Could not find a valid gem 'redis' (>= 0), here is why:
          Unable to download data from http://rubygems.org/ - Errno::ENETUNREACH: Network is unreachable - connect(2) for "rubygems.org" port 80 (http://rubygems.org/specs.4.8.gz)
          Unable to download data from https://gems.ruby-china.org - no such name (https://gems.ruby-china.org/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem source -r http://rubygems.org/ 
http://rubygems.org/ removed from sources
[root@RedHat-BG ruby-2.2.2]# gem source -a http://gems.ruby-china.org
Error fetching http://gems.ruby-china.org:
bad response Bad Request 400 (http://gems-ruby-china.b0.aicdn.com/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem source -a https://gems.ruby-china.org
source https://gems.ruby-china.org already present in the cache
[root@RedHat-BG ruby-2.2.2]# gem source -u
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem source -a http://ruby.taobao.org
Error fetching http://ruby.taobao.org:
bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
[root@RedHat-BG ruby-2.2.2]# gem source -a https://ruby.taobao.org
https://ruby.taobao.org added to sources
[root@RedHat-BG ruby-2.2.2]# gem source -r https://gems.ruby-china.org
https://gems.ruby-china.org removed from sources
[root@RedHat-BG ruby-2.2.2]# gem source -u
source cache successfully updated
[root@RedHat-BG ruby-2.2.2]# gem update --system
Updating rubygems-update
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/quick/Marshal.4.8/rubygems-update-2.6.13.gemspec.rz)
[root@RedHat-BG ruby-2.2.2]# gem install redis
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/quick/Marshal.4.8/redis-4.0.0.gemspec.rz)
[root@RedHat-BG ruby-2.2.2]# gem source -u
source cache successfully updated
[root@RedHat-BG ruby-2.2.2]# gem update --system
Updating rubygems-update
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure (https://gems-ruby-china.b0.aicdn.com/quick/Marshal.4.8/rubygems-update-2.6.13.gemspec.rz)