6.16. 在缓存存储之间迁移数据
Data Grid 提供了一个将数据从一个缓存存储迁移到另一个缓存的工具。
6.16.1. 缓存存储 migrator 复制链接链接已复制到粘贴板!
Data Grid 提供 CLI migrate store 命令,用于为最新的数据网格缓存存储实施重新创建数据。
存储 migrator 从以前的 Data Grid 版本获取缓存存储作为源,并使用缓存存储实现作为目标。
当您运行存储 migrator 时,它会使用您使用 EmbeddedCacheManager 接口定义的缓存存储类型创建目标缓存。存储 migrator 然后将源存储中的条目加载到内存中,然后将其放入目标缓存中。
存储 migrator 还允许您将数据从一种类型的缓存存储迁移到另一种缓存存储。例如,您可以从基于 JDBC 字符串的缓存存储迁移到 SIFS 缓存存储。
存储 migrator 无法将数据从分段缓存存储迁移到:
- 非分段缓存存储。
- 分段缓存存储,它们具有不同的片段数。
6.16.2. 配置缓存存储 migrator 复制链接链接已复制到粘贴板!
使用 migrator.properties 文件配置源和目标缓存存储的属性。
流程
-
创建
migrator.properties文件。 使用
migrator.properties文件配置源和目标缓存存储的属性。将
source.前缀添加到源缓存存储的所有配置属性中。源缓存存储示例
source.type=SOFT_INDEX_FILE_STORE source.cache_name=myCache source.location=/path/to/source/sifs source.version=<version>
source.type=SOFT_INDEX_FILE_STORE source.cache_name=myCache source.location=/path/to/source/sifs source.version=<version>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 重要要从分段缓存存储迁移数据,还必须使用
source.segment_count属性配置片段数量。片段的数量必须与 Data Grid 配置中的cluster.hash.numSegments匹配。如果缓存存储的片段数量与对应缓存的片段数量不匹配,则数据网格无法从缓存存储读取数据。将
target.前缀添加到目标缓存存储的所有配置属性中。目标缓存存储示例
target.type=SINGLE_FILE_STORE target.cache_name=myCache target.location=/path/to/target/sfs.dat
target.type=SINGLE_FILE_STORE target.cache_name=myCache target.location=/path/to/target/sfs.datCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.16.2.1. 缓存存储 migrator 的配置属性 复制链接链接已复制到粘贴板!
在 StoreMigrator 属性中配置源和目标缓存存储。
| 属性 | 描述 | 必填/选填 |
|---|---|---|
|
| 指定源或目标缓存存储的缓存存储类型。
| 必填 |
| 属性 | 描述 | 值示例 | 必填/选填 |
|---|---|---|---|
|
| 要备份的缓存的名称。 |
| 必填 |
|
| 可以使用分段的目标缓存存储的片段数量。
片段数量必须与 Data Grid 配置中的 |
| 选填 |
|
| 指定自定义 marshaller 类。 | 使用自定义 marshallers 时需要此项。 |
|
| 指定允许反序列化的完全限定类名称列表。 | 选填 |
| 指定以逗号分隔的正则表达式列表,用于决定允许哪些类反序列化。 |
| 选填 |
|
指定以逗号分隔的自定义 | 选填 |
| 属性 | 描述 | 必填/选填 |
|---|---|---|
|
| 指定底层数据库的 dialect。 | 必填 |
|
|
指定源缓存存储的 marshaller 版本。
*
*
*
*
*
* | 仅用于源存储。 |
|
| 指定 JDBC 连接 URL。 | 必填 |
|
| 指定 JDBC 驱动程序的类。 | 必填 |
|
| 指定数据库用户名。 | 必填 |
|
| 指定数据库用户名的密码。 | 必填 |
|
| 禁用数据库 upsert。 | 选填 |
|
| 指定是否创建表索引。 | 选填 |
|
| 指定表名称的额外前缀。 | 选填 |
|
| 指定列名称。 | 必填 |
|
| 指定列类型。 | 必填 |
|
|
指定 | 选填 |
要从旧的 Data Grid 版本中迁移 Binary 缓存存储,请在以下属性中将 table.string view 改为 table.binary.\* :
-
source.table.binary.table_name_prefix -
source.table.binary.<id\|data\|timestamp>.name -
source.table.binary.<id\|data\|timestamp>.type
| 属性 | 描述 | 必填/选填 |
|---|---|---|
|
| 设置数据库目录。 | 必填 |
|
| 指定要使用的压缩类型。 | 选填 |
Example configuration for migrating from a RocksDB cache store.
# Example configuration for migrating from a RocksDB cache store.
source.type=ROCKSDB
source.cache_name=myCache
source.location=/path/to/rocksdb/database
source.compression=SNAPPY
| 属性 | 描述 | 必填/选填 |
|---|---|---|
|
|
设置包含缓存存储 | 必填 |
Example configuration for migrating to a Single File cache store.
# Example configuration for migrating to a Single File cache store.
target.type=SINGLE_FILE_STORE
target.cache_name=myCache
target.location=/path/to/sfs.dat
| 属性 | 描述 | value |
|---|---|---|
| 必填/选填 |
| 设置数据库目录。 |
| 必填 |
| 设置数据库索引目录。 |
Example configuration for migrating to a Soft-Index File cache store.
# Example configuration for migrating to a Soft-Index File cache store.
target.type=SOFT_INDEX_FILE_STORE
target.cache_name=myCache
target.location=path/to/sifs/database
target.location=path/to/sifs/index
6.16.3. 迁移 Data Grid 缓存存储 复制链接链接已复制到粘贴板!
运行存储 migrator 将数据从一个缓存存储迁移到另一个缓存存储。
先决条件
- 获取 Data Grid CLI。
-
创建
migrator.properties文件,以配置源和目标缓存存储。
流程
-
运行
migrate store -p /path/to/migrator.propertiesCLI 命令