配置文件/etc/redis.conf

图:配置文件/etc/r、includes、General 的流程。

1. includes

图:General、NETWORK、绑定的ip 的流程。

包含其他配置文件

2. General

图:NETWORK、General、includes 的层次。

基本

1
2
后台运行:
daemonize yes

3. NETWORK

图:includes、General、NETWORK 的流程。

绑定的ip

图:General、includes、配置文件/etc/r 的流程。

1
2
3
4
如果只要本机连接则不变
bind 127.0.0.1
如果要外部连接测试则修改为公网ip
bind 公网ip
如果是腾讯云 则将bind的这行加#注释掉
1
2
3
4
#bind xxx.xxx.xxx.xxx

如果是华为云
bind 0.0.0.0
端口
1
2
port 6379
如果有云服务器有安全组设置,则需要添加响应端口的规则

4. SNAPSHOTTING

快照

5. replication

副本

6. SECRURITY

安全配置

1
2
需要密码
requirepass 123456

7 CLIENTS

客户端限制

8MEMORY management

内存管理

9 APPEND ONLY mode

数据持久方式

10 LUA SCRIPTING

服务器的脚本

11 REDIS CLUSTER

集群设置

12 SLOW LOG

慢日志

修改配置文件

1
2
3
4
5
6
7
8
如果是采用源码编译安装的redis
查找redis.conf的位置(就在是在编译源代码目录下)
find / -name "redis.conf"

将redis.conf复制到/etc下
cp /root/redis-stable/redis.conf /etc/redis.conf

如果是采用yum安装的redis则/etc/已有redis.conf

修改配置文件

1
vi /etc/redis.conf

启动服务器 加上配置文件路径的参数

1
redis-server /etc/redis.conf

连接服务器测试

1
2
3
4
5
6
7
连接
redis-cli -h 127.0.0.1 -p 6379
输入密码
auth 123456
测试
ping
服务器反馈pong

持久化方式

1
2
3
4
5
6
7
8
RDB方式
按照设定规则采用快照方式存储

AOF方式
每次修改后保存

考虑性能,就是用rdb
考虑不丢失数据,就是用aof
1
2
3
4
5
6

持久化文件在/var/lib/redis下

templ.rdb

appendonly.aof