centos7使用yum安装Redis

1、centos7使用yum安装Redis时,可能会有安装源的问题出现。安装epel源,CentOS默认的安装源在官方的centos.org上,而redis在第三方的yum源里,因此无法安装。这就是我们常常在yum源里找不到各种软件的原因,还需要自己去wget,然后configure,make,make install,这个过程太痛苦了,并且卸载软件的时候还容易出错。
2、非官方的yum推荐用fedora的epel仓库。
yum添加epel源的命令为:yum install epel-release然后回车。

[root@hadoop0 ~]# yum install epel-release

3、yum repolist查看

[root@hadoop0 ~]# yum repolist
Loaded plugins: fastestmirror
epel/x86_64/metalink                                                                                                          | 6.8 kB  00:00:00     
epel                                                                                                                          | 4.7 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                                                                   | 266 kB  00:00:01     
(2/3): epel/x86_64/updateinfo                                                                                                 | 898 kB  00:00:30     
(3/3): epel/x86_64/primary_db                                                                                                 | 6.2 MB  00:01:18     
Loading mirror speeds from cached hostfile
 * base: mirrors.nju.edu.cn
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.nju.edu.cn
repo id                                                 repo name                                                                              status
base/7/x86_64                                           CentOS-7 - Base                                                                         9,591
epel/x86_64                                             Extra Packages for Enterprise Linux 7 - x86_64                                         12,353
extras/7/x86_64                                         CentOS-7 - Extras                                                                         390
updates/7/x86_64                                        CentOS-7 - Updates                                                                      1,941
repolist: 24,275

4、执行安装redis命令:yum install redis即可

[root@hadoop0 ~]# yum install redis

5、查看Redis安装了哪些文件

find / -name "redis*"
[root@hadoop0 ~]# find / -name "redis*" 
/etc/selinux/targeted/active/modules/100/redis
/etc/systemd/system/redis-sentinel.service.d
/etc/systemd/system/redis.service.d
/etc/logrotate.d/redis
/etc/redis-sentinel.conf
/etc/redis.conf
/var/lib/redis
/var/log/redis
/usr/bin/redis-benchmark
/usr/bin/redis-check-aof
/usr/bin/redis-check-rdb
/usr/bin/redis-sentinel
/usr/bin/redis-server
/usr/bin/redis-cli
/usr/lib/systemd/system/redis-sentinel.service
/usr/lib/systemd/system/redis.service
/usr/share/doc/redis-3.2.10
/usr/share/licenses/redis-3.2.10
/usr/share/man/man1/redis-benchmark.1.gz
/usr/share/man/man1/redis-check-aof.1.gz
/usr/share/man/man1/redis-check-rdb.1.gz
/usr/share/man/man1/redis-cli.1.gz
/usr/share/man/man1/redis-sentinel.1.gz
/usr/share/man/man1/redis-server.1.gz
/usr/share/man/man5/redis-sentinel.conf.5.gz
/usr/share/man/man5/redis.conf.5.gz
/usr/libexec/redis-shutdown

6、启动Redis服务:使用service redis start命令启动redis服务端。

[root@hadoop0 ~]# service redis start
Redirecting to /bin/systemctl start  redis.service

启动失败,可能会提示如下错误信息:Can't open the log file: Permission denied。发现是权限不够的问题,输入ls -l /var/log/redis/redis-server.log命令查看权限,发现结果为:-rw-r--r-- 1 root root ..... ,解决办法:chmod 777 /var/log/redis/redis-server.log,再重启Redis输入service redis start命令,提示启动成功。

7、打开Redis客户端,使用命令:redis-cli 即可打开客户端

[root@hadoop0 ~]# redis-cli
127.0.0.1:6379> 

8、远程访问,允许远程访问redis,除需要开放服务器端口号6379,还需将配置文件中的bind 127.0.0.1注释掉。

[root@hadoop2 ~]# vi /etc/redis.conf
# bind 127.0.0.1 ::1
bind 192.168.146.31

9、重启

你可能感兴趣的:(hadoop)