parent
88df70bd80
commit
3029619552
15 changed files with 287 additions and 204 deletions
After Width: | Height: | Size: 15 KiB |
@ -1,65 +1,8 @@ |
||||
--- |
||||
outline: deep |
||||
--- |
||||
# transform 样例 |
||||
|
||||
## 阿里云兼容 |
||||
# 什么是 function |
||||
|
||||
```lua |
||||
-- Aliyun Redis 4.0: skip OPINFO command |
||||
function transform(id, is_base, group, cmd_name, keys, slots, db_id, timestamp_ms) |
||||
if cmd_name == "OPINFO" then |
||||
return 1, db_id -- disallow |
||||
else |
||||
return 0, db_id -- allow |
||||
end |
||||
end |
||||
``` |
||||
|
||||
## AWS 兼容 |
||||
|
||||
```lua |
||||
-- ElastiCache: skip REPLCONF command |
||||
function transform(id, is_base, group, cmd_name, keys, slots, db_id, timestamp_ms) |
||||
if cmd_name == "REPLCONF" then |
||||
return 1, db_id -- disallow |
||||
else |
||||
return 0, db_id -- allow |
||||
end |
||||
end |
||||
``` |
||||
|
||||
## 过滤命令 |
||||
|
||||
### 过滤所有 lua 脚本 |
||||
|
||||
``` |
||||
-- skip all scripts included LUA scripts and Redis Functions. |
||||
function filter(id, is_base, group, cmd_name, keys, slots, db_id, timestamp_ms) |
||||
if group == "SCRIPTING" then |
||||
return 1, db_id -- disallow |
||||
else |
||||
return 0, db_id -- allow |
||||
end |
||||
end |
||||
``` |
||||
|
||||
## key 操作 |
||||
|
||||
### 按照前缀过滤 key |
||||
|
||||
``` |
||||
-- skip keys prefixed with ABC |
||||
function filter(id, is_base, group, cmd_name, keys, slots, db_id, timestamp_ms) |
||||
if #keys ~= 1 then |
||||
return 0, db_id -- allow |
||||
end |
||||
|
||||
if string.sub(keys[1], 0, 3) == "ABC" then |
||||
return 1, db_id -- disallow |
||||
end |
||||
|
||||
return 0, db_id -- allow |
||||
end |
||||
``` |
||||
|
||||
|
Before Width: | Height: | Size: 1.5 MiB |
@ -0,0 +1,43 @@ |
||||
--- |
||||
outline: deep |
||||
--- |
||||
|
||||
# 什么是 RedisShake |
||||
|
||||
RedisShake 是一个用于处理和迁移 Redis 数据的工具,它提供以下特性: |
||||
|
||||
1. **Redis 兼容性**:RedisShake 兼容从 2.8 到 7.2 的 Redis 版本,并支持各种部署方式,包括单机,主从,哨兵和集群。 |
||||
2. **云服务兼容性**:RedisShake 与主流云服务提供商提供的流行 Redis-like 数据库无缝工作,包括但不限于: |
||||
- [阿里云-云数据库 Redis 版](https://www.aliyun.com/product/redis) |
||||
- [阿里云-云原生内存数据库Tair](https://www.aliyun.com/product/apsaradb/kvstore/tair) |
||||
- [AWS - ElastiCache](https://aws.amazon.com/elasticache/) |
||||
- [AWS - MemoryDB](https://aws.amazon.com/memorydb/) |
||||
3. **Module 兼容**:RedisShake |
||||
与 [TairString](https://github.com/tair-opensource/TairString),[TairZSet](https://github.com/tair-opensource/TairZset) |
||||
和 [TairHash](https://github.com/tair-opensource/TairHash) 模块兼容。 |
||||
4. **多种导出模式**:RedisShake 支持 PSync,RDB 和 Scan 导出模式。 |
||||
5. **数据处理**:RedisShake 通过自定义脚本实现数据过滤和转换。 |
||||
|
||||
## 贡献 |
||||
|
||||
我们欢迎社区的贡献。对于重大变更,请先开一个 issue 来讨论你想要改变的内容。我们特别感兴趣的是: |
||||
|
||||
1. 添加对更多模块的支持 |
||||
2. 提高对 Readers 和 Writers 的支持 |
||||
3. 分享你的 Lua 脚本和最佳实践 |
||||
|
||||
## 历史 |
||||
|
||||
RedisShake 是阿里云 [Tair 团队](https://github.com/tair-opensource) |
||||
积极维护的一个项目。它的演变可以追溯到其初始版本,该版本是从 [redis-port](https://github.com/CodisLabs/redis-port) 分支出来的。 |
||||
|
||||
版本(不同版本间配置不通用): |
||||
|
||||
- [RedisShake 2.x](https://github.com/tair-opensource/RedisShake/tree/v2) 版本带来了一系列的改进和更新,提高了其整体稳定性和性能。 |
||||
- [RedisShake 3.x](https://github.com/tair-opensource/RedisShake/tree/v3) 版本是一个重要的里程碑,整个代码库被完全重写和优化,具有更好的效率和可用性。 |
||||
- [RedisShake 4.x](https://github.com/tair-opensource/RedisShake/tree/v4) 版本 |
||||
,进一步增强了 [Reader](../reader/scan_reader.md)、配置、可观察性和 [function](../function/introduction.md) 相关的特性。 |
||||
|
||||
## 许可证 |
||||
|
||||
RedisShake 在 [MIT 许可证](https://github.com/tair-opensource/RedisShake/blob/v2/license.txt) 下开源。 |
@ -0,0 +1,11 @@ |
||||
--- |
||||
outline: deep |
||||
--- |
||||
|
||||
# 迁移模式选择 |
||||
|
||||
目前 RedisShake 有三种迁移模式:`PSync`、`RDB` 和 |
||||
`SCAN`,分别对应 [`psync_reader`](../reader/psync_reader.md)、[`rdb_reader`](../reader/rdb_reader.md) |
||||
和 [`scan_reader`](../reader/scan_reader.md)。这三种模式各有适合的场景,本文根据场景特点介绍如何选择。 |
||||
|
||||
TODO |
@ -0,0 +1,13 @@ |
||||
# rdb_reader |
||||
|
||||
## 介绍 |
||||
|
||||
可以使用 `rdb_reader` 来从 RDB 文件中读取数据,然后写入目标端。常见于从备份文件中恢复数据。 |
||||
|
||||
## 配置 |
||||
|
||||
```toml |
||||
[rdb_reader] |
||||
filepath = "/tmp/dump.rdb" |
||||
``` |
||||
|
@ -0,0 +1,34 @@ |
||||
# Scan Reader |
||||
|
||||
## 介绍 |
||||
|
||||
当源端数据库不兼容 PSync 协议时,推荐使用 `scan_reader`。 |
||||
|
||||
优势:兼容性好,只要源端数据库支持 `SCAN` 与 `DUMP` 命令,就可以使用 `scan_reader`。 |
||||
|
||||
劣势: |
||||
|
||||
1. 数据一致性不如 [`sync_reader`](./sync_reader.md)。 |
||||
2. `SCAN` 命令与 `DUMP` 命令会占用源端数据库较多的 CPU 资源 |
||||
|
||||
## 配置 |
||||
|
||||
```toml |
||||
[scan_reader] |
||||
cluster = false |
||||
address = "127.0.0.1:6379" # when cluster is true, address is one of the cluster node |
||||
username = "" # keep empty if not using ACL |
||||
password = "" # keep empty if no authentication is required |
||||
tls = false |
||||
ksn = false |
||||
``` |
||||
|
||||
默认情况下,RedisShake 会使用 `SCAN` 命令来遍历一遍所有的 Key,分别使用 `DUMP` 与 `RESTORE` 命令来从源端读取 Key |
||||
的内容,并写入目标端。Redis 的 SCAN 命令只保证 SCAN 的开始与结束之前均存在的 Key 一定会被返回,但是新写入的 Key 有可能会被遗漏。 |
||||
|
||||
如果需要提高数据一致性,可以开启 `ksn` 参数,这样 RedisShake 会在 `SCAN` |
||||
之前使用 [Redis keyspace notifications](https://redis.io/docs/manual/keyspace-notifications/) |
||||
能力来订阅 Key 的变化。当 Key 发生变化时,RedisShake 会使用 `DUMP` 与 `RESTORE` 命令来从源端读取 Key 的内容,并写入目标端。 |
||||
::: warning |
||||
Redis keyspace notifications 不会感知到 `FLUSHALL` 与 `FLUSHDB` 命令,因此在使用 `ksn` 参数时,需要确保源端数据库不会执行这两个命令。 |
||||
::: |
@ -0,0 +1,23 @@ |
||||
# Sync Reader |
||||
|
||||
## 介绍 |
||||
|
||||
当源端数据库兼容 PSync 协议时,推荐使用 `sync_reader`。兼容 PSync 协议的数据库有: |
||||
|
||||
* Redis |
||||
* Tair |
||||
* ElastiCache 部分兼容 |
||||
* MemoryDB 部分兼容 |
||||
|
||||
优势:数据一致性最佳,可以实现不停机的切换 |
||||
|
||||
## 配置 |
||||
|
||||
```toml |
||||
[sync_reader] |
||||
cluster = false |
||||
address = "127.0.0.1:6379" # when cluster is true, address is one of the cluster node |
||||
username = "" # keep empty if not using ACL |
||||
password = "" # keep empty if no authentication is required |
||||
tls = false |
||||
``` |
@ -0,0 +1,16 @@ |
||||
# Redis Writer |
||||
|
||||
## 介绍 |
||||
|
||||
`redis_writer` 用于将数据写入 Redis-like 数据库。 |
||||
|
||||
## 配置 |
||||
|
||||
```toml |
||||
[redis_writer] |
||||
cluster = false |
||||
address = "127.0.0.1:6379" # when cluster is true, address is one of the cluster node |
||||
username = "" # keep empty if not using ACL |
||||
password = "" # keep empty if no authentication is required |
||||
tls = false |
||||
``` |
Loading…
Reference in new issue