Gluster添加自定义简单xlator的步骤
2017-11-21 15:07
357 查看
1、状况说明:
已有的gluster集群由三台机器组成,分别为: gfsmaster 172.29.41.205 gfsslave1 172.29.41.204 gfsslave2 172.29.41.203 用于测试gluster挂载的客户端 gfsclient 172.29.41.206 挂载目录为 /opt/gfsmount glusterfs源码目录:/root/Gluster/gluster
gluster volume信息:
2、编写自定义代码和Makefile文件
test.c:#ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #include "xlator.h" #endif #include <fnmatch.h> #include <errno.h> #include "glusterfs.h" #include "xlator.h" #include <stdarg.h> #include "defaults.h" #include "logging.h" int test_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf, dict_t *xdata, struct iatt *postparent) { STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf, xdata, postparent); return 0; } static int test_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { gf_log(this->name, GF_LOG_ERROR, "in test translator lookup"); STACK_WIND (frame, test_lookup_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, loc, xdata); return 0; } static int test_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { gf_log(this->name, GF_LOG_ERROR, "in test translator stat"); return 0; } int reconfigure (xlator_t *this, dict_t *options) { return 0; } int init (xlator_t *this) { struct ios_conf *conf = NULL; int ret = -1; gf_log (this->name, GF_LOG_ERROR, "test translator loaded"); if (!this) return -1; if (!this->children) { gf_log (this->name, GF_LOG_ERROR, "test translator requires atleast one subvolume"); return -1; } if (!this->parents) { gf_log (this->name, GF_LOG_ERROR, "dangling volume. check volfile "); } conf = this->private; this->private = conf; ret = 0; return ret; } void fini (xlator_t *this) { struct ios_conf *conf = NULL; if (!this) return; conf = this->private; if (!conf) return; this->private = NULL; GF_FREE(conf); gf_log (this->name, GF_LOG_ERROR, "test translator unloaded"); return; } int notify (xlator_t *this, int32_t event, void *data, ...) { default_notify (this, event, data); return 0; } struct xlator_fops fops = { .stat = test_stat, .lookup = test_lookup, }; struct xlator_cbks cbks = { }; struct volume_options options[] = { };
MakeFile:
Add translator into glusterfs volume file #Author Steven Liu #E-mail lingjiujianke@gmail.com #Blog: http://blog.fs-linux.org TARGET = test.so OBJECTS = test.o GLUSTERFS_SRC = /root/Gluster/glusterfs GLUSTERFS_LIB = /usr/local/lib HOST_OS = HF_LINUX_HOST_OS CFLAGS = -fPIC -Wall -O0 -g \ -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(HOST_OS) \ -I$(GLUSTERFS_SRC) -I$(GLUSTERFS_SRC)/libglusterfs/src \ -I$(GLUSTERFS_SRC)/contrib/uuid LDFLAGS = -shared -nostartfiles -L$(GLUSTERFS_LIB) -lglusterfs -lpthread $(TARGET): $(OBJECTS) $(CC) $(OBJECTS) $(LDFLAGS) -o $(TARGET) clean: rm -rf $(TARGET) $(OBJECTS)
3、编译出so文件 并放在所有机器的/usr/local/lib/glusterfs/xlator/debug/(具体根据不同版本路径有所不同)下面
4、修改volfile
vi /var/lib/glusterd/vols/testvol/testvol-fuse.vol
在结尾处修改如下:
volume testvol-test type debug/test subvolumes testvol-md-cache end-volume volume testvol type debug/io-stats option count-fop-hits off option latency-measurement off subvolumes testvol-test end-volume
然后在每个服务器中都更新这个文件
5、在三台gluster服务器中重启glusterfsd进程
ps -ef | grep glusterfsd
kill -9 ****
6、客户端挂载测试
可以看出test xlator成功生效!
相关文章推荐
- 建站之星 添加自定义模块步骤
- 如何在gluster的源码中添加自己的xlator
- Discuz! X2.5 添加自定义数据调用模块(简单方法)
- 【转】vsftp 添加用户 简单步骤
- 【win2003添加自定义用户设置具体步骤】
- Framework/base 下添加自定义模块的步骤
- MFC程序添加自定义命名空间和自定义类的步骤
- 编译Framework/base 下添加自定义模块的步骤
- HPUX MC/SG扩容简单步骤(OPS环境添加新共享VG)
- 简单账表二次开发添加自定义字段
- CArray使用简单介绍,如何添加标准数据类型,和自定义的类,或者自定义数据类型
- 添加自定义事件以及对osg事件队列的简单理解
- VC++ 添加自定义消息响应函数以及发送消息SendMessage投递消息PostMessage的简单测试
- 利用Vuforia自定义识别/动态生成识别图的简单操作步骤
- 在VC中添加响应自定义的消息的代码步骤(转)
- Fragment之动态添加的简单使用步骤
- 前端项目添加自定义icon图标步骤
- 在ArcGIS Server Java ADF中创建一个自定义task的简单步骤
- 在web.config中添加简单的自定义段