diff --git a/curvefs/src/tools/README.md b/curvefs/src/tools/README.md new file mode 100644 index 0000000000..ca5457043e --- /dev/null +++ b/curvefs/src/tools/README.md @@ -0,0 +1,501 @@ +# curvefs_tool + +A tool for CurveFS. + +Usage: + +```shell +curvefs_tool [Command] [OPTIONS...] +``` + +When you are not sure how to use a command, --exapmle can give you an example of use: + +```shell +curvefs_tool [Command] --example +``` + +For example: + +```shell +$ curvefs_tool status-mds --example +Example : +curvefs_tool status-mds [-confPath=/etc/curvefs/tools.conf] [-rpcTimeoutMs=5000] [-rpcRetryTimes=5] [-mdsAddr=127.0.0.1:16700,127.0.0.1:26700] +``` + +In addition, this tool reads the configuration from /etc/curvefs/tools.conf, +and can be specified by "-confPath=". + +--- + +## Table of Contents + +* [version](#version) +* [status](#status) +* [list](#list) +* [build](#build) +* [umount](#umount) +* [usage](#usage) +* [delete](#delete) +* [check](#check) +* [query](#query) + +--- + +## version + +### **version** + +show the version of curvefs_tool + +Usage: + +```shell +curvefs_tool version +``` + +Output: + +```shell +1.0.0 +``` + +[TOC](#table-of-contents) + +--- + +## status + +### **status-mds** + +show the status of mds who are specified by mdsAddr in the configuration file + +Usage: + +```shell +curvefs_tool status-mds +``` + +Output: + +```shell +mds version: 1.0.0 +leader mds: 10.182.2.45:16700 +standy mds: [ ]. +offline mds: [ 10.182.2.45:27700 10.182.2.45:36700 ]. +``` + +### **status-metaserver** + +show the status of metaserver who are specified by metaserverAddr in the configuration file + +Usage: + +```shell +curvefs_tool status-metaserver +``` + +Output: + +```shell +metaserver version: 1.0.0 +online metaserver: [ 10.182.2.45:16701 10.182.2.45:36701 ]. +offline metaserver: [ 10.182.2.45:26701 ]. +``` + +### **status-etcd** + +show the status of metaserver who are specified by etcdAddr in the configuration file + +Usage: + +```shell +curvefs_tool status-etcd +``` + +Output: + +```shell +etcd version: 3.4.0 +leader etcd: 10.182.2.45:12379 +standy etcd: [ 10.182.2.45:22379 ]. +offline etcd: [ 10.182.2.45:32379 ]. +``` + +### **status-copyset** + +show the status of copyset + +Usage: + +```shell +curvefs_tool status-copyset +``` + +Output: + +```shell +all copyset is health. +copyset[4294967297]: +-info: +statusCode: TOPO_OK copysetInfo { poolId: 1 copysetId: 1 peers { id: 1 address: "10.182.2.45:36701:0" } peers { id: 2 address: "10.182.2.45:26701:0" } peers { id: 3 address: "10.182.2.45:16701:0" } epoch: 0 leaderPeer { id: 3 address: "10.182.2.45:16701:0" } } +-status: +status: COPYSET_OP_STATUS_SUCCESS copysetStatus { state: 1 peer { address: "10.182.2.45:16701:0" } leader { address: "10.182.2.45:16701:0" } readonly: false term: 2 committedIndex: 1 knownAppliedIndex: 1 pendingIndex: 0 pendingQueueSize: 0 applyingIndex: 0 firstIndex: 1 lastIndex: 1 diskIndex: 1 epoch: 0 } +status: COPYSET_OP_STATUS_SUCCESS copysetStatus { state: 4 peer { address: "10.182.2.45:26701:0" } leader { address: "10.182.2.45:16701:0" } readonly: false term: 2 committedIndex: 1 knownAppliedIndex: 1 pendingIndex: 0 pendingQueueSize: 0 applyingIndex: 0 firstIndex: 1 lastIndex: 1 diskIndex: 1 epoch: 0 } +status: COPYSET_OP_STATUS_SUCCESS copysetStatus { state: 4 peer { address: "10.182.2.45:36701:0" } leader { address: "10.182.2.45:16701:0" } readonly: false term: 2 committedIndex: 1 knownAppliedIndex: 1 pendingIndex: 0 pendingQueueSize: 0 applyingIndex: 0 firstIndex: 1 lastIndex: 1 diskIndex: 1 epoch: 0 } + +... + +``` + +[TOC](#table-of-contents) + +--- + +## list + +### **list-fs** + +list all fs in cluster + +Usage: + +```shell +curvefs_tool list-fs +``` + +Output: + +```shell +fsId: 1 +fsName: "/test" +status: INITED +rootInodeId: 1 +capacity: 18446744073709551615 +blockSize: 1 +mountNum: 1 +mountpoints: "09a03e7f5ece:/usr/local/curvefs/client/mnt" +fsType: TYPE_S3 +detail { + s3Info { + ak: "********************************" + sk: "********************************" + endpoint: "********************************" + bucketname: "********************************" + blockSize: 1048576 + chunkSize: 4194304 + } +} + +... + +``` + +### **list-coysetInfo** + +list all copysetInfo in cluster + +Usage: + +```shell +curvefs_tool list-copysetInfo +``` + +Output: + +```shell +copyset[4294967297]: +statusCode: TOPO_OK +copysetInfo { + poolId: 1 + copysetId: 1 + peers { + id: 1 + address: "10.182.2.45:36701:0" + } + peers { + id: 2 + address: "10.182.2.45:26701:0" + } + peers { + id: 3 + address: "10.182.2.45:16701:0" + } + epoch: 0 + leaderPeer { + id: 3 + address: "10.182.2.45:16701:0" + } +} + +... + +``` + +[TOC](#table-of-contents) + +--- + +## build + +### **build-topology** + +build cluster topology + +Usage: + +```shell +curvefs_tool build-topology +``` + +Output: + +```shell + +``` + +[TOC](#table-of-contents) + +--- + +## umount + +### **umount-fs** + +umount fs from cluster + +Usage: + +```shell +curvefs_tool umount-fs +``` + +Output: + +```shell +umount fs from cluster success. +``` + +[TOC](#table-of-contents) + +--- + +## usage + +### **usage-metadata** + +show the metadata usage of cluster + +Usage: + +```shell +curvefs_tool usage-metadata +``` + +Output: + +```shell +metaserver[10.182.2.45:26701] usage: total: 1.06 TB used: 755.74 GB left: 327.23 GB +metaserver[10.182.2.45:16701] usage: total: 1.06 TB used: 755.74 GB left: 327.23 GB +metaserver[10.182.2.45:36701] usage: total: 1.06 TB used: 755.74 GB left: 327.23 GB +all cluster usage: total: 3.17 TB used: 2.21 TB left: 981.68 GB +``` + +[TOC](#table-of-contents) + +--- + +## delete + +### **delete-fs** + +delete fs by fsName + +Usage: + +```shell +curvefs_tool delete-fs -fsName=/test -confirm +``` + +Output: + +```shell +1. do you really want to delete fs (/test) :[Ny]y +2. do you really want to delete fs (/test) :[Ny]y +3. do you really want to delete fs (/test) :[Ny]y +delete fs /test success. +``` + +[TOC](#table-of-contents) + +--- + +## check + +### **check-copyset** + +checkout copyset status + +Usage: + +```shell +curvefs_tool checkout-copyset -copysetId=10 -poolId=1 +``` + +Output: + +```shell +copyset[4294967306]: +state: 1 +peer { + address: "10.182.2.45:16701:0" +} +leader { + address: "10.182.2.45:16701:0" +} +readonly: false +term: 2 +committedIndex: 1 +knownAppliedIndex: 1 +pendingIndex: 0 +pendingQueueSize: 0 +applyingIndex: 0 +firstIndex: 2 +lastIndex: 1 +diskIndex: 1 +epoch: 0 +``` + +[TOC](#table-of-contents) + +--- + +## query + +### **query-copyset** + +query copyset by copysetId + +Usage: + +```shell +curvefs_tool query-copyset -copysetId=10 -poolId=1 +``` + +Output: + +```shell +copyset[4294967306]: +-info: +statusCode: TOPO_OK copysetInfo { poolId: 1 copysetId: 10 peers { id: 1 address: "10.182.2.45:36701:0" } peers { id: 2 address: "10.182.2.45:26701:0" } peers { id: 3 address: "10.182.2.45:16701:0" } epoch: 0 leaderPeer { id: 3 address: "10.182.2.45:16701:0" } } +``` + +When using the -detail parameter, you can get information about copyset status. + +```shell +copyset[4294967306]: +-info: +statusCode: TOPO_OK copysetInfo { poolId: 1 copysetId: 10 peers { id: 1 address: "10.182.2.45:36701:0" } peers { id: 2 address: "10.182.2.45:26701:0" } peers { id: 3 address: "10.182.2.45:16701:0" } epoch: 0 leaderPeer { id: 3 address: "10.182.2.45:16701:0" } } +-status: +status: COPYSET_OP_STATUS_SUCCESS copysetStatus { state: 1 peer { address: "10.182.2.45:16701:0" } leader { address: "10.182.2.45:16701:0" } readonly: false term: 2 committedIndex: 1 knownAppliedIndex: 1 pendingIndex: 0 pendingQueueSize: 0 applyingIndex: 0 firstIndex: 2 lastIndex: 1 diskIndex: 1 epoch: 0 } +status: COPYSET_OP_STATUS_SUCCESS copysetStatus { state: 4 peer { address: "10.182.2.45:26701:0" } leader { address: "10.182.2.45:16701:0" } readonly: false term: 2 committedIndex: 1 knownAppliedIndex: 1 pendingIndex: 0 pendingQueueSize: 0 applyingIndex: 0 firstIndex: 2 lastIndex: 1 diskIndex: 1 epoch: 0 } +status: COPYSET_OP_STATUS_SUCCESS copysetStatus { state: 4 peer { address: "10.182.2.45:36701:0" } leader { address: "10.182.2.45:16701:0" } readonly: false term: 2 committedIndex: 1 knownAppliedIndex: 1 pendingIndex: 0 pendingQueueSize: 0 applyingIndex: 0 firstIndex: 2 lastIndex: 1 diskIndex: 1 epoch: 0 } +``` + +### **query-partition** + +query copyset in partition by partitionId + +Usage: + +```shell +curvefs_tool query-partition -query-partition -partitionId=1 +``` + +Output: + +```shell +statusCode: TOPO_OK +copysetMap { + key: 1 + value { + poolId: 1 + copysetId: 8 + peers { + id: 1 + address: "10.182.2.45:36701:0" + } + peers { + id: 2 + address: "10.182.2.45:26701:0" + } + peers { + id: 3 + address: "10.182.2.45:16701:0" + } + } +} +``` + +### **query-metaserver** + +query metaserver by metaserverId or metaserverName + +Usage: + +```shell +curvefs_tool query-metaserver -metaserverId=1 +``` + +Output: + +```shell +statusCode: TOPO_OK +MetaServerInfo { + metaServerID: 1 + hostname: "******************" + hostIp: "10.182.2.45" + port: 36701 + externalIp: "10.182.2.45" + externalPort: 36701 + onlineState: ONLINE +} +``` + +### query-fs + +query fs by fsId or fsName, fsId first. + +Usage: + +```shell +curvefs_tool query-fs -fsId=1 +``` + +Output: + +```shell +fsId: 1 +fsName: "/test" +status: INITED +rootInodeId: 1 +capacity: 18446744073709551615 +blockSize: 1 +mountNum: 1 +mountpoints: "09a03e7f5ece:/usr/local/curvefs/client/mnt" +fsType: TYPE_S3 +detail { + s3Info { + ak: "********************************" + sk: "********************************" + endpoint: "********************************" + bucketname: "********************************" + blockSize: 1048576 + chunkSize: 4194304 + } +} + +``` + +[TOC](#table-of-contents) + +--- diff --git a/curvefs/src/tools/check/curvefs_copyset_check.cpp b/curvefs/src/tools/check/curvefs_copyset_check.cpp index d73f02bb8d..a6db8aed82 100644 --- a/curvefs/src/tools/check/curvefs_copyset_check.cpp +++ b/curvefs/src/tools/check/curvefs_copyset_check.cpp @@ -32,8 +32,8 @@ namespace check { void CopysetCheckTool::PrintHelp() { CurvefsToolRpc::PrintHelp(); - std::cout << " -copysetsId=" << FLAGS_copysetId - << " -poolsId=" << FLAGS_poolId + std::cout << " -copysetId=" << FLAGS_copysetId + << " -poolId=" << FLAGS_poolId << " [-metaserverAddr=" << FLAGS_metaserverAddr << "]"; std::cout << std::endl; } diff --git a/curvefs/src/tools/check/curvefs_copyset_check.h b/curvefs/src/tools/check/curvefs_copyset_check.h index e38e4053ac..35afe45f7f 100644 --- a/curvefs/src/tools/check/curvefs_copyset_check.h +++ b/curvefs/src/tools/check/curvefs_copyset_check.h @@ -48,7 +48,7 @@ class CopysetCheckTool curvefs::metaserver::copyset::CopysetService_Stub> { public: explicit CopysetCheckTool(const std::string& cmd = kCopysetCheckCmd, - bool show = false) + bool show = true) : CurvefsToolRpc(cmd) { show_ = show; } diff --git a/curvefs/src/tools/curvefs_tool_define.h b/curvefs/src/tools/curvefs_tool_define.h index 6beaeb4524..2eb57999bf 100644 --- a/curvefs/src/tools/curvefs_tool_define.h +++ b/curvefs/src/tools/curvefs_tool_define.h @@ -82,22 +82,22 @@ const char kConfPathHelp[] = "[-confPath=/etc/curvefs/tools.conf]"; const char kHelpStr[] = "Usage: curvefs_tool [Command] [OPTIONS...]\n" "COMMANDS:\n" // NOLINT - "version: show the version of cluster\n" - "build-topology: build cluster topology based on topo.json\n" - "umount-fs: umount curvefs from local and cluster\n" - "usage-metadata: show the metadata usage of cluster\n" - "status-mds: show the status of mds\n" + "version: show the version of curvefs_tool\n" + "status-mds: show the status of mds\n" "status-metaserver: show the status of metaserver\n" - "status-etcd: show the status of etcd\n" - "status-copyset: show the status of copyset\n" - "list-fs: list all fs in cluster\n" - "list-copysetInfo: list all copysetInfo in cluster\n" - "query-copyset: query copyset by copysetId\n" - "query-partition: query copyset in partition\n" - "query-metaserver: query metaserver by metaserverId or metaserverName\n" - "query-fs: query fs by fsId or fsName\n" - "delete-fs: delete fs by fsId or fsName\n" - "check-copyset: checkout copyset status\n" + "status-etcd: show the status of etcd\n" + "status-copyset: show the status of copyset\n" + "list-fs: list all fs in cluster\n" + "list-copysetInfo: list all copysetInfo in cluster\n" + "build-topology: build cluster topology based on topo.json\n" + "umount-fs: umount curvefs from local and cluster\n" + "usage-metadata: show the metadata usage of cluster\n" + "delete-fs: delete fs by fsName\n" + "check-copyset: checkout copyset status\n" + "query-copyset: query copyset by copysetId and poolId\n" + "query-partition: query copyset in partition by partitionId\n" + "query-metaserver: query metaserver by metaserverId or metaserverName\n" + "query-fs: query fs by fsId or fsName\n" "You can specify the config path by -confPath to avoid typing too many " "options\n"; // NOLINT diff --git a/curvefs/src/tools/list/curvefs_copysetinfo_list.cpp b/curvefs/src/tools/list/curvefs_copysetinfo_list.cpp index 12e05eda77..04dc1c33b1 100644 --- a/curvefs/src/tools/list/curvefs_copysetinfo_list.cpp +++ b/curvefs/src/tools/list/curvefs_copysetinfo_list.cpp @@ -62,7 +62,10 @@ bool CopysetInfoListTool::AfterSendRequestToHost(const std::string& host) { ret = false; } else if (show_) { for (auto const& i : response_->copysetvalues()) { - std::cout << i.DebugString() << " "; + std::cout << "copyset[" + << copyset::GetCopysetKey(i.copysetinfo().poolid(), + i.copysetinfo().copysetid()) + << "]:" << std::endl << i.DebugString() << std::endl; } std::cout << std::endl; } diff --git a/curvefs/src/tools/list/curvefs_copysetinfo_list.h b/curvefs/src/tools/list/curvefs_copysetinfo_list.h index b406c01017..b102616cae 100644 --- a/curvefs/src/tools/list/curvefs_copysetinfo_list.h +++ b/curvefs/src/tools/list/curvefs_copysetinfo_list.h @@ -27,6 +27,7 @@ #include #include "curvefs/proto/topology.pb.h" +#include "curvefs/src/tools/copyset/curvefs_copyset_base_tool.h" #include "curvefs/src/tools/curvefs_tool.h" #include "curvefs/src/tools/curvefs_tool_define.h" #include "src/common/string_util.h" diff --git a/curvefs/src/tools/query/curvefs_copyset_query.cpp b/curvefs/src/tools/query/curvefs_copyset_query.cpp index 5360a725d0..6c0c505db8 100644 --- a/curvefs/src/tools/query/curvefs_copyset_query.cpp +++ b/curvefs/src/tools/query/curvefs_copyset_query.cpp @@ -109,12 +109,12 @@ bool CopysetQueryTool::AfterSendRequestToHost(const std::string& host) { if (show_) { for (auto const& i : copysetKeys_) { - std::cout << "copyset[" << i << "]:\n info:\n"; + std::cout << "copyset[" << i << "]:\n-info:" << std::endl; for (auto const& j : key2Infos_[i]) { std::cout << j.ShortDebugString() << std::endl; } if (FLAGS_detail) { - std::cout << "\nstatus:" << std::endl; + std::cout << "-status:" << std::endl; for (auto const& j : key2Status_[i]) { std::cout << j.ShortDebugString() << std::endl; } diff --git a/curvefs/src/tools/query/curvefs_partition_query.h b/curvefs/src/tools/query/curvefs_partition_query.h index 1159425299..07b8d89da6 100644 --- a/curvefs/src/tools/query/curvefs_partition_query.h +++ b/curvefs/src/tools/query/curvefs_partition_query.h @@ -44,7 +44,7 @@ class PartitionQueryTool curvefs::mds::topology::GetCopysetOfPartitionResponse, curvefs::mds::topology::TopologyService_Stub> { public: - explicit PartitionQueryTool(const std::string& cmd = kCopysetQueryCmd, + explicit PartitionQueryTool(const std::string& cmd = kPartitionQueryCmd, bool show = true) : CurvefsToolRpc(cmd) { show_ = show;