项目作者: Difrex

项目描述 :
RBD mount wrapper cluster
高级语言: Go
项目地址: git://github.com/Difrex/rbmd.git
创建时间: 2017-01-20T13:21:15Z
项目社区:https://github.com/Difrex/rbmd

开源协议:GNU General Public License v3.0

下载


RBMD

Build Status

logo

RBDM is a rbd mount cluster. It can check already mounted images and prevent creating another block device.

It’s can map/unmap and mount/umount.

ALLOW FOR STAGING

Current status: development, testing

ALLOW FOR STAGING

Table of Contents

Dependencies

  • Zookeeper
  • Access to ceph cluster(for map/unmap images)

Usage

  1. Usage of ./rbmd:
  2. -listen string
  3. HTTP API listen address (default "127.0.0.1:9076")
  4. -tick int
  5. Tick time loop (default 5)
  6. -version
  7. Show version info and exit
  8. -ws string
  9. Websockets listen address (default "127.0.0.1:7690")
  10. -zk string
  11. Zookeeper servers comma separated (default "127.0.0.1:2181")
  12. -zkPath string
  13. Zookeeper path (default "/rbmd")

Example

./rbmd -listen 127.0.0.1:9908 -zkPath /rbmd-ru-dc3-rack5

Build

Run build.sh script. It’s required docker.

API

GET /v1/status

Return JSON of quorum status

Example

  1. {
  2. "quorum": {
  3. "node.example.com": {
  4. "node": "node.example.com",
  5. "ip": {
  6. "v4": [
  7. "10.0.3.1"
  8. ],
  9. "v6": [
  10. "fe80::f869:d0ff:fea3:3c0a"
  11. ]
  12. },
  13. "updated": 1483428452,
  14. "mounts": null
  15. }
  16. },
  17. "health": "alive.",
  18. "leader": "node.example.com"
  19. }

GET /v1/node

Return JSON of node stats

Example

  1. {
  2. "node": "node.example.com",
  3. "ip": {
  4. "v4": [
  5. "169.254.156.1"
  6. ],
  7. "v6": [
  8. "fe80::108d:fcff:fe77:3df6"
  9. ]
  10. },
  11. "updated": 1483095493,
  12. "mounts": null
  13. }

GET /v1/health

Return string with quorum health check result

Statuses:

  • alive. Match regexp: ^alive\.$ — all is good
  • 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

Example

  1. curl 127.0.0.1:9076/health
  2. alive.

POST /v1/mount

Map rbd image and mount it

Allowed mount options:

  • ro
  • noatime
  • relatime
  • nosuid
  • noexec
  • nodiratime

Example

Accept JSON

  1. {
  2. "node": "node.example.com",
  3. "pool": "web",
  4. "image": "pictures",
  5. "mountpoint": "/var/www/pictures",
  6. "mountopts": "noatime,nodiratime",
  7. "fstype": "xfs"
  8. }

Return JSON.

On success

  1. {
  2. "state": "OK",
  3. "message": "OK"
  4. }

On failure

  1. {
  2. "state": "FAIL",
  3. "message": "mount: /dev/null not a block device"
  4. }

POST /v1/umount

Unmount filesystem and unmap RBD device

Example

Accept JSON

  1. {
  2. "node": "node.example.com",
  3. "mountpoint": "/var/www/pictures",
  4. "block": "rbd0"
  5. }

Return JSON.

On success

  1. {
  2. "state": "OK",
  3. "message": "OK"
  4. }

On failure

  1. {
  2. "state": "FAIL",
  3. "message": "Not found"
  4. }

POST /v1/resolve

Remove deadly node from quorum.

Example

Accept JSON

  1. {
  2. "node": "node.example.com"
  3. }

GET /v1/metrics

Return some metrics

Example

  1. {
  2. "goroutines": 9,
  3. "nodes": 2,
  4. "mountstotal": 0,
  5. "cgocall": 1
  6. }

Systemd

Example unit

  1. [Unit]
  2. Description=RBMD
  3. After=network.target
  4. [Service]
  5. ExecStart=/usr/bin/rbmd -listen 0.0.0.0:9076 -ws 0.0.0.0:7690 -zk node1:2181,node2:2181,node3:2181
  6. KillMode=control-group
  7. Restart=on-failure
  8. [Install]
  9. WantedBy=multi-user.target

Troubleshooting

Umount request is stuck after deadly.

Remove Zk node /rbmd/cluster/node.fqdn/requests/umount

AUTHORS

Denis Zheleztsov difrex.punk@gmail.com

LICENSE

GPL version 3 see LICENSE