sstableloader
将 <dir_path> 目录中找到的 sstable 批量加载到已配置的集群中。<dir_path> 的父目录用作目标键空间/表名称。例如,要将名为 ma-1-big-Data.db 的 sstable 加载到键空间 keyspace1/standard1 中,您需要在目录 /path/to/keyspace1/standard1/ 中拥有文件 ma-1-big-Data.db 和 ma-1-big-Index.db。该工具将创建新的 sstable,并且不会清理您复制的文件。
下面列出的几个选项无法按预期工作,在这些情况下,会针对特定用例提及解决方法。
为了避免在读取 sstable 文件时将其压缩,请将文件放置在与数据目录不同的键空间/表路径中。
在执行此工具之前,必须停止 Cassandra,否则会导致意外结果。注意:该脚本不会验证 Cassandra 是否已停止。
用法
sstableloader <options> <dir_path>
-d, --nodes <初始主机> |
必需。尝试最初连接到这些主机(逗号分隔)以获取环信息 |
-u, --username <用户名> |
Cassandra 身份验证的用户名 |
-pw, --password <密码> |
Cassandra 身份验证的密码 |
-p, --port <本机传输端口> |
用于本机连接的端口(默认值为 9042) |
-sp, --storage-port <存储端口> |
用于节点间通信的端口(默认值为 7000) |
-ssp, --ssl-storage-port <SSL 存储端口> |
用于 TLS 节点间通信的端口(默认值为 7001) |
--no-progress |
不显示进度 |
-t, --throttle <节流> |
(已弃用)节流速度(以 Mbit 为单位)(默认值为 0,表示无限制)。请使用 --throttle-mib 代替 |
--throttle-mib <throttle-mib> |
节流速度(以 MiB/s 为单位)(默认值为 0,表示无限制) |
-idct, --inter-dc-throttle <inter-dc-throttle> |
(已弃用)数据中心间节流速度(以 Mbit 为单位)(默认值为 0,表示无限制)。请使用 --inter-dc-throttle-mib 代替 |
--inter-dc-throttle-mib <inter-dc-throttle-mib> |
数据中心间节流速度(以 MiB/s 为单位)(默认值为 0,表示无限制) |
--entire-sstable-throttle-mib <throttle-mib> |
整个 SSTable 节流速度(以 MiB/s 为单位)(默认值为 0,表示无限制) |
--entire-sstable-inter-dc-throttle-mib <inter-dc-throttle-mib> |
整个 SSTable 数据中心间节流速度(以 MiB/s 为单位)(默认值为 0,表示无限制) |
-cph, --connections-per-host <connectionsPerHost> |
每个主机的并发连接数 |
-i, --ignore <节点> |
不要流式传输到此(逗号分隔)节点列表 |
-alg, --ssl-alg <算法> |
客户端 SSL:算法(默认值:SunX509) |
-ciphers, --ssl-ciphers <密码套件> |
客户端 SSL:要使用的加密套件的逗号分隔列表 |
-ks, --keystore <密钥库> |
客户端 SSL:密钥库的完整路径 |
-kspw, --keystore-password <密钥库密码> |
客户端 SSL:密钥库的密码 |
-st, --store-type <存储类型> |
客户端 SSL:存储类型 |
-ts, --truststore <信任库> |
客户端 SSL:信任库的完整路径 |
-tspw, --truststore-password <信任库密码> |
客户端 SSL:信任库的密码 |
-prtcl, --ssl-protocol <协议> |
客户端 SSL:要使用的连接协议(默认值:TLS) |
-ap, --auth-provider <身份验证提供程序> |
用于 Cassandra 身份验证的自定义 AuthProvider 类名称 |
-f, --conf-path <配置文件路径> |
用于流式传输吞吐量和客户端/服务器 SSL 的 cassandra.yaml 文件路径 |
-v, --verbose |
详细输出 |
-h, --help |
显示此帮助消息 |
您可以使用 -f 命令行选项提供 cassandra.yaml 文件来设置流式传输吞吐量以及客户端和服务器加密选项。仅从 yaml 中读取 stream_throughput_outbound、server_encryption_options 和 client_encryption_options。您可以使用相应的命令行选项覆盖从 cassandra.yaml 中读取的选项。
从快照加载 sstable
将快照 sstable 复制到可访问的目录中,然后使用 sstableloader 恢复它们。
示例
cp snapshots/1535397029191/* /path/to/keyspace1/standard1/ sstableloader --nodes 172.17.0.2 /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ Established connection to initial hosts Opening sstables and calculating sections to stream Streaming relevant part of /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ma-3-big-Data.db to [/172.17.0.2] progress: [/172.17.0.2]0:1/1 100% total: 100% 0 MB/s(avg: 1 MB/s) Summary statistics: Connections per host: : 1 Total files transferred: : 1 Total bytes transferred: : 4700000 Total duration (ms): : 4390 Average transfer rate (MB/s): : 1 Peak transfer rate (MB/s): : 1
-d 或 --nodes 选项是必需的,否则脚本将无法运行。
示例
sstableloader /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ Initial hosts must be specified (-d)
对 SSL 集群使用配置文件
如果集群中启用了 SSL 加密,请使用 --conf-path 选项与 sstableloader 一起使用,将工具指向包含相关 server_encryption_options(例如,信任库位置、算法)的 cassandra.yaml。这将比在命令行上将上面显示的各个 ssl 选项传递给 sstableloader 更好。
示例
sstableloader --nodes 172.17.0.2 --conf-path /etc/cassandra/cassandra.yaml /var/lib/cassandra/loadme/keyspace1/standard1-0974e5a0aa5811e8a0a06d2c86545d91/snapshots/ Established connection to initial hosts Opening sstables and calculating sections to stream Streaming relevant part of /var/lib/cassandra/loadme/keyspace1/standard1-0974e5a0aa5811e8a0a06d2c86545d91/mc-1-big-Data.db to [/172.17.0.2] progress: [/172.17.0.2]0:0/1 1 % total: 1% 9.165KiB/s (avg: 9.165KiB/s) progress: [/172.17.0.2]0:0/1 2 % total: 2% 5.147MiB/s (avg: 18.299KiB/s) progress: [/172.17.0.2]0:0/1 4 % total: 4% 9.751MiB/s (avg: 27.423KiB/s) progress: [/172.17.0.2]0:0/1 5 % total: 5% 8.203MiB/s (avg: 36.524KiB/s) ... progress: [/172.17.0.2]0:1/1 100% total: 100% 0.000KiB/s (avg: 480.513KiB/s) Summary statistics: Connections per host : 1 Total files transferred : 1 Total bytes transferred : 4.387MiB Total duration : 9356 ms Average transfer rate : 480.105KiB/s Peak transfer rate : 586.410KiB/s
隐藏进度输出
要隐藏进度输出和摘要统计信息(例如,如果您想在脚本中使用此工具),请使用 --no-progress 选项。
示例
sstableloader --nodes 172.17.0.2 --no-progress /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ Established connection to initial hosts Opening sstables and calculating sections to stream Streaming relevant part of /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ma-4-big-Data.db to [/172.17.0.2]
获取更多详细信息
使用 --verbose 选项将提供更多进度输出。
示例
sstableloader --nodes 172.17.0.2 --verbose /var/lib/cassandra/loadme/keyspace1/standard1-0974e5a0aa5811e8a0a06d2c86545d91/ Established connection to initial hosts Opening sstables and calculating sections to stream Streaming relevant part of /var/lib/cassandra/loadme/keyspace1/standard1-0974e5a0aa5811e8a0a06d2c86545d91/mc-1-big-Data.db to [/172.17.0.2] progress: [/172.17.0.2]0:0/1 1 % total: 1% 12.056KiB/s (avg: 12.056KiB/s) progress: [/172.17.0.2]0:0/1 2 % total: 2% 9.092MiB/s (avg: 24.081KiB/s) progress: [/172.17.0.2]0:0/1 4 % total: 4% 18.832MiB/s (avg: 36.099KiB/s) progress: [/172.17.0.2]0:0/1 5 % total: 5% 2.253MiB/s (avg: 47.882KiB/s) progress: [/172.17.0.2]0:0/1 7 % total: 7% 6.388MiB/s (avg: 59.743KiB/s) progress: [/172.17.0.2]0:0/1 8 % total: 8% 14.606MiB/s (avg: 71.635KiB/s) progress: [/172.17.0.2]0:0/1 9 % total: 9% 8.880MiB/s (avg: 83.465KiB/s) progress: [/172.17.0.2]0:0/1 11 % total: 11% 5.217MiB/s (avg: 95.176KiB/s) progress: [/172.17.0.2]0:0/1 12 % total: 12% 12.563MiB/s (avg: 106.975KiB/s) progress: [/172.17.0.2]0:0/1 14 % total: 14% 2.550MiB/s (avg: 118.322KiB/s) progress: [/172.17.0.2]0:0/1 15 % total: 15% 16.638MiB/s (avg: 130.063KiB/s) progress: [/172.17.0.2]0:0/1 17 % total: 17% 17.270MiB/s (avg: 141.793KiB/s) progress: [/172.17.0.2]0:0/1 18 % total: 18% 11.280MiB/s (avg: 153.452KiB/s) progress: [/172.17.0.2]0:0/1 19 % total: 19% 2.903MiB/s (avg: 164.603KiB/s) progress: [/172.17.0.2]0:0/1 21 % total: 21% 6.744MiB/s (avg: 176.061KiB/s) progress: [/172.17.0.2]0:0/1 22 % total: 22% 6.011MiB/s (avg: 187.440KiB/s) progress: [/172.17.0.2]0:0/1 24 % total: 24% 9.690MiB/s (avg: 198.920KiB/s) progress: [/172.17.0.2]0:0/1 25 % total: 25% 11.481MiB/s (avg: 210.412KiB/s) progress: [/172.17.0.2]0:0/1 27 % total: 27% 9.957MiB/s (avg: 221.848KiB/s) progress: [/172.17.0.2]0:0/1 28 % total: 28% 10.270MiB/s (avg: 233.265KiB/s) progress: [/172.17.0.2]0:0/1 29 % total: 29% 7.812MiB/s (avg: 244.571KiB/s) progress: [/172.17.0.2]0:0/1 31 % total: 31% 14.843MiB/s (avg: 256.021KiB/s) progress: [/172.17.0.2]0:0/1 32 % total: 32% 11.457MiB/s (avg: 267.394KiB/s) progress: [/172.17.0.2]0:0/1 34 % total: 34% 6.550MiB/s (avg: 278.536KiB/s) progress: [/172.17.0.2]0:0/1 35 % total: 35% 9.115MiB/s (avg: 289.782KiB/s) progress: [/172.17.0.2]0:0/1 37 % total: 37% 11.054MiB/s (avg: 301.064KiB/s) progress: [/172.17.0.2]0:0/1 38 % total: 38% 10.449MiB/s (avg: 312.307KiB/s) progress: [/172.17.0.2]0:0/1 39 % total: 39% 1.646MiB/s (avg: 321.665KiB/s) progress: [/172.17.0.2]0:0/1 41 % total: 41% 13.300MiB/s (avg: 332.872KiB/s) progress: [/172.17.0.2]0:0/1 42 % total: 42% 14.370MiB/s (avg: 344.082KiB/s) progress: [/172.17.0.2]0:0/1 44 % total: 44% 16.734MiB/s (avg: 355.314KiB/s) progress: [/172.17.0.2]0:0/1 45 % total: 45% 22.245MiB/s (avg: 366.592KiB/s) progress: [/172.17.0.2]0:0/1 47 % total: 47% 25.561MiB/s (avg: 377.882KiB/s) progress: [/172.17.0.2]0:0/1 48 % total: 48% 24.543MiB/s (avg: 389.155KiB/s) progress: [/172.17.0.2]0:0/1 49 % total: 49% 4.894MiB/s (avg: 399.688KiB/s) progress: [/172.17.0.2]0:0/1 51 % total: 51% 8.331MiB/s (avg: 410.559KiB/s) progress: [/172.17.0.2]0:0/1 52 % total: 52% 5.771MiB/s (avg: 421.150KiB/s) progress: [/172.17.0.2]0:0/1 54 % total: 54% 8.738MiB/s (avg: 431.983KiB/s) progress: [/172.17.0.2]0:0/1 55 % total: 55% 3.406MiB/s (avg: 441.911KiB/s) progress: [/172.17.0.2]0:0/1 56 % total: 56% 9.791MiB/s (avg: 452.730KiB/s) progress: [/172.17.0.2]0:0/1 58 % total: 58% 3.401MiB/s (avg: 462.545KiB/s) progress: [/172.17.0.2]0:0/1 59 % total: 59% 5.280MiB/s (avg: 472.840KiB/s) progress: [/172.17.0.2]0:0/1 61 % total: 61% 12.232MiB/s (avg: 483.663KiB/s) progress: [/172.17.0.2]0:0/1 62 % total: 62% 9.258MiB/s (avg: 494.325KiB/s) progress: [/172.17.0.2]0:0/1 64 % total: 64% 2.877MiB/s (avg: 503.640KiB/s) progress: [/172.17.0.2]0:0/1 65 % total: 65% 7.461MiB/s (avg: 514.078KiB/s) progress: [/172.17.0.2]0:0/1 66 % total: 66% 24.247MiB/s (avg: 525.018KiB/s) progress: [/172.17.0.2]0:0/1 68 % total: 68% 9.348MiB/s (avg: 535.563KiB/s) progress: [/172.17.0.2]0:0/1 69 % total: 69% 5.130MiB/s (avg: 545.563KiB/s) progress: [/172.17.0.2]0:0/1 71 % total: 71% 19.861MiB/s (avg: 556.392KiB/s) progress: [/172.17.0.2]0:0/1 72 % total: 72% 15.501MiB/s (avg: 567.122KiB/s) progress: [/172.17.0.2]0:0/1 74 % total: 74% 5.031MiB/s (avg: 576.996KiB/s) progress: [/172.17.0.2]0:0/1 75 % total: 75% 22.771MiB/s (avg: 587.813KiB/s) progress: [/172.17.0.2]0:0/1 76 % total: 76% 22.780MiB/s (avg: 598.619KiB/s) progress: [/172.17.0.2]0:0/1 78 % total: 78% 20.684MiB/s (avg: 609.386KiB/s) progress: [/172.17.0.2]0:0/1 79 % total: 79% 22.920MiB/s (avg: 620.173KiB/s) progress: [/172.17.0.2]0:0/1 81 % total: 81% 7.458MiB/s (avg: 630.333KiB/s) progress: [/172.17.0.2]0:0/1 82 % total: 82% 22.993MiB/s (avg: 641.090KiB/s) progress: [/172.17.0.2]0:0/1 84 % total: 84% 21.392MiB/s (avg: 651.814KiB/s) progress: [/172.17.0.2]0:0/1 85 % total: 85% 7.732MiB/s (avg: 661.938KiB/s) progress: [/172.17.0.2]0:0/1 86 % total: 86% 3.476MiB/s (avg: 670.892KiB/s) progress: [/172.17.0.2]0:0/1 88 % total: 88% 19.889MiB/s (avg: 681.521KiB/s) progress: [/172.17.0.2]0:0/1 89 % total: 89% 21.077MiB/s (avg: 692.162KiB/s) progress: [/172.17.0.2]0:0/1 91 % total: 91% 24.062MiB/s (avg: 702.835KiB/s) progress: [/172.17.0.2]0:0/1 92 % total: 92% 19.798MiB/s (avg: 713.431KiB/s) progress: [/172.17.0.2]0:0/1 94 % total: 94% 17.591MiB/s (avg: 723.965KiB/s) progress: [/172.17.0.2]0:0/1 95 % total: 95% 13.725MiB/s (avg: 734.361KiB/s) progress: [/172.17.0.2]0:0/1 96 % total: 96% 16.737MiB/s (avg: 744.846KiB/s) progress: [/172.17.0.2]0:0/1 98 % total: 98% 22.701MiB/s (avg: 755.443KiB/s) progress: [/172.17.0.2]0:0/1 99 % total: 99% 18.718MiB/s (avg: 765.954KiB/s) progress: [/172.17.0.2]0:1/1 100% total: 100% 6.613MiB/s (avg: 767.802KiB/s) progress: [/172.17.0.2]0:1/1 100% total: 100% 0.000KiB/s (avg: 670.295KiB/s) Summary statistics: Connections per host : 1 Total files transferred : 1 Total bytes transferred : 4.387MiB Total duration : 6706 ms Average transfer rate : 669.835KiB/s Peak transfer rate : 767.802KiB/s
节流加载
为了防止表加载器过载系统资源,您可以使用 --throttle 选项对进程进行节流。默认值为无限制(无节流)。节流单位为兆位。请注意,以下示例中的总持续时间会增加。
示例
sstableloader --nodes 172.17.0.2 --throttle 1 /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ Established connection to initial hosts Opening sstables and calculating sections to stream Streaming relevant part of /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ma-6-big-Data.db to [/172.17.0.2] progress: [/172.17.0.2]0:1/1 100% total: 100% 0 MB/s(avg: 0 MB/s) Summary statistics: Connections per host: : 1 Total files transferred: : 1 Total bytes transferred: : 4595705 Total duration (ms): : 37634 Average transfer rate (MB/s): : 0 Peak transfer rate (MB/s): : 0
加快加载速度
要加快加载过程,可以增加每个主机的连接数。
示例
sstableloader --nodes 172.17.0.2 --connections-per-host 100 /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ Established connection to initial hosts Opening sstables and calculating sections to stream Streaming relevant part of /var/lib/cassandra/loadme/keyspace1/standard1-f8a4fa30aa2a11e8af27091830ac5256/ma-9-big-Data.db to [/172.17.0.2] progress: [/172.17.0.2]0:1/1 100% total: 100% 0 MB/s(avg: 1 MB/s) Summary statistics: Connections per host: : 100 Total files transferred: : 1 Total bytes transferred: : 4595705 Total duration (ms): : 3486 Average transfer rate (MB/s): : 1 Peak transfer rate (MB/s): : 1
这个小型数据集不会从增加每个主机的连接数中获得太多好处,但请注意,在本示例中,总持续时间已减少。