redis配置

daemonize yes
pidfile /home/redis/6666/pid/redis_6379.pid
port 6666
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile "log_6666.log"
databases 4
save 900 1
save 300 600
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename rdb_6666.rdb
dir ./store
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly yes
appendfilename "aof_6666.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
protected-mode no
activedefrag yes

### 如何配置 Redis 服务器设置参数 #### 使用 YAML 文件配置 Redis 并通过 Python 进行访问 当涉及到使用 YAML 文件来配置 Redis,在Python环境中可以通过`yaml`模块读取配置文件,并利用`redis-py`库建立与Redis服务器的连接。这允许开发者依据具体的应用场景灵活调整配置项,比如主机地址、端口号或是认证密码等[^1]。 ```python import yaml import redis with open('path/to/config.yaml', 'r') as file: config = yaml.safe_load(file) client = redis.Redis( host=config['redis']['host'], port=config['redis']['port'], password=config['redis'].get('password') ) ``` #### 修改 `redis.conf` 来直接配置 Redis 参数 对于更底层或者永久性的更改,则可以直接编辑Redis默认使用的配置文件——通常是位于安装目录下的`redis.conf`文件。此文件包含了众多可调选项,例如绑定IP(`bind`)、监听端口(`port`)以及持久化策略(`save`)等等[^4]。 要修改这些设置,可以按照如下命令给予适当权限后打开配置文件进行编辑: ```bash chmod 777 /etc/redis/redis.conf vim /etc/redis/redis.conf ``` 完成编辑保存退出之后记得重启Redis服务使新设定生效[^5]。 #### 考虑内存大小的选择 值得注意的是,在决定分配给Redis多少内存时应考虑其用途。如果是作为纯粹的数据缓存层,那么即使是较小规模的应用也可能只需要64MB至128MB之间的工作空间就已经足够满足需求了;当然这也取决于具体的业务逻辑复杂度及数据量级等因素[^3]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值