# redis7.0.5安装

##### 官网

https://redis.io/download/

```
#在线下载
wget http://download.redis.io/releases/redis-7.0.5.tar.gz
```

### 上传到服务器并解压压缩包

```
cd /usr/local
tar -zxvf  redis-7.0.5.tar.gz
```

### 进入redis目录并编译安装

```
cd /usr/local/redis-7.0.5
make && make install
```

### 拷贝redis.conf至/etc/redis.conf

```
cp redis.conf /etc/redis.conf
```

### 设置redis.conf

```
vim /etc/redis.conf

daemonize yes        #配置redis为后台启动
bind 0.0.0.0         #配置可以对外访问redis-server
requirepass 123456   #配置连接密码

```

###  启动redis

```
cd /usr/local/bin/
./redis-server /etc/redis.conf
```

###  测试链接

```
[root@oracle /]# redis-cli -h 192.168.0.1 -p 6379
192.168.0.1:6379> keys *
(error) NOAUTH Authentication required.
192.168.0.1:6379> auth   123456   #配置连接密码
OK
192.168.0.1:6379> keys *
(empty array)

```

### 设置服务自启

```
vim /etc/rc.local

在下方加入启动命令
#redis自启
/usr/local/bin/redis-server /etc/redis.conf

```

### 卸载redis

```
#删除安装目录
rm -rf /usr/local/redis-7.0.5
#删除所有redis相关命令脚本
rm -rf /usr/bin/redis-*
#删除/etc/redis.conf
rm -f /etc/redis.conf
#移除/etc/rc.local自启 参考第8点
vim /etc/rc.local

```











