2017-01-10 09:56:09 +03:00
|
|
|
# RBMD
|
|
|
|
|
2017-01-24 10:06:32 +03:00
|
|
|
[![Build Status](https://travis-ci.org/Difrex/rbmd.svg?branch=master)](https://travis-ci.org/Difrex/rbmd)
|
|
|
|
|
2017-09-04 13:40:30 +03:00
|
|
|
![logo](/img/logo.png)
|
|
|
|
|
2016-12-30 14:26:41 +03:00
|
|
|
RBD mount wrapper cluster
|
|
|
|
|
2017-09-01 11:49:33 +03:00
|
|
|
**ALLOW FOR STAGING**
|
2017-01-12 14:55:32 +03:00
|
|
|
|
|
|
|
Current status: *development*, *testing*
|
|
|
|
|
2017-09-01 11:49:33 +03:00
|
|
|
**ALLOW FOR STAGING**
|
2017-01-12 14:55:32 +03:00
|
|
|
|
2016-12-30 14:26:41 +03:00
|
|
|
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
|
|
|
|
**Table of Contents**
|
|
|
|
|
2017-01-10 09:56:09 +03:00
|
|
|
- [RBMD](#rbmd)
|
|
|
|
- [Dependencies](#dependencies)
|
|
|
|
- [Usage](#usage)
|
|
|
|
- [Example](#example)
|
|
|
|
- [Build](#build)
|
2016-12-30 14:26:41 +03:00
|
|
|
- [API](#api)
|
2017-09-01 12:01:35 +03:00
|
|
|
- [GET /v1/status](#get-v1status)
|
2016-12-30 14:26:41 +03:00
|
|
|
- [Example](#example)
|
2017-09-01 12:01:35 +03:00
|
|
|
- [GET /v1/node](#get-v1node)
|
2016-12-30 14:26:41 +03:00
|
|
|
- [Example](#example)
|
2017-09-01 12:01:35 +03:00
|
|
|
- [GET /v1/health](#get-v1health)
|
2016-12-30 14:26:41 +03:00
|
|
|
- [Example](#example)
|
2017-09-01 12:01:35 +03:00
|
|
|
- [POST /v1/mount](#post-v1mount)
|
2017-01-09 23:13:37 +03:00
|
|
|
- [Example](#example)
|
2017-09-01 12:01:35 +03:00
|
|
|
- [POST /v1/umount](#post-v1umount)
|
2017-01-09 23:13:37 +03:00
|
|
|
- [Example](#example)
|
2017-09-01 12:01:35 +03:00
|
|
|
- [POST /v1/resolve](#post-v1resolve)
|
2017-01-10 23:25:42 +03:00
|
|
|
- [Example](#example)
|
2017-09-01 12:01:35 +03:00
|
|
|
- [GET /v1/metrics](#get-v1metrics)
|
2017-01-13 13:29:54 +03:00
|
|
|
- [Example](#example)
|
2017-01-20 16:19:16 +03:00
|
|
|
- [Systemd](#systemd)
|
2017-09-01 11:50:30 +03:00
|
|
|
- [Troubleshooting](#troubleshooting)
|
|
|
|
- [Umount request is stuck after deadly.](#umount-request-is-stuck-after-deadly)
|
2016-12-30 14:31:53 +03:00
|
|
|
- [AUTHORS](#authors)
|
|
|
|
- [LICENSE](#license)
|
2016-12-30 14:26:41 +03:00
|
|
|
|
|
|
|
<!-- markdown-toc end -->
|
|
|
|
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
* Zookeeper
|
|
|
|
* Access to ceph cluster(for map/unmap images)
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```
|
|
|
|
Usage of ./rbmd:
|
|
|
|
-listen string
|
2017-01-13 10:34:00 +03:00
|
|
|
HTTP API listen address (default "127.0.0.1:9076")
|
2016-12-30 14:26:41 +03:00
|
|
|
-tick int
|
|
|
|
Tick time loop (default 5)
|
2017-01-13 10:34:00 +03:00
|
|
|
-version
|
|
|
|
Show version info and exit
|
2017-01-03 10:33:19 +03:00
|
|
|
-ws string
|
2017-01-13 10:34:00 +03:00
|
|
|
Websockets listen address (default "127.0.0.1:7690")
|
2016-12-30 14:26:41 +03:00
|
|
|
-zk string
|
|
|
|
Zookeeper servers comma separated (default "127.0.0.1:2181")
|
|
|
|
-zkPath string
|
|
|
|
Zookeeper path (default "/rbmd")
|
|
|
|
```
|
|
|
|
|
|
|
|
### Example
|
|
|
|
|
|
|
|
```./rbmd -listen 127.0.0.1:9908 -zkPath /rbmd-ru-dc3-rack5```
|
|
|
|
|
2017-01-10 09:55:09 +03:00
|
|
|
## Build
|
|
|
|
|
|
|
|
Required Go > 1.6
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone https://github.com/rbmd/rbmd.git && cd rbmd
|
2017-01-31 15:37:32 +03:00
|
|
|
GOPATH=$(pwd) go get -t -v ./...
|
2017-01-10 09:55:09 +03:00
|
|
|
GOPATH=$(pwd) go build
|
|
|
|
```
|
|
|
|
|
2016-12-30 14:26:41 +03:00
|
|
|
## API
|
|
|
|
|
2017-09-01 12:01:35 +03:00
|
|
|
### GET /v1/status
|
2016-12-30 14:26:41 +03:00
|
|
|
|
|
|
|
Return JSON of quorum status
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2016-12-30 14:26:41 +03:00
|
|
|
{
|
2017-01-03 10:33:19 +03:00
|
|
|
"quorum": {
|
|
|
|
"node.example.com": {
|
|
|
|
"node": "node.example.com",
|
2016-12-30 14:26:41 +03:00
|
|
|
"ip": {
|
|
|
|
"v4": [
|
|
|
|
"10.0.3.1"
|
|
|
|
],
|
|
|
|
"v6": [
|
2017-01-03 10:33:19 +03:00
|
|
|
"fe80::f869:d0ff:fea3:3c0a"
|
2016-12-30 14:26:41 +03:00
|
|
|
]
|
|
|
|
},
|
2017-01-03 10:33:19 +03:00
|
|
|
"updated": 1483428452,
|
2016-12-30 14:26:41 +03:00
|
|
|
"mounts": null
|
|
|
|
}
|
2017-01-03 10:33:19 +03:00
|
|
|
},
|
|
|
|
"health": "alive.",
|
|
|
|
"leader": "node.example.com"
|
2016-12-30 14:26:41 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-09-01 12:01:35 +03:00
|
|
|
### GET /v1/node
|
2016-12-30 14:26:41 +03:00
|
|
|
|
|
|
|
Return JSON of node stats
|
|
|
|
|
|
|
|
#### Example
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2016-12-30 14:26:41 +03:00
|
|
|
{
|
2017-09-01 12:21:59 +03:00
|
|
|
"node": "node.example.com",
|
2016-12-30 14:26:41 +03:00
|
|
|
"ip": {
|
|
|
|
"v4": [
|
|
|
|
"169.254.156.1"
|
|
|
|
],
|
|
|
|
"v6": [
|
|
|
|
"fe80::108d:fcff:fe77:3df6"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"updated": 1483095493,
|
|
|
|
"mounts": null
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-09-01 12:01:35 +03:00
|
|
|
### GET /v1/health
|
2016-12-30 14:26:41 +03:00
|
|
|
|
|
|
|
Return string with quorum health check result
|
|
|
|
|
2016-12-30 14:55:42 +03:00
|
|
|
Statuses:
|
2016-12-30 15:05:20 +03:00
|
|
|
* alive. Match regexp: ```^alive\.$``` -- all is good
|
2017-01-10 10:05:21 +03:00
|
|
|
* resizing. Match regexp: ```^resizing\.$``` -- One or more nodes goind down
|
|
|
|
* deadly. Match regexp: ```^deadly\.$``` -- One or more nodes is down and they has mapped images
|
2016-12-30 14:55:42 +03:00
|
|
|
|
|
|
|
|
2016-12-30 14:26:41 +03:00
|
|
|
#### Example
|
|
|
|
```
|
|
|
|
curl 127.0.0.1:9076/health
|
|
|
|
alive.
|
|
|
|
```
|
|
|
|
|
2017-09-01 12:01:35 +03:00
|
|
|
### POST /v1/mount
|
2016-12-30 14:26:41 +03:00
|
|
|
|
2017-01-03 21:37:20 +03:00
|
|
|
Map rbd image and mount it
|
|
|
|
|
2017-01-12 16:34:40 +03:00
|
|
|
Allowed mount options:
|
|
|
|
* ro
|
|
|
|
* noatime
|
|
|
|
* relatime
|
|
|
|
* nosuid
|
|
|
|
* noexec
|
|
|
|
* nodiratime
|
|
|
|
|
2017-01-03 21:37:20 +03:00
|
|
|
#### Example
|
|
|
|
|
|
|
|
Accept JSON
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2017-01-03 21:37:20 +03:00
|
|
|
{
|
|
|
|
"node": "node.example.com",
|
|
|
|
"pool": "web",
|
2017-01-04 16:59:43 +03:00
|
|
|
"image": "pictures",
|
2017-01-03 21:37:20 +03:00
|
|
|
"mountpoint": "/var/www/pictures",
|
|
|
|
"mountopts": "noatime,nodiratime",
|
|
|
|
"fstype": "xfs"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Return JSON.
|
|
|
|
|
|
|
|
On success
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2017-01-03 21:37:20 +03:00
|
|
|
{
|
|
|
|
"state": "OK",
|
|
|
|
"message": "OK"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
On failure
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2017-01-03 21:37:20 +03:00
|
|
|
{
|
2017-01-11 14:18:55 +03:00
|
|
|
"state": "FAIL",
|
2017-01-03 21:37:20 +03:00
|
|
|
"message": "mount: /dev/null not a block device"
|
|
|
|
}
|
|
|
|
```
|
2016-12-30 14:26:41 +03:00
|
|
|
|
2017-09-01 12:01:35 +03:00
|
|
|
### POST /v1/umount
|
2016-12-30 14:26:41 +03:00
|
|
|
|
2017-01-09 23:12:50 +03:00
|
|
|
Unmount filesystem and unmap RBD device
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
|
|
|
|
Accept JSON
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2017-01-09 23:12:50 +03:00
|
|
|
{
|
|
|
|
"node": "node.example.com",
|
|
|
|
"mountpoint": "/var/www/pictures",
|
|
|
|
"block": "rbd0"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Return JSON.
|
|
|
|
|
|
|
|
On success
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2017-01-09 23:12:50 +03:00
|
|
|
{
|
|
|
|
"state": "OK",
|
|
|
|
"message": "OK"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
On failure
|
2017-01-10 10:05:21 +03:00
|
|
|
```json
|
2017-01-09 23:12:50 +03:00
|
|
|
{
|
2017-09-01 11:49:33 +03:00
|
|
|
"state": "FAIL",
|
2017-01-09 23:12:50 +03:00
|
|
|
"message": "Not found"
|
|
|
|
}
|
|
|
|
```
|
2016-12-30 14:31:53 +03:00
|
|
|
|
2017-09-01 12:01:35 +03:00
|
|
|
### POST /v1/resolve
|
2017-01-10 23:22:44 +03:00
|
|
|
|
|
|
|
Remove deadly node from quorum.
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
|
|
|
|
Accept JSON
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"node": "node.example.com"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-09-01 12:01:35 +03:00
|
|
|
### GET /v1/metrics
|
2017-01-13 13:29:54 +03:00
|
|
|
|
|
|
|
Return some metrics
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"goroutines": 9,
|
|
|
|
"nodes": 2,
|
|
|
|
"mountstotal": 0,
|
|
|
|
"cgocall": 1
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-01-20 16:19:16 +03:00
|
|
|
## Systemd
|
|
|
|
|
|
|
|
Example unit
|
|
|
|
```ini
|
|
|
|
[Unit]
|
|
|
|
Description=RBMD
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
ExecStart=/usr/bin/rbmd -listen 0.0.0.0:9076 -ws 0.0.0.0:7690 -zk node1:2181,node2:2181,node3:2181
|
|
|
|
KillMode=control-group
|
|
|
|
Restart=on-failure
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
```
|
|
|
|
|
2017-09-01 11:49:33 +03:00
|
|
|
# Troubleshooting
|
|
|
|
|
|
|
|
## Umount request is stuck after deadly.
|
|
|
|
|
|
|
|
Remove Zk node */rbmd/cluster/node.fqdn/requests/umount*
|
|
|
|
|
2016-12-30 14:31:53 +03:00
|
|
|
# AUTHORS
|
|
|
|
|
|
|
|
Denis Zheleztsov <difrex.punk@gmail.com>
|
|
|
|
|
|
|
|
# LICENSE
|
|
|
|
|
2017-01-09 23:17:13 +03:00
|
|
|
GPL version 3 see [LICENSE](LICENSE)
|