Gluster添加自定义简单xlator的步骤
来源:互联网 发布:淘宝评价推荐排序 编辑:程序博客网 时间:2024/06/05 06:21
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;}intreconfigure (xlator_t *this, dict_t *options){ return 0;}intinit (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;}voidfini (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;}intnotify (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.orgTARGET = test.soOBJECTS = test.oGLUSTERFS_SRC = /root/Gluster/glusterfsGLUSTERFS_LIB = /usr/local/libHOST_OS = HF_LINUX_HOST_OSCFLAGS = -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/uuidLDFLAGS = -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-cacheend-volumevolume testvol type debug/io-stats option count-fop-hits off option latency-measurement off subvolumes testvol-testend-volume
然后在每个服务器中都更新这个文件
5、在三台gluster服务器中重启glusterfsd进程
ps -ef | grep glusterfsd
kill -9 ****
6、客户端挂载测试
可以看出test xlator成功生效!
阅读全文
0 0
- Gluster添加自定义简单xlator的步骤
- gluster 添加xlator新节点
- 如何在gluster的源码中添加自己的xlator
- Gluster简单加密xlator rot-13模块的测试
- Gluster源代码阅读3--MGMT Xlator
- gluster的迁移
- 在MFC框架中添加自定义消息的几个步骤
- Framework/base 下添加自定义模块的步骤
- Framework/base 下添加自定义模块的步骤
- Framework/base 下添加自定义模块的步骤
- Framework/base 下添加自定义模块的步骤
- 编译Framework/base 下添加自定义模块的步骤
- Fragment之动态添加的简单使用步骤
- gluster文件锁的实现
- Gluster升级遇到的问题
- MFC程序添加自定义命名空间和自定义类的步骤
- 添加硬盘的步骤
- Fragment的添加步骤
- 代码重构之DAO扮演多个职责的重构案例
- Java
- for循环优化总结
- 自定义注解
- java虚拟机(三)---对象存活
- Gluster添加自定义简单xlator的步骤
- adb连接安卓设备失败failed to start daemon
- 【Scikit-Learn 中文文档】广义线性模型
- greenDAO的使用详解---(1)greenDAO的配置和增删改查
- BSP 测试之Power相关Log查看--Android操作系统
- 如何设计实现真正的响应式微服务系统?
- andoid7.0 bma250e 驱动1 (bma250.c)
- 【第三方类库】Apache Curator
- JSP