Skip to content

Commit

Permalink
docs: Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
suxb201 committed Aug 25, 2023
1 parent 88df70b commit 3029619
Show file tree
Hide file tree
Showing 15 changed files with 287 additions and 204 deletions.
111 changes: 99 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,105 @@
# redis-shake
# RedisShake: Redis Data Processing & Migration Tool

[![CI](https://RedisShake/actions/workflows/ci.yml/badge.svg?branch=v3)](https://RedisShake/actions/workflows/ci.yml)
[![CI](https://github.com/tair-opensource/RedisShake/actions/workflows/ci.yml/badge.svg?event=push?branch=v4)](https://github.com/tair-opensource/RedisShake/actions/workflows/ci.yml)
[![CI](https://github.com/tair-opensource/RedisShake/actions/workflows/pages.yml/badge.svg?branch=v4)](https://github.com/tair-opensource/RedisShake/actions/workflows/pages.yml)
[![CI](https://github.com/tair-opensource/RedisShake/actions/workflows/release.yml/badge.svg?branch=v4)](https://github.com/tair-opensource/RedisShake/actions/workflows/release.yml)

- [中文文档](https://tair-opensource.github.io/RedisShake/)
- [English Document](https://tair-opensource.github.io/RedisShake/en/)
- [English Documentation](https://tair-opensource.github.io/RedisShake/en/)

redis-shake is a tool for Redis data migration and data filtering.
* 🚄 High performance
* ✅ Tested on Redis 2.8, Redis 3.0, Redis 4.0, Redis 5.0, Redis 6.0 and Redis 7.0
* 🤗 Support custom filtering rules
* 💪 Support large instance migration
* 💖 Support `restore` mode, `sync` mode and `scan` mode
* ☁️ Support Aliyun Redis and ElastiCache
## Overview

![redis-shake2.PNG](https://s2.loli.net/2022/07/10/OZrSGutknlI8XNp.png)
RedisShake is a tool designed for processing and migrating Redis data. It offers the following features:

![image.png](https://s2.loli.net/2022/06/30/vU346lVBrNofKzu.png)
1. **Redis Compatibility**: RedisShake is compatible with Redis versions ranging from 2.8 to 7.2, and supports various
deployment methods including standalone, master-slave, sentinel, and cluster.

2. **Cloud Service Compatibility**: RedisShake works seamlessly with popular Redis-like databases provided by leading
cloud service providers, including but not limited to:
- [Alibaba Cloud - ApsaraDB for Redis](https://www.alibabacloud.com/product/apsaradb-for-redis)
- [Alibaba Cloud - Tair](https://www.alibabacloud.com/product/tair)
- [AWS - ElastiCache](https://aws.amazon.com/elasticache/)
- [AWS - MemoryDB](https://aws.amazon.com/memorydb/)

3. **Module Compatibility**: RedisShake is compatible
with [TairString](https://github.com/tair-opensource/TairString), [TairZSet](https://github.com/tair-opensource/TairZset),
and [TairHash](https://github.com/tair-opensource/TairHash) modules.

4. **Multiple Export Modes**: RedisShake supports PSync, RDB, and Scan export modes.

5. **Data Processing**: RedisShake enables data filtering and transformation through custom scripts.

## Getting Started

### Installation

#### Download the Binary Package

Download the binary package directly from the [Releases](https://github.com/tair-opensource/RedisShake/releases) page.

#### Compile from Source

To compile from source, ensure that you have a Golang environment set up on your local machine:

```shell
git clone https://github.com/alibaba/RedisShake
cd RedisShake
sh build.sh
```

### Usage

Assume you have two Redis instances:

* Instance A: 127.0.0.1:6379
* Instance B: 127.0.0.1:6380

Create a new configuration file `shake.toml`:

```toml
[sync_reader]
address = "127.0.0.1:6379"

[redis_writer]
address = "127.0.0.1:6380"
```

To start RedisShake, run the following command:

```shell
./redis-shake shake.toml
```

For more detailed information, please refer to the documentation:

- [中文文档](https://tair-opensource.github.io/RedisShake/)
- [English Documentation](https://tair-opensource.github.io/RedisShake/en/)

## Contributing

We welcome contributions from the community. For significant changes, please open an issue first to discuss what you
would like to change. We are particularly interested in:

1. Adding support for more modules
2. Enhancing support for Readers and Writers
3. Sharing your Lua scripts and best practices

## History

RedisShake is a project actively maintained by the [Tair team](https://github.com/tair-opensource) at Alibaba Cloud. Its
evolution can be traced back to its initial version, which was forked
from [redis-port](https://github.com/CodisLabs/redis-port).

During its evolution:

- The [RedisShake 2.x](https://github.com/tair-opensource/RedisShake/tree/v2) version brought a series of improvements
and updates, enhancing its overall stability and performance.
- The [RedisShake 3.x](https://github.com/tair-opensource/RedisShake/tree/v3) version represented a significant
milestone where the entire codebase was completely rewritten and optimized, leading to better efficiency and
usability.
- The current version, [RedisShake 4.x](https://github.com/tair-opensource/RedisShake/tree/v4), has further enhanced
features related to readers, configuration, observability, and functions.

## License

RedisShake is open-sourced under the [MIT license](https://github.com/tair-opensource/RedisShake/blob/v2/license.txt).
42 changes: 19 additions & 23 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
head: [['link', { rel: 'icon', href: '/RedisShake/favicon.ico' }]],
base: "/RedisShake/",
title: "RedisShake",
description: "RedisShake is a tool for processing and migrating Redis data.",
Expand All @@ -21,48 +22,43 @@ export default defineConfig({
{
text: '介绍',
items: [
{ text: '什么是 RedisShake', link: '/zh/guide/getting-started' },
{ text: '什么是 RedisShake', link: '/zh/guide/introduction' },
{ text: '快速上手', link: '/zh/guide/getting-started' },
{ text: '配置', link: '/zh/guide/getting-started' },
{ text: '迁移模式选择', link: '/zh/guide/getting-started' },
{ text: '配置', link: '/zh/guide/config' },
{ text: '迁移模式选择', link: '/zh/guide/mode' },
]
},
{
text: 'Reader',
items: [
{ text: 'Sync Reader', link: '/zh/function/introduction' },
{ text: 'Scan Reader', link: '/zh/function/best_practices' },
{ text: 'RDB Reader', link: '/zh/function/best_practices' },
{ text: 'Sync Reader', link: '/zh/reader/sync_reader' },
{ text: 'Scan Reader', link: '/zh/reader/scan_reader' },
{ text: 'RDB Reader', link: '/zh/reader/rdb_reader' },
]
},
{
text: 'Writer',
items: [
{ text: 'Redis Writer', link: '/zh/function/introduction' },
{ text: 'Redis Writer', link: '/zh/writer/redis_writer' },
]
},
{
text: 'function',
items: [
{ text: '什么是 function', link: '/zh/function/introduction' },
{
text: '最佳实践',
items: [
{ text: '监控', link: '/zh/function/best_practices' },
]
}
{ text: '最佳实践', link: '/zh/function/best_practices' }
]
},
{
text: '进阶用法',
items: [
{ text: '监控', link: '/zh/function/best_practices' },
{ text: '双向同步', link: '/zh/function/best_practices' },
{ text: '容器部署', link: '/zh/function/best_practices' },
{ text: '主从实例向集群实例迁移', link: '/zh/function/best_practices' },
{ text: '大 key 重写', link: '/zh/function/best_practices' },
]
}
// {
// text: '进阶用法',
// items: [
// { text: '监控', link: '/zh/function/best_practices' },
// { text: '双向同步', link: '/zh/function/best_practices' },
// { text: '容器部署', link: '/zh/function/best_practices' },
// { text: '主从实例向集群实例迁移', link: '/zh/function/best_practices' },
// { text: '大 key 重写', link: '/zh/function/best_practices' },
// ]
// }
],
footer: {
message: 'Released under the MIT License.',
Expand Down
10 changes: 6 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ hero:
- theme: brand
text: 快速上手
link: /zh/guide/getting-started

- theme: alt
text: 什么是 RedisShake
link: /zh/guide/introduction
features:
- title: 数据迁移
details: 支持 sync、scan 和 restore 三种数据迁移模式
- title: 数据处理
- title: 数据加工
details: 支持使用 lua 脚本对数据进行过滤与修改
- title: 云数据库支持
details: 兼容主流云厂商的多种架构:主从、集群等
- title: 兼容
details: 兼容多种 Redis 部署形态,兼容主流云厂商的 Redis-like 数据库
---

Binary file added docs/src/public/favicon.ico
Binary file not shown.
59 changes: 1 addition & 58 deletions docs/src/zh/function/introduction.md
Original file line number Diff line number Diff line change
@@ -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
```

Loading

0 comments on commit 3029619

Please sign in to comment.