一、安装包下载
redis安装包
http://cocobabi.vip/app/redis-3.2.12-2.el7.x86_64.rpm
二、安装
1、将文件放到/opt目录下
2、进入/opt目录# cd /opt
3、先执行依赖安装命令,再执行redis安装命令
[root@iZuf61gy3n1d12woog919aZ app]# rpm -ivh jemalloc-3.6.0-1.el7.x86_64.rpm
warning: jemalloc-3.6.0-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:jemalloc-3.6.0-1.el7 ################################# [100%]
[root@iZuf61gy3n1d12woog919aZ app]# rpm -ivh redis-3.2.12-2.el7.x86_64.rpm
warning: redis-3.2.12-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:redis-3.2.12-2.el7 ################################# [100%]
4、启动redis
[root@iZuf61gy3n1d12woog919aZ app]# service redis start
Redirecting to /bin/systemctl start redis.service
三、配置
1、redis配置文件默认路径
/etc/redis.conf
2、修改配置文件
[root@iZuf61gy3n1d12woog919aZ html]# vim /etc/redis.conf
################################# GENERAL #####################################
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# 如果需要在其它地方远程redis,需要注释下面的一行
bind 127.0.0.1
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# 启动守护进程
daemonize yes
...
3、设置密码
// 进入redis命令行
[root@iZuf61gy3n1d12woog919aZ html]# /usr/bin/redis-cli -p 6379
// 修改密码为123456
127.0.0.1:6379> config set requirepass 123456
127.0.0.1:6379> ok
// 需要使用密码重新进入redis
[root@iZuf61gy3n1d12woog919aZ html]# /usr/bin/redis-cli -p 6379 -a 123456
// 查询密码
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "123456"