gluster 添加xlator新节点
2014-07-11 15:41
176 查看
添加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。
例子如下:
原文件内容:
修改后文件的内容如下:
注意:黑体部分为变动的地方
3.创建任意目录,编写test.c文件
此文件摘自http://blog.chinaunix.net/uid-11344913-id-3795965.html
4.在test.c同目录下,编辑Makefile文件
内容如下:
执行命令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查看
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添加节点失败报错:No route to host
- Gluster添加自定义简单xlator的步骤
- 如何在gluster的源码中添加自己的xlator
- [置顶] 手动输入信息添加echarts节点
- VB6 Treeview的添加节点子节点、Treeview打开、Treeview关闭
- 《JavaScript学习笔记》:DOM_添加节点、删除节点、文档碎片
- ie下,jquery为动态添加的节点添加事件,用live
- C#里创建xml文件添加删除节点
- Js为表单动态添加节点内容的方法
- asp.net treeview数据库绑定 (节点添加 删除 修改)
- @ Replica set 多服务器 高可用 配置 (添加删除节点方法)
- DOM操作——JavaScript怎样添加、移除、移动、复制、创建和查找节点
- Hadoop 2.6.0动态添加节点
- Hadoop热添加删除节点(含Hbase)
- clone方式添加应用节点
- Oracle 11G R2 RAC 添加节点,添加asm磁盘
- 创建节点、添加节点
- C# xml文件的创建,修改和添加节点 。
- Hadoop分布式集群系统添加节点
- js怎样添加、移除、移动、复制、创建和查找节点