当前位置: 首页 > ai >正文

redis的AOF恢复数据

  1. 启用AOF
  2. 使用AOF文件恢复数据
     

步骤一:启用AOF

127.0.0.1:6379> config set appendonly yes
OK
127.0.0.1:6379> CONFIG GET appendonly
1) "appendonly"
2) "yes"
127.0.0.1:6379> CONFIG rewrite
OK
[root@redis170 ~]# ls /var/lib/redis/
appendonly.aof  dump.rdb
[root@redis170 ~]# wc -l  /var/lib/redis/appendonly.aof
1 /var/lib/redis/appendonly.aof
[root@redis170 ~]# !redis
redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> mset x 1 y 2 c 3
OK
127.0.0.1:6379> exit
[root@redis170 ~]# wc -l  /var/lib/redis/appendonly.aof
21 /var/lib/redis/appendonly.aof

步骤二:使用AOF文件恢复数据

1)备份aof文件
redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> CONFIG GET appendonly
1) "appendonly"
2) "no"
127.0.0.1:6379> CONFIG set appendonly yes
OK
127.0.0.1:6379> exit
[root@redis170 ~]# ll /var/lib/redis/
总用量 8
-rw-r--r-- 1 redis redis 92 5月  24 11:35 appendonly.aof
-rw-r--r-- 1 redis redis 92 5月  24 11:34 dump.rdb
127.0.0.1:6379> mset x 1 y 2 z 3
OK
127.0.0.1:6379> keys *
1) "x"
2) "z"
3) "y"
127.0.0.1:6379> exit
[root@redis170 ~]# cp /var/lib/redis/appendonly.aof  /opt/
2)删除数据
redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> keys *
1) "x"
2) "z"
3) "y"
127.0.0.1:6379> flushall
OK3)恢复数据[root@redis170 ~]# cp /opt/appendonly.aof  /var/lib/redis/
cp:是否覆盖'/var/lib/redis/appendonly.aof'? y
[root@redis170 ~]# systemctl start redis
[root@redis170 ~]# !redis
redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> keys *
1) "z"
2) "y"
3) "x"

http://www.xdnf.cn/news/8614.html

相关文章:

  • CMake基础:CMakeLists.txt 文件结构和语法
  • github公开项目爬取
  • SMT贴片机操作核心步骤精要
  • 在kali中搞个jdk1.8.,又不破坏环境
  • Python猜拳“小”游戏
  • 动态IP:像变色龙一样自由切换网络身份
  • 【编程语言】【C语言】一篇文件构建C语言知识体系
  • 神经算子与FNO技术详解
  • 几种环境下的Postgres数据库安装
  • docker commit除了提交容器成镜像,还能搞什么之修改cmd命令
  • 全面指南:使用Node.js和Python连接与操作MongoDB
  • 汉字不仅是一种语言 还是当作艺术形式来展现
  • 基于Springboot + vue3实现的中国戏曲文化传播系统
  • Linux环境变量与地址空间
  • 冰箱热交换的原理以及如何加氟
  • 超越OpenAI CodeX的软件工程智能体:Jules
  • Axure元件动作六:设置图片
  • 高分辨率北半球多年冻土数据集(2000-2016)
  • 科学计算中的深度学习模型精解:CNN、U-Net 和 Diffusion Models
  • 【KWDB 创作者计划】KWDB单机性能测试:从零开始的详细教程
  • 前端项目部署 打包上线
  • 人脸美颜磨皮祛痘1:数据集说明(含下载链接)
  • LangGraph:人工干预与自动化结合
  • 使用workvisual对库卡机器人进行程序备份
  • 86. Java 数字和字符串 - 数字
  • Doris ClickHouse Greenplum 对比
  • 6.3.2图的深度优先遍历
  • 跨模态行人检索方法综述(上)
  • 使用YouDDNS-Docker为飞牛NAS配置YouDDNS动态域名解析
  • 如何选用正确的html元素