Redis事务机制+Redis持久化机制

**

Redis事务

**
Multi 开启事务
Exec
discard 回退

数据备份

save 持久化数据到内存 读取数据恢复到内存
dump.rdb

BGSAVE 后台备份
Config Get dir 数据备份,获取redis 安装目录

Redis 发布 /订阅服务

publish
subscribe redisChat
publish redisChat

subscribe xdl-chart 订阅

publish xdl-chart hello 发布

unsubscribe 指退订定的频道

ActiveMQ Apache 强劲消息总线
利用API建立连接,创建队列 通过相应API Project之间相互处理
RabbitMQ

Redis持久化机制

持久化的目的

是为了数据恢复。
redis持久化具有两种模式RDB 和AOF模式,可以分开使用也可以合并使用

RDB模式

被称为快照模式,rdb文件,save事务,将当前内存数据状态像快照模式一样保存到rdb文件中,可以配置指定的固定频率拍照,也可以使用save命令。

redis.windows.conf

#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

save 900 1   //15分钟改变一次
save 300 10//5分钟改变10次
save 60 10000//1分钟改变10000次

RDB最快一分钟备份一次,数据会丢失,恢复速度快,默认开启

AOP 模式

被称为日志模式,意思将每一次执行的的命令都保存到AOF文件中,然后将来可以根据AOF文件恢复内存中的数据。

AOF:日志文件大/回复慢,但是不会丢失数据。默认关闭

配置文件
redis.windows.conf

#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# Please check http://redis.io/topics/persistence for more information.

appendonly no

# The name of the append only file (default: "appendonly.aof")
appendfilename "appendonly.aof"

# The fsync() call tells the Operating System to actually write data on disk
# instead of waiting for more data in the output buffer. Some OS will really flush
# data on disk, some other OS will just try to do it ASAP.
#
# Redis supports three different modes:
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log. Slow, Safest.
# everysec: fsync only one time every second. Compromise.
#
# The default is "everysec", as that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
# "no" that will let the operating system flush the output buffer when
# it wants, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting),
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
#
# More details please check the following article:
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec".

# appendfsync always
appendfsync everysec
# appendfsync no

持久化打开方式
appendonly no 默认未no 可以改为yes
appendonly yes//开启 开启后redis会优先采用AOF记录
AOF持久化文件名字
appendfilename “appendonly.aof”

AOF持久化频率:

appendfsync always //一直记录

appendfsync everysec//以s为单位记录
#appendfsync no //不记录

no-appendfsync-on-rewrite no
支持压缩重写,对原有指令过滤 压缩重写

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值