# 17.2 配置

Redis的配置信息在/etc/redis/redis.conf下。 查看

```
sudo vi /etc/redis/redis.conf
```

## 核心配置选项

绑定ip：如果需要远程访问，可将此⾏注释，或绑定⼀个真实ip

```
bind 127.0.0.1
```

端⼝，默认为6379

```
port 6379
```

是否以守护进程运⾏ a) 如果以守护进程运⾏，则不会在命令⾏阻塞，类似于服务 b) 如果以⾮守护进程运⾏，则当前终端被阻塞 c) 设置为yes表示守护进程，设置为no表示⾮守护进程 d) 推荐设置为yes

```
daemonize yes
```

数据⽂件

```
dbfilename dump.rdb
```

数据⽂件存储路径

```
dir /var/lib/redis
```

⽇志⽂件

```
logfile /var/log/redis/redis-server.log
```

数据库，默认有16个

```
database 16
```

主从复制，类似于双机备份。

```
slaveof
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.clay-wangzhi.com/17-redis/17.2-pei-zhi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
