gluster 添加xlator新节点
来源:互联网 发布:公司网络布局 编辑:程序博客网 时间:2024/06/04 19:26
添加xlator过程步骤分析
1.执行命令A机器:mkdir/home/test
任意机器:glustervolume create testvol A机器IP:/home/test
如果你指定的brick位于根分区,在创建卷命令后加force
2.vim /var/lib/glusterd/vols/testvol/testvol-fuse.vol,这个是默认生成的配置文件,我们修改这个文件加入我们自己的xlator。
例子如下:
原文件内容:
volumetestvol-client-0
type
protocol/client
optiontransport-
type
tcp
optionremote-subvolume /home/test
optionremote-host A
机器IP
end-volume
volumetestvol-dht
type
cluster/distribute
subvolumestestvol-client-0
end-volume
volumetestvol-write-behind
type
performance/write-behind
subvolumestestvol-dht
end-volume
volumetestvol-
read
-ahead
type
performance/read-ahead
subvolumestestvol-write-behind
end-volume
volumetestvol-io-cache
type
performance/io-cache
subvolumestestvol-
read
-ahead
end-volume
volumetestvol-quick-
read
type
performance/quick-read
subvolumestestvol-io-cache
end-volume
volumetestvol-
open
-behind
type
performance/open-behind
subvolumestestvol-quick-
read
end-volume
volumetestvol-md-cache
type
performance/md-cache
subvolumestestvol-
open
-behind
end-volume
volumetestvol
type
debug/io-stats
optioncount-fop-hits off
optionlatency-measurement off
subvolumestestvol-md-cache
end-volume
修改后文件的内容如下:
volumetestvol-client-0
type
protocol/client
optiontransport-
type
tcp
optionremote-subvolume /home/test
optionremote-host A
机器IP
end-volume
volumetestvol-dht
type
cluster/distribute
subvolumestestvol-client-0
end-volume
volumetestvol-write-behind
type
performance/write-behind
subvolumestestvol-dht
end-volume
volumetestvol-
read
-ahead
type
performance/read-ahead
subvolumestestvol-write-behind
end-volume
volumetestvol-io-cache
type
performance/io-cache
subvolumestestvol-
read
-ahead
end-volume
volumetestvol-quick-
read
type
performance/quick-read
subvolumestestvol-io-cache
end-volume
volumetestvol-
open
-behind
type
performance/open-behind
subvolumestestvol-quick-
read
end-volume
volumetestvol-md-cache
type
performance/md-cache
subvolumestestvol-
open
-behind
end-volume
volumetestvol-
test
type
debug/test
subvolumestestvol-md-cache
end-volume
volumetestvol
type
debug/io-stats
optioncount-fop-hits off
optionlatency-measurement off
subvolumestestvol-
test
end-volume
注意:黑体部分为变动的地方
3.创建任意目录,编写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_top_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,
"testtranslator 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_fopsfops = {
.stat = test_stat,
.lookup = test_lookup,
};
struct
xlator_cbkscbks = {
};
struct
volume_optionsoptions[] = {
};
此文件摘自http://blog.chinaunix.net/uid-11344913-id-3795965.html
4.在test.c同目录下,编辑Makefile文件
内容如下:
TARGET =
test
.so
OBJECTS=
test
.o
GLUSTERFS_SRC = /...../glusterfs #
自己的gluster
源码路径
GLUSTERFS_LIB = /usr/local/lib
HOST_OS= GF_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)
此源码文件注意调整需要tab
键格式的地方
执行命令make
将产生的test.so文件拷贝到/usr/local/lib/glusterfs/3.4.3/xlator/debug
4.重启glusterd服务,客户端挂载此卷
mount-t glusterfs A机器IP:testvol/media
查看日志文件输出是否含有testxlator的信息。
附上指定日志输出位置和指定卷配置的命令:
/glusterfsd-l ../../g.log -f /home/li/...../test.vol
(-l指定日志存储位置,-f指定配置文件的位置)
glusterfsd的位置可以用whereisglusterfsd查看
- gluster 添加xlator新节点
- Gluster添加自定义简单xlator的步骤
- 如何在gluster的源码中添加自己的xlator
- Gluster源代码阅读3--MGMT Xlator
- Gluster简单加密xlator rot-13模块的测试
- 设计新Xlator扩展GlusterFS
- Hadoop添加新的节点
- hadoop 动态添加新节点
- javascript添加新节点的方法
- 给XML文件添加新的节点
- 【Hadoop】完全分布式添加新节点
- hadoop集群添加新节点hhbase调试
- Hadoop-添加新节点到集群
- RAC添加新节点步骤整理
- hadoop-2.6.0动态添加新节点
- Hadoop-HBASE 热添加新节点
- oracle11g rac 如何删除损坏节点并添加新节点
- dom4j解析xml文件,添加新节点,添加节点内容,读取文件中节点内容作为新增节点内容
- 开源项目之Android Afinal框架
- messagebox afxmessagebox(转载)
- Net Remoting(应用程序域)
- 哈夫曼树
- 设计自己的基于Selenium 的自动化测试框架-Java版(2) - 定义自己的工作流程
- gluster 添加xlator新节点
- 8.asm-PEB、TEB的地址(ntdll!RtlGetCurrentPeb得到PEB)
- UVa 437 The Tower of Babylon(动态规划)
- Linux系统常用快捷键
- RHEL5.5_x86_64上安装ASE12.5.4
- 异或树
- 一人点赞,N人跟风?
- workBench 下工程创建时通过快捷方式添加其他位置的文件夹
- ArcGIS教程:欧氏距离——空间分析