作者: 石文
时间:2019-01-13
Heketi是一个GlusterFs管理软件,可以管理glusterFS集群的卷创建、删除等操作。
Heketi管理GlusterFS集群需要注意:
GlusterFS集群的各peer必须要有未安装文件系统的磁盘设备(磁盘设备未进行格式化)
GlusterFS集群各peer的端口号不能太少,不然当peer上的brick将端口号用完后,会造成无法创建卷
GlusterFS的各peer不能组成集群,Heketi可以自创建集群组合。
Heketi安装步骤:
使用rpm包安装:
rpm -ivh heketi-7.0.0-1.el7.x86_64.rpm
配置文件:
配置文件位置:/etc/heketi/heketi.json
配置文件示例:
{
#默认端口8080
"port": "8088",
#不需要密码
"use_auth": false,
#glusterfs集群配置信息
"glusterfs": {
"executor": "ssh",
"sshexec": {
"keyfile": "/etc/heketi/heketi_key",
"user": "root"
},
"db": "/heketidb/heketi.db",
"loglevel" : "debug"
}
}
检查是否正常运行,执行如下命令:
curl http://localhost:8088/hello
返回值正常:
Hello from Heketi
Heketi和GlusterFS各节点配置信赖关系
注意:就是配置Heketi免密登录GlusterFS集群各节点,当Heketi配置文件的<“glusterfs”>键如此写时,可以使用如下方式进行配置免密登录
"glusterfs": {
"executor": "ssh",
"sshexec": {
"keyfile": "/etc/heketi/heketi_key",
"user": "root"
},
"db": "/heketidb/heketi.db",
"loglevel" : "debug"
}
创建目录/etc/heketi(也可以不创建,任意目录都行)
mkdir /etc/heketi
生成heketi秘钥对
ssh-keygen -f /etc/heketi/heketi_key -t rsa -N ''
通过heketi-client 向Heketi导入GlusterFS集群信息
安装heketi-client:
使用rpm安装
rpm -ivh /export/servers/heketi-client-7.0.0-1.el7.x86_64.rpm
配置配置文件:/etc/heketi/topology.json(文件需要提前创建)
{
"clusters": [
{
"nodes": [
{
"node": {
"hostnames": {
"manage": [
"1.1.1.6"
],
"storage": [
"1.1.1.6"
]
},
"zone": 1
},
"devices": [
"/dev/sdb"
]
},
{
"node": {
"hostnames": {
"manage": [
"1.1.1.7"
],
"storage": [
"1.1.1.7"
]
},
"zone": 1
},
"devices": [
"/dev/sdb"
]
},
{
"node": {
"hostnames": {
"manage": [
"1.1.1.8"
],
"storage": [
"1.1.1.8"
]
},
#配置机柜感知
"zone": 1
},
"devices": [
"/dev/sdb"
]
}
]
}
]
}
向heketi发送GlusterFS集群信息
heketi-cli --server http://localhost:8088 topology load --json=/etc/heketi/topology.json
如何给集群扩容?
使用Heketi管理GlusterFS集群
heketi-cli --server http://localhost:8088 setup-openshift-heketi-storage
#集群列表
heketi-cli --server http://localhost:8088 cluster list
#集群详细信息
heketi-cli --server http://localhost:8088 cluster info <cluster ID>
#节点信息
heketi-cli --server http://localhost:8088 node info <node ID>
#卷信息
heketi-cli --server http://localhost:8088 volume list
#heketi支持如下命令
heketi-cli --server http://localhost:8088 -h
blockvolume Heketi Volume Management
cluster Heketi cluster management
db Heketi Database Management
device Heketi device management
help Help about any command
loglevel Heketi Log Level
node Heketi Node Management
setup-openshift-heketi-storage Setup OpenShift/Kubernetes persistent storage for Heketi
topology Heketi Topology Management
volume Heketi Volume Management
#集群相关命令
heketi-cli --server http://localhost:8088 cluster -h
create Create a cluster
delete Delete the cluster
info Retrieves information about cluster
list Lists the clusters managed by Heketi
setflags Set flags on a cluster
#节点相关命令
heketi-cli --server http://localhost:8088 node -h
add Add new node to be managed by Heketi
delete Deletes a node from Heketi management
disable Disallow usage of a node by placing it offline
enable Allows node to go online
info Retrieves information about the node
list List all nodes in cluster
remove Removes a node and all its associated devices from Heketi
rmtags Removes tags from a node
settags Sets tags on a node
#卷相关命令
heketi-cli --server http://localhost:8088 volume -h
clone Creates a clone
create Create a GlusterFS volume
delete Deletes the volume
expand Expand a volume
info Retrieves information about the volume
list Lists the volumes managed by Heketi
其他的命令可以通过<-h>查看详细使用方式
实际部署中遇到的问题
#heketi-cli topology load --json=topology-sample.json
Creating cluster ... ID: 5b930ef6081fd22e895c25a3dfb0c516
Allowing file volumes on cluster.
Allowing block volumes on cluster.
Creating node 10.30.1.15 ... ID: b120572be40db6c1d979c3903876430b
Adding device /dev/sdb ... OK
Creating node 10.30.1.16 ... ID: 7ce13ffc5eabe64a3791e93233fd3c1a
Adding device /dev/sdb ... OK
Creating node 10.30.1.17 ... ID: f9abdc2e5d4cfa17c035a97f984a1a3b
Adding device /dev/sdb ... OK
当磁盘文件系统已经存在时的错误日志
[root@10-211-105-109 heketi]# heketi-cli --server http://localhost:8088 topology load --json=/etc/heketi/topology.json
Creating node 10.211.105.200 ... ID: 6c0476a0b495bc67c2e6b181ca2f0813
Adding device /dev/sda5 ... Unable to add device: Can't open /dev/sda5 exclusively. Mounted filesystem?
当节点是已经位于其他集群中时的报错
[root@10-211-105-109 heketi]# heketi-cli --server http://localhost:8088 topology load --json=/etc/heketi/topology.json
Creating node 10.211.106.9 ... Unable to create node: peer probe: failed: 10.211.106.9 is either already part of another cluster or having volumes configured
当使用heketi创建卷时,创建失败后会怎样
heketi记录的节点空间会减少,并且无法释放。也看不到卷信息。最终的结果是节点空间显示使用了很多,但是看不到任何的使用情况。这会不会是一个BUG?
参考资料:
https://github.com/heketi/heketi/blob/master/docs/admin/topology.md