您的位置:首页 > 数据库 > Redis

redis重启之后丢失数据

2017-02-22 14:54 162 查看
小狼在redis重启之后丢失了数据库中全部的数据,很是头疼,怎么才能让他不丢失数据,成了小狼必须要解决的重中之重

第一步

       在redis配置文件中添加如下配置

redis 127.0.0.1:6380> config get*append*
1) "appendonly"
2) "yes"
3) "no-appendfsync-on-rewrite"
4) "no"
5) "appendfsync"
6) "everysec"
redis 127.0.0.1:6380> config get*aof*
1) "auto-aof-rewrite-percentage"
2) "100"
3) "auto-aof-rewrite-min-size"
4) "67108864"

第二步
 在redis配置文件中添加如下配置,重启服务

1)
# save ""
save 900 1
save 300 10
save 60 10000

2)
# The filename where to dump the DB
dbfilename dump.rdb

3)
# Note that you must specify a directoryhere, not a file name.
dir ./

第三步  
编辑/etc/sysctl.conf ,改vm.overcommit_memory=1,然后sysctl -p 使配置文件生效

成功解决问题,点个赞
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: