diff --git a/README.md b/README.md index 781b980eb8..6f5dd91aad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[English version](README_en.md) +[中文版](README_cn.md) @@ -14,79 +14,77 @@ [![Releases](https://img.shields.io/github/v/release/opencurve/curve?include_prereleases)](https://github.com/opencurve/curve/releases) [![LICENSE](https://img.shields.io/badge/licence-Apache--2.0%2FGPL-blue)](https://github.com/opencurve/curve/blob/master/LICENSE) +CURVE is a distributed storage system designed and developed independently by NetEase, featured with high performance, high availability, high reliability and well expansibility, and it can serve as the basis for storage systems designed for different scenario (e.g. block storage, object storage and cloud database). -CURVE是网易自主设计研发的高性能、高可用、高可靠分布式存储系统,具有非常良好的扩展性。基于该存储底座可以打造适用于不同应用场景的存储系统,如块存储、对象存储、云原生数据库等。当前我们基于CURVE已经实现了高性能块存储系统,支持快照克隆和恢复 ,支持QEMU虚拟机和物理机NBD设备两种挂载方式, 在网易内部作为高性能云盘使用。 +So far, we have implemented a high performance block storage system, which supports snapshot, clone and recovery, and it can be attached to QEMU virtual machine or physical machine (by curve-nbd). CURVE has been served as an elastic block storage service inside NetEase for a certain time, during which high performance and reliability have shown. -## 设计文档 +## Design Documentation -- 通过 [CURVE概述](https://www.opencurve.io/) 可以了解 CURVE 架构 -- CURVE相关文档 - - [NEBD](docs/cn/nebd.md) - - [MDS](docs/cn/mds.md) - - [Chunkserver](docs/cn/chunkserver_design.md) - - [Snapshotcloneserver](docs/cn/snapshotcloneserver.md) - - [CURVE质量体系介绍](docs/cn/quality.md) - - [CURVE监控体系介绍](docs/cn/monitor.md) - - [Client](docs/cn/curve-client.md) - - [Client Python API](docs/cn/curve-client-python-api.md) -- CURVE上层应用 - - [对接k8s文档](docs/cn/k8s_csi_interface.md) +- Wanna have a glance at CURVE? Click here for [Intro to CURVE](https://www.opencurve.io/)! +- Want more details? Our documentation for every component: + - [NEBD](docs/en/nebd_en.md) + - [MDS](docs/en/mds_en.md) + - [Chunkserver](docs/en/chunkserver_design_en.md) + - [Snapshotcloneserver](docs/en/snapshotcloneserver_en.md) + - [CURVE quality control](docs/en/quality_en.md) + - [CURVE monitoring](docs/en/monitor_en.md) + - [Client](docs/en/client_en.md) + - [Client Python API](docs/en/curve-client-python-api_en.md) +- Application based on CURVE + - [Work with k8s](docs/en/k8s_csi_interface_en.md) -## 快速开始 +## Quick Start -在您开始动手部署前请先仔细阅读特别说明部分:[特别说明](docs/cn/deploy.md#%E7%89%B9%E5%88%AB%E8%AF%B4%E6%98%8E) +Want to try on it? Take it easy! We'll help you step by step, but make sure you've read this [Special Statement](docs/en/deploy_en.md#special-statement) before you start. -### 部署All-in-one体验环境 +### Deploy an all-in-one environment (to try how CURVE works) -[单机部署](docs/cn/deploy.md#%E5%8D%95%E6%9C%BA%E9%83%A8%E7%BD%B2) +[Deploy on single machine](docs/en/deploy_en.md#deploy-on-single-machine) -### 部署多机集群 +### Deploy multi-machine cluster (try it in production environment) -[多机部署](docs/cn/deploy.md#%E5%A4%9A%E6%9C%BA%E9%83%A8%E7%BD%B2) +[Deploy on multiple machines](docs/en/deploy_en.md#deploy-on-multiple-machines) -### 查询工具说明 +### curve_ops_tool introduction -[查询工具说明](docs/cn/curve_ops_tool.md) +[curve_ops_tool introduction](docs/en/curve_ops_tool_en.md) -## 参与开发 +## For Developers +### Deploy build and development environment -### 部署编译开发环境 +[development environment deployment](docs/en/build_and_run_en.md) -[编译开发环境搭建](docs/cn/build_and_run.md) +### Compile test cases and run +[test cases compiling and running](docs/en/build_and_run_en.md#test-case-compilation-and-execution) -### 测试用例编译及运行 -[测试用例编译及运行](docs/cn/build_and_run.md#%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B%E7%BC%96%E8%AF%91%E5%8F%8A%E6%89%A7%E8%A1%8C) +### Coding style guides +CURVE is coded following [Google C++ Style Guide strictly](https://google.github.io/styleguide/cppguide.html). Please follow this guideline if you're trying to contribute your codes. -### 编码规范 -CURVE编码规范严格按照[Google C++开源项目编码指南](https://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/contents/)来进行代码编写,请您也遵循这一指南来提交您的代码。 +### Code coverage requirement +1. Unit tests: Incremental line coverage ≥ 80%, incremental branch coverage ≥ 70% +2. Integration tests: Measure together with unit tests, and should fulfill the same requirement +3. Exception tests: Not required yet -### 测试覆盖率要求 -1. 单元测试:增量行覆盖80%以上,增量分支覆盖70%以上 -2. 集成测试:与单元测试合并统计,满足上述覆盖率要求即可 -3. 异常测试:暂不做要求 +### Other processes -### 其他开发流程说明 -代码开发完成之后,提[pr](https://github.com/opencurve/curve/compare)到curve的master分支。提交pr时,请填写pr模板。pr提交之后会自动触发CI,CI通过并且经过review之后,代码才可合入。 -具体规则请见[CONTRIBUTING](https://github.com/opencurve/curve/blob/master/CONTRIBUTING.md). +After finishing the development of your code, you should submit a pull request to master branch of CURVE and fill out a pull request template. The pull request will trigger the CI automatically, and the code will only be merged after passing the CI and being reviewed. -## 版本发布周期 -- CURVE版本发布周期:大版本半年,小版本1~2个月 -- 版本号规则:采用3段式版本号,x.y.z{-后缀},x是大版本,y是小版本,z是bugfix,后缀用来区beta版本(-beta)、rc版本(-rc)、和稳定版本(没有后缀)。每半年的大版本是指x增加1,每1~2个月的小版本是y增加1。正式版本发布之后,如果有bugfix是z增加1。 +For more detail, please refer to [CONTRIBUTING](https://github.com/opencurve/curve/blob/master/CONTRIBUTING.md). -## 分支规则 -所有的开发都在master分支开发,如果需要发布版本,从master拉取新的分支**release-x.y**。版本发布从release-x.y分支发布。 - -## 反馈及交流 - -- [Github Issues](https://github.com/openCURVE/CURVE/issues):欢迎提交BUG、建议,使用中如遇到问题可参考FAQ或加入我们的User group进行咨询 -- [FAQ](https://github.com/openCURVE/CURVE/wiki/CURVE-FAQ):主要根据User group中常见问题整理,还在逐步完善中 -- User group:当前为微信群,由于群人数过多,需要先添加以下个人微信,再邀请进群。 - - +## Release Cycle +- CURVE release cycle:Half a year for major version, 1~2 months for minor version +- Versioning format: We use a sequence of three digits and a suffix (x.y.z{-suffix}), x is the major version, y is the minor version, and z is for bugfix. The suffix is for distinguishing beta (-beta), RC (-rc) and GA version (without any suffix). Major version x will increase 1 every half year, and y will increase every 1~2 months. After a version is released, number z will increase if there's any bugfix. +## Branch +All the developments will be done under master branch. If there's any new version to establish, a new branch release-x.y will be pulled from the master, and the new version will be released from this branch. +## Feedback & Contact +- [Github Issues](https://github.com/openCURVE/CURVE/issues):You are sincerely welcomed to issue any bugs you came across or any suggestions through Github issues. If you have any question you can refer to our FAQ or join our user group for more details. +- [FAQ](https://github.com/openCURVE/CURVE/wiki/CURVE-FAQ):Frequently asked question in our user group, and we'll keep working on it. +- User group:We use Wechat group currently. + diff --git a/README_cn.md b/README_cn.md new file mode 100644 index 0000000000..2790262754 --- /dev/null +++ b/README_cn.md @@ -0,0 +1,91 @@ +[English version](README.md) + + + + +# CURVE + +[![Jenkins Coverage](https://img.shields.io/jenkins/coverage/cobertura?jobUrl=http%3A%2F%2F59.111.91.248%3A8080%2Fjob%2Fcurve_untest_job%2F)](http://59.111.91.248:8080/job/curve_untest_job/HTML_20Report/) +[![Robot failover](https://img.shields.io/jenkins/build?jobUrl=http%3A%2F%2F59.111.91.248%3A8080%2Fjob%2Fcurve_failover_testjob%2F&label=failover)](http://59.111.91.248:8080/job/curve_failover_testjob/) +[![Robot interface](https://img.shields.io/jenkins/tests?jobUrl=http%3A%2F%2F59.111.91.248%3A8080%2Fjob%2Fcurve_robot_job%2F)](http://59.111.91.248:8080/job/curve_robot_job/) +[![BUILD Status](https://img.shields.io/jenkins/build?jobUrl=http%3A%2F%2F59.111.91.248%3A8080%2Fjob%2Fopencurve_multijob%2F)](http://59.111.91.248:8080/job/opencurve_multijob/lastBuild) +[![Docs](https://img.shields.io/badge/docs-latest-green.svg)](https://github.com/opencurve/curve/tree/master/docs) +[![Releases](https://img.shields.io/github/v/release/opencurve/curve?include_prereleases)](https://github.com/opencurve/curve/releases) +[![LICENSE](https://img.shields.io/badge/licence-Apache--2.0%2FGPL-blue)](https://github.com/opencurve/curve/blob/master/LICENSE) + + +CURVE是网易自主设计研发的高性能、高可用、高可靠分布式存储系统,具有非常良好的扩展性。基于该存储底座可以打造适用于不同应用场景的存储系统,如块存储、对象存储、云原生数据库等。当前我们基于CURVE已经实现了高性能块存储系统,支持快照克隆和恢复 ,支持QEMU虚拟机和物理机NBD设备两种挂载方式, 在网易内部作为高性能云盘使用。 + +## 设计文档 + +- 通过 [CURVE概述](https://opencurve.github.io/) 可以了解 CURVE 架构 +- CURVE相关文档 + - [NEBD](docs/cn/nebd.md) + - [MDS](docs/cn/mds.md) + - [Chunkserver](docs/cn/chunkserver_design.md) + - [Snapshotcloneserver](docs/cn/snapshotcloneserver.md) + - [CURVE质量体系介绍](docs/cn/quality.md) + - [CURVE监控体系介绍](docs/cn/monitor.md) + - [Client](docs/cn/curve-client.md) + - [Client Python API](docs/cn/curve-client-python-api.md) +- CURVE上层应用 + - [对接k8s文档](docs/cn/k8s_csi_interface.md) + +## 快速开始 + +在您开始动手部署前请先仔细阅读特别说明部分:[特别说明](docs/cn/deploy.md#%E7%89%B9%E5%88%AB%E8%AF%B4%E6%98%8E) + +### 部署All-in-one体验环境 + +[单机部署](docs/cn/deploy.md#%E5%8D%95%E6%9C%BA%E9%83%A8%E7%BD%B2) + +### 部署多机集群 + +[多机部署](docs/cn/deploy.md#%E5%A4%9A%E6%9C%BA%E9%83%A8%E7%BD%B2) + +### 查询工具说明 + +[查询工具说明](docs/cn/curve_ops_tool.md) + +## 参与开发 + + +### 部署编译开发环境 + +[编译开发环境搭建](docs/cn/build_and_run.md) + +### 测试用例编译及运行 +[测试用例编译及运行](docs/cn/build_and_run.md#%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B%E7%BC%96%E8%AF%91%E5%8F%8A%E6%89%A7%E8%A1%8C) + +### 编码规范 +CURVE编码规范严格按照[Google C++开源项目编码指南](https://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/contents/)来进行代码编写,请您也遵循这一指南来提交您的代码。 + +### 测试覆盖率要求 +1. 单元测试:增量行覆盖80%以上,增量分支覆盖70%以上 +2. 集成测试:与单元测试合并统计,满足上述覆盖率要求即可 +3. 异常测试:暂不做要求 + +### 其他开发流程说明 +代码开发完成之后,提[pr](https://github.com/opencurve/curve/compare)到curve的master分支。提交pr时,请填写pr模板。pr提交之后会自动触发CI,CI通过并且经过review之后,代码才可合入。 +具体规则请见[CONTRIBUTING](https://github.com/opencurve/curve/blob/master/CONTRIBUTING.md). + +## 版本发布周期 +- CURVE版本发布周期:大版本半年,小版本1~2个月 +- 版本号规则:采用3段式版本号,x.y.z{-后缀},x是大版本,y是小版本,z是bugfix,后缀用来区beta版本(-beta)、rc版本(-rc)、和稳定版本(没有后缀)。每半年的大版本是指x增加1,每1~2个月的小版本是y增加1。正式版本发布之后,如果有bugfix是z增加1。 + +## 分支规则 +所有的开发都在master分支开发,如果需要发布版本,从master拉取新的分支**release-x.y**。版本发布从release-x.y分支发布。 + +## 反馈及交流 + +- [Github Issues](https://github.com/openCURVE/CURVE/issues):欢迎提交BUG、建议,使用中如遇到问题可参考FAQ或加入我们的User group进行咨询 +- [FAQ](https://github.com/openCURVE/CURVE/wiki/CURVE-FAQ):主要根据User group中常见问题整理,还在逐步完善中 +- User group:当前为微信群,由于群人数过多,需要先添加以下个人微信,再邀请进群。 + + + + + + + + diff --git a/README_en.md b/README_en.md deleted file mode 100644 index 6bee5ebbef..0000000000 --- a/README_en.md +++ /dev/null @@ -1,89 +0,0 @@ -[中文版](README.md) - - - - -# CURVE - -[![Jenkins Coverage](https://img.shields.io/jenkins/coverage/cobertura?jobUrl=http%3A%2F%2F59.111.93.165%3A8080%2Fjob%2Fcurve_untest_job%2F)](http://59.111.93.165:8080/job/curve_untest_job/HTML_20Report/) -[![Robot failover](https://img.shields.io/jenkins/build?jobUrl=http%3A%2F%2F59.111.93.165%3A8080%2Fjob%2Fcurve_failover_testjob%2F&label=failover)](http://59.111.93.165:8080/job/curve_failover_testjob/) -[![Robot interface](https://img.shields.io/jenkins/tests?jobUrl=http%3A%2F%2F59.111.93.165%3A8080%2Fjob%2Fcurve_robot_job%2F)](http://59.111.93.165:8080/job/curve_robot_job/) -[![BUILD Status](https://img.shields.io/jenkins/build?jobUrl=http%3A%2F%2F59.111.93.165%3A8080%2Fjob%2Fopencurve_multijob%2F)](http://59.111.93.165:8080/job/opencurve_multijob/lastBuild) -[![Docs](https://img.shields.io/badge/docs-latest-green.svg)](https://github.com/opencurve/curve/tree/master/docs) -[![Releases](https://img.shields.io/github/v/release/opencurve/curve?include_prereleases)](https://github.com/opencurve/curve/releases) -[![LICENSE](https://img.shields.io/badge/licence-Apache--2.0%2FGPL-blue)](https://github.com/opencurve/curve/blob/master/LICENSE) - -CURVE is a distributed storage system designed and developed independently by NetEase, featured with high performance, high availability, high reliability and well expansibility, and it can serve as the basis for storage systems designed for different scenario (e.g. block storage, object storage and cloud database). - -So far, we have implemented a high performance block storage system, which supports snapshot, clone and recovery, and it can be attached on QEMU virtual machine or physical machine (by curve-nbd). CURVE has been served as an elastic block storage service inside NetEase for a certain time, during which high performance and reliability have shown. - -## Design Documentation - -- Wanna have a glance at CURVE? Click here for [Intro to CURVE](https://opencurve.github.io/)! -- Want more details? Our documentation for every component: - - [NEBD](docs/en/nebd_en.md) - - [MDS](docs/en/mds_en.md) - - [Chunkserver](docs/cn/chunkserver_design_en.md) - - [Snapshotcloneserver](docs/cn/snapshotcloneserver_en.md) - - [CURVE quality control](docs/cn/quality.md) - - [CURVE monitoring](docs/cn/monitor.md) - - [Client](docs/cn/curve-client.md) - - [Client Python API](docs/cn/curve-client-python-api.md) -- Application based on CURVE - - [Work with k8s](docs/cn/k8s_csi_interface.md) - -## Quick Start - -Want to try on it? Take it easy! We'll help you step by step, but make sure you've read this [Special Statement](docs/cn/deploy.md#%E7%89%B9%E5%88%AB%E8%AF%B4%E6%98%8E) before you start. - -### Deploy an all-in-one environment (to try how CURVE works) - -[Deploy on single machine](docs/cn/deploy.md#%E5%8D%95%E6%9C%BA%E9%83%A8%E7%BD%B2) - -### Deploy multi-machine cluster (try it in production environment) - -[Deploy on multiple machines](docs/cn/deploy.md#%E5%A4%9A%E6%9C%BA%E9%83%A8%E7%BD%B2) - -### curve_ops_tool introduction - -[curve_ops_tool introduction](docs/cn/curve_ops_tool.md) - -## For Developers - -### Deploy build and development environment - -[development environment deployment](docs/cn/build_and_run.md) - -### Compile test cases and run -[test cases compiling and running](docs/cn/build_and_run.md#%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B%E7%BC%96%E8%AF%91%E5%8F%8A%E6%89%A7%E8%A1%8C) - -### Coding style guides -CURVE is coded following [Google C++ Style Guide strictly](https://google.github.io/styleguide/cppguide.html). Please follow this guideline if you're trying to contribute your codes. - -### Code coverage requirement -1. Unit tests: Incremental line coverage ≥ 80%, incremental branch coverage ≥ 70% -2. Integration tests: Measure together with unit tests, and should fulfill the same requirement -3. Exception tests: Not required yet - -### Other processes - -After finishing the development of your code, you should submit a pull request to master branch of CURVE and fill out a pull request template. The pull request will trigger the CI automatically, and the code will only be merged after passing the CI and being reviewed. - -For more detail, please refer to [CONTRIBUTING](https://github.com/opencurve/curve/blob/master/CONTRIBUTING.md). - -## Release Cycle -- CURVE release cycle:Half a year for major version, 1~2 months for minor version - -- Versioning format: We use a sequence of three digits and a suffix (x.y.z{-suffix}), x is the major version, y is the minor version, and z is for bugfix. The suffix is for distinguishing beta (-beta), RC (-rc) and GA version (without any suffix). Major version x will increase 1 every half year, and y will increase every 1~2 months. After a version is released, number z will increase if there's any bugfix. - -## Branch - -All the developments will be done under master branch. If there's any new version to establish, a new branch release-x.y will be pulled from the master, and the new version will be released from this branch. - -## Feedback & Contact - -- [Github Issues](https://github.com/openCURVE/CURVE/issues):You are sincerely welcomed to issue any bugs you came across or any suggestions through Github issues. If you have any question you can refer to our FAQ or join our user group for more details. -- [FAQ](https://github.com/openCURVE/CURVE/wiki/CURVE-FAQ):Frequently asked question in our user group, and we'll keep working on it. -- User group:We use Wechat group currently. - - diff --git a/docs/cn/curve-client-python-api.md b/docs/cn/curve-client-python-api.md index b730ad24a2..90adcfe8d1 100644 --- a/docs/cn/curve-client-python-api.md +++ b/docs/cn/curve-client-python-api.md @@ -1,304 +1,322 @@ -#### 获取一个与curve集群交互的CBDClient对象 - -```python -import curvefs - -# 获取一个与后端集群交互的CBDClient对象,不同的CBDClient对象可以与不同的集群建立连接 -cbd1 = curvefs.CBDClient() -cbd2 = curvefs.CBDClient() -``` - -#### 初始化CBDClient - -```python -import curvefs -cbd = curvefs.CBDClient() - -# 参数:curve-client配置文件的绝对路径 -# 返回值:返回0表示初始化成功,-1表示初始化失败 -cbd.Init("/etc/curve/client.conf") -``` - -#### 创建文件 - -```python -import curvefs -cbd = curvefs.CBDClient() -cbd.Init("/etc/curve/client.conf") # 后续示例省略初始化过程 - -# 参数:三个参数分别为 -# 文件全路径 -# 文件所属用户信息 -# 文件大小 -# 返回值:返回0表示创建成功,否则返回错误码 - -# 首先初始化user信息(curvefs的控制面接口都有用户信息验证,都需要传入用户信息) -user = curvefs.UserInfo_t() -user.owner = "curve" -user.password = "" # 密码为空时,可以省略 - -# 调用Create接口创建文件 -cbd.Create("/curve", user, 10*1024*1024*1024) - -# UserInfo定义如下 -typedef struct UserInfo { - char owner[256]; # 用户名 - char password[256]; # 用户密码 -} UserInfo_t; -``` - -#### 查看文件信息 - -```python -# 参数:三个参数分别为 -# 文件名 -# 用户信息 -# 文件信息[出参] -# 返回值:返回0表示获取成功,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "curve" - -# 构造file信息 -finfo = curvefs.FileInfo_t() - -# 查看文件信息 -cbd.StatFile("/curve", user, finfo) -print finfo.filetype -print finfo.length -print finfo.ctime - -# FileInfo定义如下 -typedef struct FileInfo { - uint64_t id; - uint64_t parentid; - int filetype; # 卷类型 - uint64_t length; # 卷大小 - uint64_t ctime; # 卷创建时间 - char filename[256]; # 卷名 - char owner[256]; # 卷所属用户 - int fileStatus; # 卷状态 -} FileInfo_t; - -# 文件状态 -#define CURVE_FILE_CREATED 0 -#define CURVE_FILE_DELETING 1 -#define CURVE_FILE_CLONING 2 -#define CURVE_FILE_CLONEMETAINSTALLED 3 -#define CURVE_FILE_CLONED 4 -#define CURVE_FILE_BEINGCLONED 5 -``` - -#### 扩容文件 - -```python -# 参数:三个参数分别为 -# 文件名 -# 用户信息 -# 扩容后文件大小 -# 返回值:返回0表示扩容成功,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "curve" - -# 扩容 -cbd.Extend("/curve", user, 20*1024*1024*1024) - -# 查看扩容后的文件信息 -finfo = curvefs.FileInfo_t() -cbd.StatFile("/curve", user, finfo) -print finfo.length -``` - -#### 打开/关闭文件 - -```python -# 打开文件 -# 参数:两个参数分别为 -# 文件名 -# 用户信息 -# 返回值:打开成功返回文件fd,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "user1" - -# 打开文件,返回fd -fd = cbd.Open("/tmp1", user) - -# 关闭文件 -# 参数:打开文件时返回的fd -# 返回值:关闭成功返回0,否则返回错误码 -cbd.Close(fd) -``` - -#### 读写文件 - -```python -# 写文件 -# 参数:四个参数分别为 -# 文件fd -# 待写入数据 -# 偏移量 -# 写入数据长度 -# 返回值:写入成功返回写入字节数,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "user1" - -# 打开文件,返回fd -fd = cbd.Open("/tmp1", user) - -# 写文件(目前读写都需要4k对齐) -cbd.Write(fd, "aaaaaaaa"*512, 0, 4096) -cbd.Write(fd, "bbbbbbbb"*512, 4096, 4096) - -# 读文件 -# 参数:四个参数分别为 -# 文件fd -# 空字符串 -# 偏移量 -# 读取数据长度 -# 返回值:读取成功返回读取数据,否则返回错误码 - -# 读取的内容通过返回值返回,buf在此没有意义,可以传入一个空串 -cbd.Read(fd,"", 0, 4096) - -# 关闭文件 -cbd.Close(fd) -``` - -备注:当前python api接口,不支持异步读写 - -#### 删除文件 - -```python -# 参数:两个参数分别为 -# 文件名 -# 用户信息 -# 返回值:删除成功返回0,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "curve" - -# 删除文件 -cbd.Unlink("/curve", user) -``` - -#### 重命名文件 - -```python -# 参数:三个参数分别为 -# 用户信息 -# 旧文件名 -# 新文件名 -# 返回值:成功返回0,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "curve" - -# 重命名 -cbd.Rename(user, "/curve", "/curve-new") -``` - -#### 创建目录 - -```python -# 参数:两个参数分别为 -# 目录路径 -# 用户信息 -# 返回值:成功返回0,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "curve" -# 创建目录 -cbd.Mkdir("/curvedir", user) -``` - -#### 删除目录 - -```python -# 参数:两个参数分别为 -# 目录路径 -# 用户信息 -# 返回值:成功返回0,否则返回错误码 - -# 构造user信息 -user = curvefs.UserInfo_t() -user.owner = "curve" - -# 删除目录 -cbd.Rmdir("/curvedir", user) -``` - -#### 获取目录下的文件 - -```python -# 参数:两个参数分别为 -# 目录路径 -# 用户信息 -# 返回值:当前目录下的文件列表(只包括文件名) -files = cbd.Listdir("/test", user) -for f in files: - print f -``` - -#### 获取集群ID - -```python -# 通过返回值判断是否获取成功 -# 成功返回集群id字符串 -# 失败返回空字符串 -clusterId = cbd.GetClusterId() -print clusterId -# c355675a-f4d2-4729-b80a-5a7bcc749d1c -``` - -#### 清理CBDClient对象 - -```python -cbd.UnInit() -``` - -### 错误码 - -| Code | Message | 描述 | -| :--: | :-------------------------- | ------------------------ | -| 0 | OK | 操作成功 | -| -1 | EXISTS | 文件或目录已存存在 | -| -2 | FAILED | 操作失败 | -| -3 | DISABLEDIO | 禁止IO | -| -4 | AUTHFAIL | 认证失败 | -| -5 | DELETING | 正在删除 | -| -6 | NOTEXIST | 文件不存在 | -| -7 | UNDER_SNAPSHOT | 快照中 | -| -8 | NOT_UNDERSNAPSHOT | 非快照状态 | -| -9 | DELETE_ERROR | 删除错误 | -| -10 | NOT_ALLOCATE | Segment未分配 | -| -11 | NOT_SUPPORT | 操作不支持 | -| -12 | NOT_EMPTY | 目录非空 | -| -13 | NO_SHRINK_BIGGER_FILE | 禁止缩容 | -| -14 | SESSION_NOTEXISTS | Session不存在 | -| -15 | FILE_OCCUPIED | 文件被占用 | -| -16 | PARAM_ERROR | 参数错误 | -| -17 | INTERNAL_ERROR | 内部错误 | -| -18 | CRC_ERROR | CRC检查错误 | -| -19 | INVALID_REQUEST | 请求参数存在异常 | -| -20 | DISK_FAIL | 磁盘异常 | -| -21 | NO_SPACE | 空间不足 | -| -22 | NOT_ALIGNED | IO未对齐 | -| -23 | BAD_FD | 文件正在被关闭,fd不可用 | -| -24 | LENGTH_NOT_SUPPORT | 文件长度不满足要求 | -| -25 | SESSION_NOT_EXIST | Session不存在(与-14重复) | -| -26 | STATUS_NOT_MATCH | 状态异常 | -| -27 | DELETE_BEING_CLONED | 删除文件正在被克隆 | -| -28 | CLIENT_NOT_SUPPORT_SNAPSHOT | Client版本不支持快照 | -| -29 | SNAPSHOT_FROZEN | Snapshot功能禁用中 | -| -100 | UNKNOWN | 未知错误 | - +[English version](../en/curve-client-python-api_en.md) + +#### 获取一个与curve集群交互的CBDClient对象 + +```python +import curvefs + +# 获取一个与后端集群交互的CBDClient对象,不同的CBDClient对象可以与不同的集群建立连接 +cbd1 = curvefs.CBDClient() +cbd2 = curvefs.CBDClient() +``` + +#### 初始化CBDClient + +```python +import curvefs +cbd = curvefs.CBDClient() + +# 参数:curve-client配置文件的绝对路径 +# 返回值:返回0表示初始化成功,-1表示初始化失败 +cbd.Init("/etc/curve/client.conf") +``` + +#### 创建文件 + +```python +import curvefs +cbd = curvefs.CBDClient() +cbd.Init("/etc/curve/client.conf") # 后续示例省略初始化过程 + +# 参数:三个参数分别为 +# 文件全路径 +# 文件所属用户信息 +# 文件大小 +# 返回值:返回0表示创建成功,否则返回错误码 + +# 首先初始化user信息(curvefs的控制面接口都有用户信息验证,都需要传入用户信息) +user = curvefs.UserInfo_t() +user.owner = "curve" +user.password = "" # 密码为空时,可以省略 + +# 调用Create接口创建文件 +cbd.Create("/curve", user, 10*1024*1024*1024) + +# UserInfo定义如下 +typedef struct UserInfo { + char owner[256]; # 用户名 + char password[256]; # 用户密码 +} UserInfo_t; +``` + +#### 查看文件信息 + +```python +# 参数:三个参数分别为 +# 文件名 +# 用户信息 +# 文件信息[出参] +# 返回值:返回0表示获取成功,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "curve" + +# 构造file信息 +finfo = curvefs.FileInfo_t() + +# 查看文件信息 +cbd.StatFile("/curve", user, finfo) +print finfo.filetype +print finfo.length +print finfo.ctime + +# FileInfo定义如下 +typedef struct FileInfo { + uint64_t id; + uint64_t parentid; + int filetype; # 卷类型 + uint64_t length; # 卷大小 + uint64_t ctime; # 卷创建时间 + char filename[256]; # 卷名 + char owner[256]; # 卷所属用户 + int fileStatus; # 卷状态 +} FileInfo_t; + +# 文件状态 +#define CURVE_FILE_CREATED 0 +#define CURVE_FILE_DELETING 1 +#define CURVE_FILE_CLONING 2 +#define CURVE_FILE_CLONEMETAINSTALLED 3 +#define CURVE_FILE_CLONED 4 +#define CURVE_FILE_BEINGCLONED 5 +``` + +#### 扩容文件 + +```python +# 参数:三个参数分别为 +# 文件名 +# 用户信息 +# 扩容后文件大小 +# 返回值:返回0表示扩容成功,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "curve" + +# 扩容 +cbd.Extend("/curve", user, 20*1024*1024*1024) + +# 查看扩容后的文件信息 +finfo = curvefs.FileInfo_t() +cbd.StatFile("/curve", user, finfo) +print finfo.length +``` + +#### 打开/关闭文件 + +```python +# 打开文件 +# 参数:两个参数分别为 +# 文件名 +# 用户信息 +# 返回值:打开成功返回文件fd,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "user1" + +# 打开文件,返回fd +fd = cbd.Open("/tmp1", user) + +# 关闭文件 +# 参数:打开文件时返回的fd +# 返回值:关闭成功返回0,否则返回错误码 +cbd.Close(fd) +``` + +#### 读写文件 + +```python +# 写文件 +# 参数:四个参数分别为 +# 文件fd +# 待写入数据 +# 偏移量 +# 写入数据长度 +# 返回值:写入成功返回写入字节数,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "user1" + +# 打开文件,返回fd +fd = cbd.Open("/tmp1", user) + +# 写文件(目前读写都需要4k对齐) +cbd.Write(fd, "aaaaaaaa"*512, 0, 4096) +cbd.Write(fd, "bbbbbbbb"*512, 4096, 4096) + +# 读文件 +# 参数:四个参数分别为 +# 文件fd +# 空字符串 +# 偏移量 +# 读取数据长度 +# 返回值:读取成功返回读取数据,否则返回错误码 + +# 读取的内容通过返回值返回,buf在此没有意义,可以传入一个空串 +cbd.Read(fd,"", 0, 4096) + +# 关闭文件 +cbd.Close(fd) +``` + +备注:当前python api接口,不支持异步读写 + +#### 删除文件 + +```python +# 参数:两个参数分别为 +# 文件名 +# 用户信息 +# 返回值:删除成功返回0,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "curve" + +# 删除文件 +cbd.Unlink("/curve", user) +``` +#### 恢复文件 + +```python +# 参数:三个参数分别为 +# 文件名 +# 用户信息 +# 文件id(可选,默认为0) +# 返回值:恢复成功返回0,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "curve" + +# 恢复文件 +cbd.Recover("/curve", user, 0) +``` + +#### 重命名文件 + +```python +# 参数:三个参数分别为 +# 用户信息 +# 旧文件名 +# 新文件名 +# 返回值:成功返回0,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "curve" + +# 重命名 +cbd.Rename(user, "/curve", "/curve-new") +``` + +#### 创建目录 + +```python +# 参数:两个参数分别为 +# 目录路径 +# 用户信息 +# 返回值:成功返回0,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "curve" +# 创建目录 +cbd.Mkdir("/curvedir", user) +``` + +#### 删除目录 + +```python +# 参数:两个参数分别为 +# 目录路径 +# 用户信息 +# 返回值:成功返回0,否则返回错误码 + +# 构造user信息 +user = curvefs.UserInfo_t() +user.owner = "curve" + +# 删除目录 +cbd.Rmdir("/curvedir", user) +``` + +#### 获取目录下的文件 + +```python +# 参数:两个参数分别为 +# 目录路径 +# 用户信息 +# 返回值:当前目录下的文件列表(只包括文件名) +files = cbd.Listdir("/test", user) +for f in files: + print f +``` + +#### 获取集群ID + +```python +# 通过返回值判断是否获取成功 +# 成功返回集群id字符串 +# 失败返回空字符串 +clusterId = cbd.GetClusterId() +print clusterId +# c355675a-f4d2-4729-b80a-5a7bcc749d1c +``` + +#### 清理CBDClient对象 + +```python +cbd.UnInit() +``` + +### 错误码 + +| Code | Message | 描述 | +| :--: | :-------------------------- | ------------------------ | +| 0 | OK | 操作成功 | +| -1 | EXISTS | 文件或目录已存存在 | +| -2 | FAILED | 操作失败 | +| -3 | DISABLEDIO | 禁止IO | +| -4 | AUTHFAIL | 认证失败 | +| -5 | DELETING | 正在删除 | +| -6 | NOTEXIST | 文件不存在 | +| -7 | UNDER_SNAPSHOT | 快照中 | +| -8 | NOT_UNDERSNAPSHOT | 非快照状态 | +| -9 | DELETE_ERROR | 删除错误 | +| -10 | NOT_ALLOCATE | Segment未分配 | +| -11 | NOT_SUPPORT | 操作不支持 | +| -12 | NOT_EMPTY | 目录非空 | +| -13 | NO_SHRINK_BIGGER_FILE | 禁止缩容 | +| -14 | SESSION_NOTEXISTS | Session不存在 | +| -15 | FILE_OCCUPIED | 文件被占用 | +| -16 | PARAM_ERROR | 参数错误 | +| -17 | INTERNAL_ERROR | 内部错误 | +| -18 | CRC_ERROR | CRC检查错误 | +| -19 | INVALID_REQUEST | 请求参数存在异常 | +| -20 | DISK_FAIL | 磁盘异常 | +| -21 | NO_SPACE | 空间不足 | +| -22 | NOT_ALIGNED | IO未对齐 | +| -23 | BAD_FD | 文件正在被关闭,fd不可用 | +| -24 | LENGTH_NOT_SUPPORT | 文件长度不满足要求 | +| -25 | SESSION_NOT_EXIST | Session不存在(与-14重复) | +| -26 | STATUS_NOT_MATCH | 状态异常 | +| -27 | DELETE_BEING_CLONED | 删除文件正在被克隆 | +| -28 | CLIENT_NOT_SUPPORT_SNAPSHOT | Client版本不支持快照 | +| -29 | SNAPSHOT_FROZEN | Snapshot功能禁用中 | +| -100 | UNKNOWN | 未知错误 | + diff --git a/docs/cn/curve_ops_tool.md b/docs/cn/curve_ops_tool.md index 1f6e9029e0..c3621d4d78 100644 --- a/docs/cn/curve_ops_tool.md +++ b/docs/cn/curve_ops_tool.md @@ -1,3 +1,5 @@ +[English version](../en/curve_ops_tool_en.md) + ## curve_ops_tool 工具使用说明 @@ -10,13 +12,17 @@ Commands: space: 展示curve磁盘所有类型的空间,包括总的空间和已使用空间。 status: 展示集群的所有状态信息。 + cluster-status:展示整个集群状态信息。 chunkserver-status: 展示chunkserver在线状态信息。 mds-status: 展示mds状态信息。 client-status: 展示客户端状态信息。 + client-list:列出所有客户端。 etcd-status: 展示etcd状态信息。 snapshot-clone-status: 展示快照克隆服务器状态。 copysets-status: 检查所有copyset的健康状态。 chunkserver-list: 展示chunkserver列表和chunkserver信息。 + server-list : 列出所有server信息。 + logical-pool-list:列出所有逻辑池信息。 get: 展示文件信息和文件的真实空间。 list: 列出目录下所有文件的文件信息。 seginfo: 展示文件的segment信息。 @@ -28,11 +34,14 @@ Commands: remove-peer: 从copyset中移除节点。 transfer-leader: 转换copyset上的leader角色给一个节点。 reset-peer: 重置copyset配置,仅支持针对一个节点的重置。 + do-snapshot:对该节点上的copyset打快照。 + do-snapshot-all:对所有节点上的所有copyset打快照。 check-chunkserver: 检查一个chunkserver的健康状态。 check-copyset: 检查一个copyset的健康状态。 check-server: 检查一个server的健康状态。 check-operator: 检查操作者。 + list-may-broken-vol:列出所有大多数副本挂掉的卷 rapid-leader-schedule: 逻辑池中集群的快速leader调度。 - + 可以在配置文件中进行配置,避免携带太多可选项,工具默认配置文件在 /etc/curve/tools.conf,自定义路径可以通过 -confPath 来指定配置文件。 注意:显式指定的参数和-confPath指定的配置文件同时存在时,显式指定参数会覆盖配置文件参数。 \ No newline at end of file diff --git a/docs/cn/k8s_csi_interface.md b/docs/cn/k8s_csi_interface.md index d5a1a4d6d5..8d3261d8f9 100644 --- a/docs/cn/k8s_csi_interface.md +++ b/docs/cn/k8s_csi_interface.md @@ -1,3 +1,5 @@ +[English version](../en/k8s_csi_interface_en.md) + 目前,curve可以通过CSI插件的方式对接Kubernetes。本文给出的是CSI插件开发指导说明。curve csi插件源码请见[curve-csi](https://github.com/opencurve/curve-csi)。 ## Curve Interface @@ -6,6 +8,7 @@ curve提供命令行管理工具curve,用来创建、删除卷等管理操作 - 创建卷:`curve create [-h] --filename FILENAME --length LENGTH --user USER` - 删除卷:`curve delete [-h] --user USER --filename FILENAME` +- 恢复卷:`curve recover [-h] --user USER --filename FILENAME [--id ID]` - 扩容卷:`curve extend [-h] --user USER --filename FILENAME --length LENGTH` - 查询卷:`curve stat [-h] --user USER --filename FILENAME` - rename卷:`curve rename [-h] --user USER --filename FILENAME --newname NEWNAME` diff --git a/docs/cn/monitor.md b/docs/cn/monitor.md index 81b80efcc0..654a117307 100644 --- a/docs/cn/monitor.md +++ b/docs/cn/monitor.md @@ -1,3 +1,5 @@ +[English version](../en/monitor_en.md) + # 监控体系 ## 概述 @@ -22,7 +24,7 @@ CURVE 中使用到的 bvar 数据模型有: `bvar::PerSecond` : 获得某个bvar在一段时间内平均每秒的累加值。PerSecond也是会自动更新的衍生变量。 -`bvar::LatencyRecorder` : 专用于记录延时和qps的变量。输入延时,平均延时/最大延时/qps/总次数 都有了。 +`bvar::LatencyRecorder` : 专用于记录延时和qps的变量。输入延时,平均延时/最大延时/qps/总次数都有了。 CURVE 中 bvar 的具体使用方式可以查看: diff --git a/docs/en/curve-client-python-api_en.md b/docs/en/curve-client-python-api_en.md new file mode 100644 index 0000000000..3a4baf3798 --- /dev/null +++ b/docs/en/curve-client-python-api_en.md @@ -0,0 +1,321 @@ +[中文版](../cn/curve-client-python-api.md) + +#### Get a CBDClient object that interacts with the Curve cluster + +```python +import curvefs + +# Get a CBDClient object that interacts with the back-end cluster. Different CBDClient objects can establish connections with different clusters +cbd1 = curvefs.CBDClient() +cbd2 = curvefs.CBDClient() +``` + +#### CBDClient initialization + +```python +import curvefs +cbd = curvefs.CBDClient() + +# parameter: full path of curve-client configuration file +# return: return 0 if initialized successfully, -1 means failed +cbd.Init("/etc/curve/client.conf") +``` + +#### Create file + +```python +import curvefs +cbd = curvefs.CBDClient() +cbd.Init("/etc/curve/client.conf") # subsequent examples omit the initialization process + +# parameter: the three parameters are +# file full path +# user information +# file size +# return: return 0 if create successfully, otherwise return an error code + +# First initialize user information (the control plane interfaces of curvefs have user information verification, and user information needs to be passed in) +user = curvefs.UserInfo_t() +user.owner = "curve" +user.password = "" # when the password is empty, it can be omitted + +# Create a file with Create interface +cbd.Create("/curve", user, 10*1024*1024*1024) + +# UserInfo definition +typedef struct UserInfo { + char owner[256]; # username + char password[256]; # password +} UserInfo_t; +``` + +#### Get file information + +```python +# parameter: the three parameters are +# filename +# user information +# fileInfo[exit parameter] +# return: return 0 if get successfully, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "curve" + +# Construct file information +finfo = curvefs.FileInfo_t() + +# Get file information +cbd.StatFile("/curve", user, finfo) +print finfo.filetype +print finfo.length +print finfo.ctime + +# FileInfo definition +typedef struct FileInfo { + uint64_t id; + uint64_t parentid; + int filetype; # volume type + uint64_t length; # volume size + uint64_t ctime; # volume create time + char filename[256]; # volume name + char owner[256]; # volume owner + int fileStatus; # volume status +} FileInfo_t; + +# File status +#define CURVE_FILE_CREATED 0 +#define CURVE_FILE_DELETING 1 +#define CURVE_FILE_CLONING 2 +#define CURVE_FILE_CLONEMETAINSTALLED 3 +#define CURVE_FILE_CLONED 4 +#define CURVE_FILE_BEINGCLONED 5 +``` + +#### Extend file + +```python +# parameter: the three parameters are +# filename +# user information +# file size after extend +# return: return 0 if extend successfully, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "curve" + +# Extend +cbd.Extend("/curve", user, 20*1024*1024*1024) + +# Get file information after extension +finfo = curvefs.FileInfo_t() +cbd.StatFile("/curve", user, finfo) +print finfo.length +``` + +#### Open/Close file + +```python +# Open file +# parameter: the two parameters are +# filename +# user information +# return: return fd if open successfully, otherwise return error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "user1" + +# Open file,return fd +fd = cbd.Open("/tmp1", user) + +# Close file +# parameter: fd returned when opening the file +# return: return 0 if closed successfully, otherwise return an error code +cbd.Close(fd) +``` + +#### Read and write file + +```python +# Write file +# parameter: the four parameters are +# fd +# data to write +# offset +# date length +# return: return the number of bytes written If write successful, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "user1" + +# Open file,return fd +fd = cbd.Open("/tmp1", user) + +# Write files (Currently, 4k alignment is required for reading and writing) +cbd.Write(fd, "aaaaaaaa"*512, 0, 4096) +cbd.Write(fd, "bbbbbbbb"*512, 4096, 4096) + +# Read file +# parameter: the four parameters are +# fd +# null string +# offset +# data length to read +# return: return read data if read successfully, otherwise return an error code + +# The read content is returned by the return value, buf is not needed, you can pass in an empty string +cbd.Read(fd,"", 0, 4096) + +# Close file +cbd.Close(fd) +``` + +Note: The current python api does not support asynchronous reading and writing + +#### Delete file + +```python +# parameter: the two parameters are +# filename +# user information +# return: return 0 if delete successfully, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "curve" + +# Delete file +cbd.Unlink("/curve", user) +``` +#### Recover file + +```python +# parameter: the three parameters are +# filename +# user information +# file id (optional, default is 0) +# return: return 0 if recover successfully, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "curve" + +# Recover file +cbd.Recover("/curve", user, 0) +``` + +#### Rename file + +```python +# parameter: the three parameters are +# user information +# old filename +# new filename +# return: return 0 if rename successfully, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "curve" + +# Rename +cbd.Rename(user, "/curve", "/curve-new") +``` + +#### Create a directory + +```python +# parameter: the two parameters are +# directory path +# user information +# return: return 0 if create successfully, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "curve" +# Create directory +cbd.Mkdir("/curvedir", user) +``` + +#### Delete directory + +```python +# parameter: the two parameters are +# directory path +# user information +# return: return 0 if create successfully, otherwise return an error code + +# Construct user information +user = curvefs.UserInfo_t() +user.owner = "curve" + +# Delete directory +cbd.Rmdir("/curvedir", user) +``` + +#### List the files in the directory + +```python +# parameter: the two parameters are +# directory path +# user information +# return: files in the directory (only filename) +files = cbd.Listdir("/test", user) +for f in files: + print f +``` + +#### Get the cluster ID + +```python +# Determine whether this get is successful by the return value +# success: return cluster ID +# fail: return null string +clusterId = cbd.GetClusterId() +print clusterId +# c355675a-f4d2-4729-b80a-5a7bcc749d1c +``` + +#### Clean CBDClient object + +```python +cbd.UnInit() +``` + +### Error code + +| Code | Message | description | +| :--: | :-------------------------- | ------------------------ | +| 0 | OK | success | +| -1 | EXISTS | file or directory exists | +| -2 | FAILED | fail | +| -3 | DISABLEDIO | disable io | +| -4 | AUTHFAIL | authentication failed | +| -5 | DELETING | deleting | +| -6 | NOTEXIST | file not exist | +| -7 | UNDER_SNAPSHOT | under snapshot | +| -8 | NOT_UNDERSNAPSHOT | not under snapshot | +| -9 | DELETE_ERROR | delete error | +| -10 | NOT_ALLOCATE | segment not allocated | +| -11 | NOT_SUPPORT | operation not supported | +| -12 | NOT_EMPTY | directory not empty | +| -13 | NO_SHRINK_BIGGER_FILE | no shrinkage | +| -14 | SESSION_NOTEXISTS | session not exist | +| -15 | FILE_OCCUPIED | file occupied | +| -16 | PARAM_ERROR | parameter error | +| -17 | INTERNAL_ERROR | internal error | +| -18 | CRC_ERROR | CRC error | +| -19 | INVALID_REQUEST | parameter invalid | +| -20 | DISK_FAIL | disk fail | +| -21 | NO_SPACE | no space | +| -22 | NOT_ALIGNED | io not aligned | +| -23 | BAD_FD | file is being closed, fd unavailable | +| -24 | LENGTH_NOT_SUPPORT | file length is not supported | +| -25 | SESSION_NOT_EXIST | session not exist, duplicate with -14 | +| -26 | STATUS_NOT_MATCH | status error | +| -27 | DELETE_BEING_CLONED | delete the file being cloned | +| -28 | CLIENT_NOT_SUPPORT_SNAPSHOT | this version of client not support snapshot | +| -29 | SNAPSHOT_FROZEN | snapshot is disabled | +| -100 | UNKNOWN | unknown error | diff --git a/docs/en/curve_ops_tool_en.md b/docs/en/curve_ops_tool_en.md new file mode 100644 index 0000000000..af3d64c9da --- /dev/null +++ b/docs/en/curve_ops_tool_en.md @@ -0,0 +1,47 @@ +[中文版](../cn/curve_ops_tool.md) + + + +## curve_ops_tool help + +Usage: curve_ops_tool [Command] [OPTIONS...] + +show command example : curve_ops_tool space --example + +Commands: + + space : show curve all disk type space, include total space and used space + status : show the total status of the cluster + cluster-status : show cluster status + chunkserver-status : show the chunkserver online status + mds-status : show the mds status + client-status : show the client status + client-list : list all client + etcd-status : show the etcd status + snapshot-clone-status : show the snapshot clone server status + copysets-status : check the health state of all copysets + chunkserver-list : show curve chunkserver-list, list all chunkserver information + server-list : list all server information + logical-pool-list : list all logical pool information + get : show the file info and the actual space of file + list : list the file info of files in the directory + seginfo : list the segments info of the file + delete : delete the file, to force delete, should specify the --forcedelete=true + clean-recycle : clean the RecycleBin + create : create file, file length unit is GB + chunk-location : query the location of the chunk corresponding to the offset + check-consistency : check the consistency of three copies + remove-peer : remove the peer from the copyset + transfer-leader : transfer the leader of the copyset to the peer + reset-peer : reset the configuration of copyset, only reset to one peer is supported + do-snapshot : do snapshot of the peer of the copyset + do-snapshot-all : do snapshot of all peers of all copysets + check-chunkserver : check the health state of the chunkserver + check-copyset : check the health state of one copyset + check-server : check the health state of the server + check-operator : check the operators + list-may-broken-vol: list all volumes on majority offline copysets + rapid-leader-schedule: rapid leader schedule in cluster in logicalpool + + It can be configured in the configuration file to avoid carrying too many options. The default configuration file of the tool is /etc/curve/tools.conf, and the custom path can be specified by -confPath. + Note: When the explicitly specified parameters and the configuration file specified by -confPath exist at the same time, the explicitly specified parameters will overwrite the configuration file parameters. diff --git a/docs/en/k8s_csi_interface_en.md b/docs/en/k8s_csi_interface_en.md new file mode 100644 index 0000000000..6ff2703268 --- /dev/null +++ b/docs/en/k8s_csi_interface_en.md @@ -0,0 +1,91 @@ +[中文版](../cn/k8s_csi_interface.md) + +Currently, Curve can be connected to Kubernetes through the CSI plugin. This article gives instructions on the development of CSI plugin. For the source code of the Curve CSI plugin, please see [curve-csi](https://github.com/opencurve/curve-csi). + +## Curve Interface + +Curve provides a command line management tool curve, which is used to create and delete volumes and other management operations. The specific interface is as follows: + +- create volume: `curve create [-h] --filename FILENAME --length LENGTH --user USER` +- delete volume: `curve delete [-h] --user USER --filename FILENAME` +- recover volume: `curve recover [-h] --user USER --filename FILENAME [--id ID]` +- extend volume: `curve extend [-h] --user USER --filename FILENAME --length LENGTH` +- get volume info: `curve stat [-h] --user USER --filename FILENAME` +- rename volume: `curve rename [-h] --user USER --filename FILENAME --newname NEWNAME` +- create directory: `curve mkdir [-h] --user USER --dirname DIRNAME` +- delete directory: `curve rmdir [-h] --user USER --dirname DIRNAME` +- list files in the directory:`curve list [-h] --user USER --dirname DIRNAME` + +Provide curve-nbd tool to map, unmap, list on node: + +```bash +Usage: curve-nbd [options] map (Map an image to nbd device) + unmap (Unmap nbd device) + list-mapped (List mapped nbd devices) +Map options: +--device Specify nbd device path (/dev/nbd{num}) +--read-only Map read-only +--nbds_max Override for module param nbds_max +--max_part Override for module param max_part +--timeout Set nbd request timeout +--try-netlink Use the nbd netlink interface +``` + +## Implementing with Kubernetes CSI + +CSI spec: + +``` + CreateVolume +------------+ DeleteVolume + +------------->| CREATED +--------------+ + | +---+----^---+ | + | Controller | | Controller v ++++ Publish | | Unpublish +++ +|X| Volume | | Volume | | ++-+ +---v----+---+ +-+ + | NODE_READY | + +---+----^---+ + Node | | Node + Stage | | Unstage + Volume | | Volume + +---v----+---+ + | VOL_READY | + +---+----^---+ + Node | | Node + Publish | | Unpublish + Volume | | Volume + +---v----+---+ + | PUBLISHED | + +------------+ +``` + +In CSI plugin: + +- CreateVolume: + - curve mkdir: DIRNAME defined in `k8s storageClass` + - curve create: FILENAME is `k8s persistentVolume name` + - curve stat: wait volume ready +- Controller Publish Volume: + - Nothing to do +- Node Stage Volume: + - curve-nbd list-mapped: check if it has been mounted + - curve-nbd map: mount +- Node Publish Volume: + - mount the stagePath to the publishPath +- Node Unpublish Volume: + - umount publishPath +- Node Unstage Volume: + - curve-nbd list-mapped: check if it has been umounted + - curve-nbd unmap: umount +- Controller Unpublish Volume: + - Nothing to do +- DeleteVolume: + - curve delete + +Other optional support: + +- Extend: + - ControllerExpandVolume: curve extend + - NodeExpandVolume: resize2fs/xfs_growfs + +- Snapshot: not yet supported diff --git a/docs/en/monitor_en.md b/docs/en/monitor_en.md new file mode 100644 index 0000000000..a5b606d751 --- /dev/null +++ b/docs/en/monitor_en.md @@ -0,0 +1,68 @@ +[中文版](../cn/monitor.md) + +# Monitoring System + +## Overview + +CURVE monitoring system includes three aspects: indicators collection, indicators storage, and indicators display. For indicators collection, use [brpc](https://github.com/apache/incubator-brpc) built-in [bvar](https://github.com/apache/incubator-brpc/blob/master/docs/en/bvar.md); the open source monitoring system [prometheus](https://prometheus.io/docs/introduction/overview/) is used for indicators storage; [grafana](https://github.com/grafana/grafana) is used for indicators display. + +## bvar + +[bvar](https://github.com/apache/incubator-brpc/blob/master/docs/en/bvar.md) is a counter library in a multi-threaded environment, which is convenient for recording and viewing various types of user numerical value in program. bvar data can be exported and queried via web portal on the port of the brpc server service, also can view historical trends, statistics and quantile values; bvar also has a built-in prometheus conversion module to convert collected indicators into a format supported by prometheus. + +The bvar data models used in CURVE are: + +`bvar::Adder` : counter,default 0,varname << N is equivalent to varname += N. + +`bvar::Maxer` : maximum value,default std::numeric_limits::min(),varname << N is equivalent to varname = max(varname, N). + +`bvar::Miner` : minimum value,default std::numeric_limits::max(),varname << N is equivalent to varname = min(varname, N). + +`bvar::IntRecorder` : the average value since use. Note that the attributive here is not "in a period of time". Generally, the average value in the time window is derived through Window. + +`bvar::Window`: the accumulated value of a bvar in a period of time. Window is derived from the existing bvar and will be updated automatically. + +`bvar::PerSecond`: the average accumulated value of a bvar per second in a period of time. PerSecond is also a derivative variable that is automatically updated. + +`bvar::LatencyRecorder`: to recording latency and qps. Input delay, average delay/maximum delay/qps/total times are all available. + +The specific usage of bvar in CURVE can be viewed: + +[client metric](../../src/client/client_metric.h) + +[chunkserver metric](../../src/chunkserver/chunkserver_metrics.h) + +[mds topoloy metric](../../src/mds/topology/topology_metric.h) + +[mds shedule metric](../../src/mds/schedule/scheduleMetrics.h) + +## prometheus + grafana + +CURVE cluster monitoring uses Prometheus to collect data and Grafana to display. + +Monitoring content includes: Client, Mds, Chunkserver, Etcd, and machine nodes. + +The configuration of the monitoring target uses the prometheus file-based service automatic discovery function. The monitoring component is deployed in docker and docker-compose is used for orchestration. The deployment related scripts are in the [CURVE warehouse](../../monitor). + +monitor + +1. ```Promethethus``` regularly pulls corresponding data from Brpc Server in MDS, ETCD, Snapshotcloneserver, ChunkServer, and Client. + +2. ```docker compose``` is used to orchestrate the configuration of docker components, including Promethues, Grafana and Repoter. + +3. ```python``` scripts. [target_json.py](../../monitor/target_json.py) is used to generate the monitoring target configuration that prometheus service discovery depends on. The generated file is in json format and the script depends on [target.ini](../. ./monitor/target.ini.example) to obtain mds, etcd information from the configuration. [grafana-report.py](../../monitor/grafana-report.py) is used to export the data information required by the daily reporter from Grafana. + +## Renderings Show + +##### Grafana renderings + +monitor + +monitor + +monitor + +##### Daily Report renderings + +monitor +