gluster 添加xlator新节点

gluster 添加xlator新节点添加 xlator 过程步骤分析 1 执行命令 A 机器 mkdir home test 任意机器 glustervolum 机器 IP home test 如果你指定的 brick 位于根分区 在创建卷命令后加 force2 vim var lib glusterd vols testvol testvol fuse vol 这个是默认生成的配置文件 我

                                                                   添加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

    typeprotocol/client

    optiontransport-typetcp

    optionremote-subvolume /home/test

    optionremote-host A机器IP

end-volume

 

volumetestvol-dht

    typecluster/distribute

    subvolumestestvol-client-0

end-volume

 

volumetestvol-write-behind

    typeperformance/write-behind

    subvolumestestvol-dht

end-volume

 

volumetestvol-read-ahead

    typeperformance/read-ahead

    subvolumestestvol-write-behind

end-volume

 

volumetestvol-io-cache

    typeperformance/io-cache

    subvolumestestvol-read-ahead

end-volume

 

volumetestvol-quick-read

    typeperformance/quick-read

    subvolumestestvol-io-cache

end-volume

 

volumetestvol-open-behind

    typeperformance/open-behind

    subvolumestestvol-quick-read

end-volume

 

volumetestvol-md-cache

    typeperformance/md-cache

    subvolumestestvol-open-behind

end-volume

 

volumetestvol

    typedebug/io-stats

    optioncount-fop-hits off

    optionlatency-measurement off

    subvolumestestvol-md-cache

end-volume

修改后文件的内容如下:

volumetestvol-client-0

    typeprotocol/client

    optiontransport-typetcp

    optionremote-subvolume /home/test

    optionremote-host A机器IP

end-volume

 

volumetestvol-dht

    typecluster/distribute

    subvolumestestvol-client-0

end-volume

 

volumetestvol-write-behind

    typeperformance/write-behind

    subvolumestestvol-dht

end-volume

 

volumetestvol-read-ahead

    typeperformance/read-ahead

    subvolumestestvol-write-behind

end-volume

 

volumetestvol-io-cache

    typeperformance/io-cache

    subvolumestestvol-read-ahead

end-volume

 

volumetestvol-quick-read

    typeperformance/quick-read

    subvolumestestvol-io-cache

end-volume

 

volumetestvol-open-behind

    typeperformance/open-behind

    subvolumestestvol-quick-read

end-volume

 

volumetestvol-md-cache

    typeperformance/md-cache

    subvolumestestvol-open-behind

end-volume

volumetestvol-test

    typedebug/test

    subvolumestestvol-md-cache

end-volume

volumetestvol

    typedebug/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

#include

#include"glusterfs.h"

#include"xlator.h"

#include

#include"defaults.h"

#include"logging.h"

 

inttest_lookup_cbk(call_frame_t *frame, void*cookie,xlator_t *this,

                     int32_top_ret, int32_t op_errno,

                     inode_t*inode, structiatt*buf,

                     dict_t*xdata, structiatt*postparent)

{

        STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf, xdata,

                             postparent);

        return0;

}

 

 

staticinttest_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);

    return0;

}

 

staticinttest_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");

    return0;

}

 

int

reconfigure(xlator_t *this, dict_t *options)

{

        return0;

}

 

 

int

init(xlator_t *this)

{

        structios_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;

        returnret;

}

 

 

void

fini(xlator_t *this)

{

        structios_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);

        return0;

}

 

structxlator_fopsfops = {

        .stat       = test_stat,

        .lookup     = test_lookup,

};

 

structxlator_cbkscbks = {

};

 

structvolume_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机器IPtestvol/media

查看日志文件输出是否含有testxlator的信息。

附上指定日志输出位置和指定卷配置的命令:

/glusterfsd-l ../../g.log -f /home/li/…../test.vol

(-l指定日志存储位置,-f指定配置文件的位置)

glusterfsd的位置可以用whereisglusterfsd查看

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/211619.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月18日 下午10:00
下一篇 2026年3月18日 下午10:01


相关推荐

  • Declare 语句

    Declare 语句原文 http blog csdn net u0 article details 本文是看了网上很多零碎的知识点总结而成 要感谢广大网友的智慧 Declare 语句用于在模块级别中声明对动态链接库 DLL 中外部过程的引用 语法 1 Public nbsp nbsp Private nbsp Declare nbsp Sub nbsp name nbsp Lib nbsp libname nbsp Alias nbsp aliasnam

    2026年3月18日
    3
  • treeTable v 1.4.2

    treeTable v 1.4.2treeTablev1.4.2简介treeTable是跨浏览器、性能很高的jquery的树表组件,它使用非常简单,只需要引用jquery库和一个js文件,接口也很简单。优点兼容主流浏览器:支持IE6和IE6+,Firefox,chrome,Opera,Safari接口简洁:在普通表格的基础上增加父子关系的自定义标签就可以组件性能高:内部实现了只绑

    2022年6月11日
    35
  • oracle自动更新视图,Oracle 视图及视图更新「建议收藏」

    创建视图createOrReplaceviewtasselectT1.t11f1,T1.t12f2,T2.t22f3fromT1,T2WhereT1.t11=T2.t11;视图更新CreateOrReplaceTriggerTrg_InsUpdDel_tInsteadOfInsertorupdateordeleteontforeachrowDec…

    2022年4月12日
    56
  • 最简分式

    最简分式题目内容 分数可以表示为 分子 分母 的形式 编写一个程序 要求用户输入一个分数 然后将其约分为最简分式 最简分式是指分子和分母不具有可以约分的成分了 如 6 12 可以被约分为 1 2 当分子大于分母时 不需要表达为整数又分数的形式 即 11 8 还是 11 8 而当分子分母相等时 仍然表达为 1 1 的分数形式 nbsp 输入格式 输入在一行中给出一个分数 分子和分母中间以斜杠 分隔 如 12

    2026年3月26日
    1
  • 各种卷积操作[通俗易懂]

    各种卷积操作[通俗易懂]各种卷积的作用Filter与kernelfilter是多个kernel的串联,每个kernel分配给输入的特定通道。filter总是比kernel大一维。1.常规卷积运算整个过程可以用下图来概括。假设输入层为一个大小为64x64x3(Width=Height=64,Channel=3)的彩色图片。经过一个包含4个filter(每个filter有3个kernel,kernel_size=3×3)的卷积层,最终输出4个特征图(featuremap),且尺寸与输入层相同。因此卷积层的参数数量可以

    2022年5月28日
    51
  • unity自学入门_unity 教程

    unity自学入门_unity 教程六本书Unity5权威讲解Unity3DNGUI实战教程Unity5实战使用C和Unity开发多平台游戏Unity3D人工智能编程Unity官方案例精讲UnityShader入门精要1.Unity5权威讲解#目录第1章 Unity5简介 11.1 Unity3D游戏引擎的诞生 21.2 Unity5的优势 21.2.1 支持多平台 21.2.2 集

    2022年8月30日
    9

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号