最近小編在玩redis其中遇到很多坑,其中遇到的一個坑就是剛開始學習的時候-當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 使配置文件生效
愛動手 的你可以動手試試