上一篇文章我们对余老师开发的分布式存储系统FastCFS做了一个简单的介绍,具体看这个链接:https:www。jianshu。compf09953393b1e 今天我讲自己部署FastCFS集群并和k8s集群打通的全过程分享出来,希望能够帮助到希望尝试使用FastCFS的同学。一、快速部署 如果你只是想简单快速上手体验FastCFS,作为学习或者本地测试环境而非生产环境,你可以选择以下两种方式部署FastCFS:部署本地单节点Docker部署1。单机部署 单机部署FastCFS的github和gitee上面已经提供了比较完整的文档说明。我这里摘抄一些,并做下说明: 前提是安装的机器必须已经安装git客户端。仅支持Centos7、Centos8两个Linux发行版本,笔者在Centos7环境亲测成功,Centos8没有环境没有测试。 一键搭建(包括部署和运行)单节点(需要root身份执行):gitclonehttps:gitee。comfastdfs100FastCFS。cdFastCFS。helloWorld。sh注意:helloWorld。sh将更改FastCFS相关配置文件,请不要在多节点集群上执行! 上述操作完成后,执行命令验证安装状态:dfhoptfastcfsfusegrepfuse 如果可以看到FastCFS挂载的文件目录,说明安装成功,你可以把optfastcfsfuse当作本地文件系统访问该目录。 说明没有安装git客户端,也没有问题,只需要下载两个个sh文件并放到同一个文件夹即可,它们是: helloWorld。sh fastcfs。sh(值得注意的是fastcfs。sh支持源码编译安装,但是个人觉得并不适合一键部署) 安装命令如下(有git客户端且已经按上一步安装成功的可以略过)mkdirfastcfscdfashcfswgethttps:toscode。gitee。comfastdfs100FastCFSrawmasterhelloWorld。shwgethttps:toscode。gitee。comfastdfs100FastCFSrawmasterfastcfs。shchmodxhelloWorld。shchmodxfastcfs。sh。helloWorld。sh 一键部署的详细说明,请参见这里一键部署详细说明2。Docker部署 官方暂时没有提供Docker镜像,为了方便大家快速体验,笔者制作了一个单机版本的镜像,已经push到DockerHub,地址为:https:hub。docker。comrjerry6290fastcfs启动方式:dockerrunnamefastCFSprivilegeddjerry6290fastcfs:v3。1。0 v3。1。0是版本号,可以根据实际情况修改成最新版本号。 注意:由于需要通过fuse把FastCFS作为目录挂载,所以在dockerrun时需要增加参数privileged,让容器真正有root权限。登录到容器验证fastCFSdockerexecitfastCFSsh执行dfh,应该能看到fastCFS的fspool被挂载到optfastcfsfuse目录dfhFilesystemSizeUsedAvailUseMountedonoverlay500G110G391G22tmpfs64M064M0devtmpfs12G012G0sysfscgroupshm64M064M0devshmdevmappercentosroot500G110G391G22etchostsdevfuse342G0342G0optfastcfsfuse写文件echoHelloFastCFSoptfastcfsfuseFastCFS。txt查看文件内容catoptfastcfsfuseFastCFS。txtHelloFastCFS 当然,你也可以通v的方式把optfastcfsfuse目录挂载出来,具体做法就不赘述了。 该Dockerfile开源在github,并通过githubActions自动打包并push到dockerhub,项目地址:https:github。comjerry6290dockerImagefastCFSServer二、集群部署1。软硬件环境准备 FastCFS作为一款开源云原生分布式存储系统,可以很好的部署和运行在Intel架构服务器环境和主流虚拟化环境,并支持绝大多数的主流硬件和网络,支持主流的Linux操作系统环境。1。1操作系统发行版本要求: Linux操作系统平台 版本 RedHatEnterpriseLinux 7。x及以上版本版本 CentOS 7。x及以上版本版本 UbuntuLTS 16。04及以上的版本1。2服务器建议配置 FastCFS有三大组件,FastDIR,FastStore,FastAuth,支持部署和运行在Intelx8664架构的64位通用硬件服务器平台。 对于开发,测试,及生产环境的服务器硬件配置有以下要求和建议:开发及测试环境: 组件 CPU 内存 硬盘 网络 实例数量 FastDIR 4核 8G 无特殊要求 千兆网卡 1(可和FastStore,FastAuth同机器) FastStore 4核 8G 无特殊要求,最好是SSD,容量大一些 千兆网卡 1(可和FastDIR,FastAuth同机器) FastAuth 4核 8G 无特殊要求 千兆网卡 1(可和FastStore,FastDIR同机器)生产环境: 组件 CPU 内存 硬盘 网络 实例数量 FastDIR 8核 16G 无特殊要求 千兆网卡 3及以上,最好是奇数(可和FastStore,FastAuth同机器) FastStore 8核 16G 最好是SSD,容量大一些 千兆网卡 6及以上,可根据需求的容量而定(可和FastDIR,FastAuth同机器) FastAuth 8核 16G 无特殊要求 千兆网卡 3及以上,最好是奇数(可和FastStore,FastDIR同机器)注意: FastStore对服务器和数据均采用分组方式,服务器分组简称SG,组内的数据是冗余关系(服务器数即数据副本数)。一个SG可以容纳多个数据分组DG,引入DG的主要目的是方便扩容时做数据迁移,因此最好预设得大一些,生产环境至少配置256,开发测试环境至少配置16个。生产环境建议建2个以上SG,每个SG有3台服务器,即3个数据副本,所以存储数据的组件FastStore建议至少236台服务器,以保证数据完整性。FastAuth是可选,如果需要通过CSI集成到k8s,则需要开启存储池或访问权限控制,需要部署FastAuth认证集群。FastDIR启用存储插件的话,最好配置SSD。如果对性能和可靠性有更高的要求,fastDIR,fastStore,fastAuth三大组件应尽可能分开部署。2。环境及配置准备2。1SSH免密登录 找一个服务器当中控机,比如:192。168。0。201,以root用户登录到中控机,执行以下命令。将192。168。0。204替换成你的受控机器IP,按提示输入受控机器root用户密码,执行成功后即创建好SSH互信,其他机器同理。sshkeygentrsa一路回车sshcopyid192。168。0。204 验证ssh免密是否成功,在中控机,通过ssh的方式登录受控机器IP。如果不需要输入密码并登录成功,即表示SSH互信配置成功,如果没有成功请检查受控机器的sshd配置和相关安全策略。ssh192。168。0。2042。2端口准备fastDIR默认集群端口11011默认服务端口11012fastAuth默认集群端口31011默认服务端口31012fastStore默认集群端口21014默认副本端口21015默认服务端口21016 需要保证每台服务器上述的端口是相互能通的,如果是在redhat7、centos7版本及以上版本,可以通过firewallcmd命令打开服务器之间端口通信。比如在网段192。168。0。124,可以通过一下命令打开端口,其中网段和zonepublic需要自行根据自己的zone进行调整:firewallcmdpermanentzonepublicaddrichrulerulefamilyipv4sourceaddress192。168。0。124portprotocoltcpport1101111012acceptfirewallcmdpermanentzonepublicaddrichrulerulefamilyipv4sourceaddress192。168。0。124portprotocoltcpport2101421016acceptfirewallcmdpermanentzonepublicaddrichrulerulefamilyipv4sourceaddress192。168。0。124portprotocoltcpport3101131012acceptfirewallcmdreload3。集群拓扑规划 FastCFS支持大规模的集群,下面以最为典型的最小化集群拓扑,1个SG,3个DG(3个数据副本)。更大规模的安装方式可参照此过程扩展安装,服务器的数量及配置参数按上文所述。 本次安装教程,笔者手头上的机器有限,准备了4台机器,已经安装好centos7。9,对应的端口防火墙已经打开,,集群拓扑规划如下:3个FastStore节点、3个FastDir节点、3个FastAuth节点,一个fuse客户端节点FastStore、FastDir、FastAuth公用3个节点。 组件 服务器IP 个数 FastDir 192。168。0。201,192。168。0。204,192。168。0。205 3hrFastStore 192。168。0。201,192。168。0。204,192。168。0。205 3hrFastAuth 192。168。0。201,192。168。0。204,192。168。0。205 3hrFastfuse客户端 192。168。0。203 14。集群安装与配置4。1yum方式安装4。1。1FastOS。repoyum源 需要在每个节点安装,命令:rpmivhhttp:www。fastken。comyumrepoel7x8664FastOSrepo1。0。01。el7。centos。x8664。rpm4。1。2安装FastDIR 分别在192。168。0。201,204,205安装yuminstallfastDIRservery 安装完毕后,在etcfastcfs下可看到FastDIR的配置文件,在usrbin目录看到fdir相关的程序lletcfastcfsfdirtotal16rwrr。1rootroot134Jan2023:24client。confrwrr。1rootroot291Jan2023:24cluster。confrwrr。1rootroot2160Jan2023:24server。confrwrr。1rootroot726Jan2023:24storage。confllusrbingrepfdirrwxrxrx。1rootroot11336Jan2020:51fdirclusterstatrwxrxrx。1rootroot11472Jan2020:51fdirgetxattrrwxrxrx。1rootroot11344Jan2020:51fdirlistrwxrxrx。1rootroot7200Jan2020:51fdirlistserversrwxrxrx。1rootroot11344Jan2020:51fdirmkdirrwxrxrx。1rootroot11312Jan2020:51fdirremoverwxrxrx。1rootroot11312Jan2020:51fdirrenamerwxrxrx。1rootroot234208Jan2020:51fdirserverdrwxrxrx。1rootroot11384Jan2020:51fdirservicestatrwxrxrx。1rootroot11328Jan2020:51fdirsetxattrrwxrxrx。1rootroot11328Jan2020:51fdirstat4。1。2安装FastStore 分别在192。168。0。201,204,205安装yuminstallfaststoreservery 安装完毕后,在etcfastcfs下可看到FastStore的配置文件,在usrbin目录看到fs相关的程序lletcfastcfsfstoretotal16rwrr。1rootroot147Jan2023:24client。confrwrr。1rootroot1739Jan2023:24cluster。confrwrr。1rootroot1274Jan2023:24server。confrwrr。1rootroot673Jan2023:24storage。confllusrbinegrepfsrwxrxrx。1rootroot11488Jan1310:32fsclusterstatrwxrxrx。1rootroot11440Jan1310:32fsdeleterwxrxrx。1rootroot11480Jan1310:32fsreadrwxrxrx。1rootroot447336Jan1310:32fsserverdrwxrxrx。1rootroot11424Jan1310:32fsservicestatrwxrxrx。1rootroot11456Jan1310:32fswrite4。1。3安装FastAuth 分别在192。168。0。201,204,205安装yuminstallFastCFSauthservery 安装完毕后,在etcfastcfs下可看到FastAuth的配置文件lletcfastcfsauthtotal20rwrr。1rootroot411Jan2100:47auth。confrwrr。1rootroot134Jan2100:47client。confrwrr。1rootroot148Jan2119:18cluster。confdrwxrxrx。2rootroot51Jan2115:47keysrwrr。1rootroot1627Jan2100:47server。confrwrr。1rootroot145Jan2100:47session。conf4。1。3安装Fastfused客户端 客户端只需要在192。168。0。203安装yumremovefuseyyuminstallFastCFSfusedy说明: centos版本中的fuse为老版本的包(fuse2。x),需要卸载才可以成功安装FastCFSfused依赖的fuse3;第一次安装才需要卸载fuse包,以后就不用执行了。 安装完毕后,在etcfastcfs下可看到fcfs的配置文件lletcfastcfstotal0drwxrxrx3rootroot113Feb314:38authdrwxrxrx2rootroot23Feb314:38fcfsdrwxrxrx2rootroot84Feb314:38fdirdrwxrxrx2rootroot84Feb314:38fstore4。1。4集群配置 FastCFS并没有统一的配置中心,需要在各个节点上单独部署配置文件。配置文件分为三大类:集群配置文件、服务配置文件、客户端配置文件。集群配置文件:指的是描述FastDir、FastStore、FastAuth的配置文件,入口文件名称为cluster。conf。该配置文件中设定是集群的参数,如服务节点的IP、服务端口号、集群同步端口号,服务节点的拓扑结构等。cluster。conf文件全局统一,各个节点上的内容是相同的。服务配置文件:指的是服务本身的配置文件,入口文件名称server。conf如线程数量、链接数量、缓冲区大小、存储配置、日志配置等。服务配置文件的内容,可以全局不统一。不过从集群运维方便的角度考虑,服务器配置最好是统一的。客户端配置文件:指的是fuse或者其他客户端的配置,比如fuse客户端需要知道fdir、fstore、fauth的集群情况,所以客户端需要fdir、fstore和fauth的server服务集群的配置。 下面针对三大组件和客户端的配置进行详细说明:fdir配置 用root登录主控机192。168。0。201修改fdir集群配置文件 修改etcfastcfsfdircluster。conf文件,修改为上面提到的三个IP地址(修改成你自己对应的IP),〔sever1〕为192。168。0。201,〔sever2〕为192。168。0。204,〔sever3〕为192。168。0。205,如果你有更多fdir节点,增加配置〔serverN〕即可,修改后的内容如下:configtheauthconfigfilenameauthconfigfilename。。authauth。conf〔groupcluster〕thedefaultclusterportport11011〔groupservice〕thedefaultserviceportport11012〔server1〕host192。168。0。201节点1〔server2〕host192。168。0。204节点2〔server3〕host192。168。0。205节点3修改fdir服务配置文件 修改etcfastcfsfdirserver。conf文件,内容如下:thebasepathtostorelogfilesthispathmustbeexistbasepathoptfastcfsfdirthepathtostoredatafilescanbeanabsolutepathorarelativepaththerelativepathforsubdirectoryunderthebasepaththispathwillbecreatedautowhennotexistdefaultvalueisdatadatapathdatamaxconcurrentconnectionsthisserversupportyoushouldsetthisparameterlarger,eg。10240defaultvalueis256maxconnections10240thedatathreadcountthesethreadsdealCUD(Create,Update,Delete)operationsdispatchedbythehashcodeofthenamespaceifyouhaveonlyonenamespace,youshouldconfigthisparameterto1,becauseitismeaninglesstoconfigurethisparametergreaterthan1inthiscasedefaultvalueis1datathreads1theclusteridforgenerateinodemustbenaturalnumbersuchas1,2,3,。。。IMPORTANTNOTE:doNOTchangetheclusteridaftersetbecausethe64bitsinodeincludestheclusterid,andtheinodedisordermaybeleadtoconfusionclusterid1configclusterserversclusterconfigfilenamecluster。confsessionconfigfilenameforauthsessionconfigfilename。。authsession。conf〔storageengine〕ifenablethestorageenginefalse:usebinlogdirectlytrue:usestorageengineformassivefilesdefaultvalueisfalse,如果设置为true,还需要配置storage。confenabledfalsetheconfigfilenameforstoragestorageconfigfilenamestorage。confthepathtostorethedatafilescanbeanabsolutepathorarelativepaththerelativepathforsubdirectoryunderthebasepaththispathwillbecreatedautowhennotexistdefaultvalueisdbdatapathdbtheintervalforlruelimination0fornevereliminateunit:secondsdefaultvalueis1eliminateinterval1thememorylimitratiofordentrythevalidlimitrangeis〔1,99〕defaultvalueis80memorylimit80〔cluster〕thelistenportport11011thenetworkthreadcountthesethreadsdealnetworkiodispatchedbytheincomingsocketfddefaultvalueis4workthreads2〔service〕port11012workthreads4 server。conf基本上用默认配置即可,如果需要开启存储插件,需要把〔storageengine〕下面的enabletrue,同时配置storage。conf。复制cluster文件到其他节点 fdir的cluster。conf,server。conf配置完成后,把cluster。conf配置文件通过scp命令复制到其他节点(包括客户端节点),server。conf不需要复制:scpetcfastcfsfdircluster。conf192。168。0。204:etcfastcfsfdircluster。confscpetcfastcfsfdircluster。conf192。168。0。205:etcfastcfsfdircluster。confscpetcfastcfsfdircluster。conf192。168。0。203:etcfastcfsfdircluster。conffstore配置 用root登录主控机192。168。0。201修改fstore集群配置文件非常重要: fstore是存储数据的核心组件,修改cluster配置文件,一定要了解fstore存储的基本原理。了解SG(服务器分组),DG(数据分组),DGC(数据分组数)等几个名词的相互关系。上面的拓扑规划时已经简单描述过,更详细查看作者余大的技术文章:https:my。oschina。netu3334339blog4870261 修改etcfastcfsfstorecluster。conf文件,让fstore的集群拓扑为:1个SG,SG里面包含三台服务器,DG为2,DGC为128,修改后的内容如下:thegroupcountoftheserversinstancesservergroupcount1SGC1alldatagroupsmustbemappedtotheservergroup(s)withoutomission。oncethenumberofdatagroupsisset,itcanNOTbechanged,otherwisethedataaccesswillbeconfused!datagroupcount128DGCconfigtheauthconfigfilenameauthconfigfilename。。authauth。conf〔groupcluster〕thedefaultclusterportport21014〔groupreplica〕thedefaultreplicaportport21015〔groupservice〕thedefaultserviceportport21016〔servergroup1〕serverids〔1,3〕datagroupids〔1,64〕datagroupids〔65,128〕〔server1〕host192。168。0。201〔server2〕host192。168。0。204〔server3〕host192。168。0。205 server。conf基本上用默认配置即可,如果需要修改存储目录,需要修改storage。conf,如果有多个数据盘可以配置多个目录,充分利用硬盘空间thewritethreadcountperstorepaththedefaultvalueis1writethreadsperpath1thereadthreadcountperstorepaththedefaultvalueis1,如果有多个盘可以配置多个目录,充分利用硬盘空间readthreadsperpath1usuallyonestorepathforonediskeachstorepathisconfiguratedinthesectionas:〔storepathid〕,eg。〔storepath1〕forthefirststorepath,〔storepath2〕forthesecondstorepath,andsoon。storepathcount1reservedspaceofeachdiskforsystemorotherapplications。thevalueformatisXXthedefaultvalueis10reservedspaceperdisk10storepathsconfig〔storepath1〕thepathtostorethefile,如果有多个盘可以配置多个目录,充分利用硬盘空间pathoptfaststoredata复制cluster文件到其他节点 fstore的cluster。conf,server。conf,storage。conf配置完成后,把cluster。conf配置文件通过scp命令复制到其他节点,server。conf不需要复制:scpetcfastcfsfstorecluster。conf192。168。0。204:etcfastcfsfstorecluster。confscpetcfastcfsfstorecluster。conf192。168。0。205:etcfastcfsfstorecluster。conffauth配置 用root登录主控机192。168。0。201修改fauth集群配置文件 修改etcfastcfsauthcluster。conf文件,修改为上面提到的三个IP地址(修改成你自己对应的IP),〔sever1〕为192。168。0。201,〔sever2〕为192。168。0。204,〔sever3〕为192。168。0。205,如果你有更多fauth节点,增加配置〔serverN〕即可,修改后的内容如下:〔groupcluster〕thedefaultclusterportport31011〔groupservice〕thedefaultserviceportport31012〔server1〕host192。168。0。201〔server2〕host192。168。0。204〔server3〕host192。168。0。205修改auth。conf开启认证 把etcfastcfsauthauth。conf文件里面的authenabledtrue,修改后内容:enabledisableauthenticationdefaultvalueisfalseauthenabledtruetheusernameforlogindefaultvalueisadminusernameadminthesecretkeyfilenameoftheuservariable{username}willbereplacedwiththevalueofusernamedefaultvalueiskeys{username}。keysecretkeyfilenamekeys{username}。keytheconfigfilenameofauthclientclientconfigfilenameclient。conf复制cluster文件到其他节点 fauth的cluster。conf,auth。conf配置完成后,把cluster。conf、auth。conf配置文件通过scp命令复制到其他节点,server。conf不需要复制:scpetcfastcfsauthcluster。conf192。168。0。204:etcfastcfsauthcluster。confscpetcfastcfsauthcluster。conf192。168。0。205:etcfastcfsauthcluster。confscpetcfastcfsauthcluster。conf192。168。0。203:etcfastcfsauthcluster。confscpetcfastcfsauthauth。conf192。168。0。204:etcfastcfsauthauth。confscpetcfastcfsauthauth。conf192。168。0。205:etcfastcfsauthauth。confscpetcfastcfsauthauth。conf192。168。0。203:etcfastcfsauthauth。conf集群启动 集群的配置文件在各个节点已经配置和分发完毕,下面可以开始启动集群了。 启动顺序如下:fdirfauthfstore 用root用户分别登录到3个节点,执行如下命令:systemctlrestartfastdirsystemctlrestartfastauthsystemctlrestartfaststore 如果启动有问题,请检查配置文件,具体启动日志可以查看optfastcfs下对应的auth、fdir、fstore三个目录里面的logs目录。客户端启动 如果三个节点的所有组件启动没有错误,在客户端节点可以启动客户端程序,把fastCFS的默认poolfs挂载到相应目录。 以本次部署为例,root用户登录到客户端节点192。168。0。203,执行命令:systemctlrestartfastcfs 查看日志文件optfastcfsfcfslogsfcfsfused。log看下启动是否有误,如果无误可以通过dfh查看挂载的目录optfastcfsfusedfhFilesystemSizeUsedAvailUseMountedonoverlay500G110G391G22tmpfs64M064M0devtmpfs12G012G0sysfscgroupshm64M064M0devshmdevmappercentosroot500G110G391G22etchostsdevfuse342G0342G0optfastcfsfuse4。2部署工具fastcfs。sh安装 运维工具fastcfs。sh方式的安装,请参考官方文档,这里不赘述:https:github。comhappyfish100FastCFSblobmasterdocsfcfsopstoolzhCN。md4。3Ansible方式安装(推荐、未完成)4。4K8SOperator方式安装(未完成)5。验证集群状态5。1fdir集群状态 查询fdir整个集群状态fdirclusterstat输出如下serverid:1,host:192。168。0。201:11012,status:23(ACTIVE),ismaster:0serverid:2,host:192。168。0。204:11012,status:23(ACTIVE),ismaster:0serverid:3,host:192。168。0。205:11012,status:23(ACTIVE),ismaster:1servercount:3 查询fdir某个节点状态,1表示是server编号,和cluster。conf相对应fdirservicestat1输出如下serverid:1host:192。168。0。201:11012status:23(ACTIVE)ismaster:falseconnection:{current:4,max:4}binlog:{currentversion:48}dentry:{currentinodesn:5000020,nscount:2,dircount:10,filecount:4}5。2fstore集群状态 显示所有状态fsclusterstat输出如下:datagroupid:1serverid:1,host:192。168。0。201:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0serverid:2,host:192。168。0。204:21016,status:5(ACTIVE),ispreseted:1,ismaster:1,dataversion:0serverid:3,host:192。168。0。205:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0。。。。省略N个datagroupid:127serverid:1,host:192。168。0。201:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0serverid:2,host:192。168。0。204:21016,status:5(ACTIVE),ispreseted:1,ismaster:1,dataversion:0serverid:3,host:192。168。0。205:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0datagroupid:128serverid:1,host:192。168。0。201:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0serverid:2,host:192。168。0。204:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0serverid:3,host:192。168。0。205:21016,status:5(ACTIVE),ispreseted:1,ismaster:1,dataversion:0dataservercount:384 显示某个sg状态,比如sg1fsclusterstatg1输出如下:datagroupid:1serverid:1,host:192。168。0。201:21016,status:5(ACTIVE),ispreseted:1,ismaster:1,dataversion:0serverid:2,host:192。168。0。204:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0serverid:3,host:192。168。0。205:21016,status:5(ACTIVE),ispreseted:0,ismaster:0,dataversion:0dataservercount:3 更多查看fsclusterstathelp5。1fauth集群状态fauthclusterstat输出如下:serverid:1,host:192。168。0。201:31012,isonline:1,ismaster:0serverid:2,host:192。168。0。204:31012,isonline:1,ismaster:0serverid:3,host:192。168。0。205:31012,isonline:1,ismaster:1servercount:36。集群管理6。1fdir相关操作 fdir有fdirlist、fdirmkdir、fdirrename、fdirremove、fdirgetxattr、fdirsetxattr等,还有fcfspool管理、查看pool相关 比如查看poolfs,可以通过fdirlist,更多的信息查看用help查看fdirlistnfs 查看pool列表fcfspoolplist6。2fstore相关操作 fsread,fswrite,fsdelete等,相关命令还不熟,研究中。。。6。3fauth相关操作 fcfsuser查看,新增,删除,设置用户权限等 查看用户列表fcfsuserlist 更多操作Usage:fcfsuser〔cconfigfilenameetcfastcfsauthclient。conf〕〔uadminusernameadmin〕〔kadminsecretkeyfilenameetcfastcfsauthkeys{username}。key〕〔ppriviledgespool〕operation〔username〕〔usersecretkeyfilenamekeys{username}。key〕theoperationsandparametersare:createusername〔usersecretkeyfilename〕passwdsecretkeyusername〔usersecretkeyfilename〕〔y〕:regenerateuserssecretkeygrantusername,theoptionppriviledgesisrequireddeleteremoveusernamelist〔username〕〔usersecretkeyfilename〕:specifythefilenametostorethegeneratedsecretkeyoftheuser〔priviledges〕:thegrantedpriviledgesseperatebycomma,priviledges:user:usermanagementpool:createstoragepoolcluster:monitorclustersession:subscribesessionforFastDIRandFastStoreserverside:forallpriviledges7。测试集群性能 更多性能测试查看官方测试结果:https:github。comhappyfish100FastCFSblobmasterdocsbenchmark。md8。KubernetesCSI安装与配置 终于到了对k8s的支持,作为云原生分布式存储,对k8s的支持肯定是少不了的。8。1用户和pool准备 CSIDriver必须要求FastCFS启用验证模块authenabledtrue,因为k8s的CSI要求支持卷支持定义容量,不同卷是相互独立的。pool就是为此设计的,在CSIDriver中一个卷就是一个pool,而pool是属于用户进行管理的。 为CSI单独创建一个用户:k8s,当然可以用admin用户,但是不推荐。fcfsusercreatek8screateuserk8ssuccess,secretkeystoretofile:keysk8s。key 新建k8s用户成功后会在当前目录下keys目录生成k8s。key文件,这个文件的内容后面会用到。 查看用户:fcfsuserlistNo。usernamepriviledges1。admin2。admin13。k8spool8。2配置准备 FastCFSCSI是利用fused客户端来实现的卷的创建、挂载等操作。上面已经说到FastCFS没有统一的配置中心,而客户端又需要FastCFS集群相关的配置信息,所以需要把集群的配置让CSI读取到。 CSI现在实现的方式是通过httpuri来读取,因此需要把配置文件通过web服务器暴露处理,可以通过nginx、apache等web服务器。 现在CSI需要依赖一个web服务器,其实可以通过configMap挂载文件的方式来实现,已经给官方提供建议并被采纳,不依赖uri的新CSI版本应该很快和大家见面。 笔者使用的是nginx,把192。168。0。201的etcfastcfs目录通过nginx暴露出来,具体细节请参考nginx文档,比如我这里的地址是:http:192。168。0。201:1808ConfigMap准备 创建fastcfscsicm。yml文件,并填入以下内容,其中configURL需要修改成你自己的可以获取fastcfs配置的web服务器地址:apiVersion:v1kind:ConfigMapdata:config。json:〔{clusterID:virtualclusterid1,configURL:http:192。168。0。201:1808修改成你自己的可以获取fastcfs配置的web服务器地址}〕metadata:name:fcfscsiconfig 执行kubectlapplyffastcfscsicm。ymlSecret准备 Secret用来保存刚才创建的用户的用户名和密钥,还是以k8s为例,查看keysk8s。key文件catkeysk8s。key407f1379637afba188d31a795d0224e8 创建fastcfscsisecret。yml,并填入内容,407f1379637afba188d31a795d0224e8改成你自己的密钥。apiVersion:v1kind:Secretmetadata:name:csifcfssecretnamespace:defaultstringData:其实这里并需要admin用户,先填k8s用户和密钥adminName:k8sadminSecretKey:407f1379637afba188d31a795d0224e8usestaticpvforuseruserName:k8suserSecretKey:407f1379637afba188d31a795d0224e8 执行kubectlapplyffastcfscsisecret。yml8。3Helm3准备 添加fastcfscsiHelm存储库:helmrepoaddfastcfscsihttps:happyfish100。github。iofastcfscsihelmrepoupdate8。4安装FastCFSCSI使用helmchart安装驱动程序的版本helmupgradeinstallfastcfscsifastcfscsifcfscsidriver创建静态卷 创建文件fastcfsstaticpv。ymlapiVersion:v1kind:PersistentVolumemetadata:name:testpvspec:capacity:storage:1GivolumeMode:FilesystemaccessModes:ReadWriteOncestorageClassName:csi:driver:fcfs。csi。vazmin。github。iovolumeHandleshouldbesameasFastCFSpoolnamevolumeHandle:testpvnodeStageSecretRef:nodestagesecretnamename:csifcfssecretnodestagesecretnamespacewhereabovesecretiscreatednamespace:defaultvolumeAttributes:RequiredoptionsfromstorageclassparametersneedtobeaddedinvolumeAttributesclusterID:virtualclusterid1static:truepersistentVolumeReclaimPolicy:RetainapiVersion:v1kind:PersistentVolumeClaimmetadata:name:fcfsclaimspec:accessModes:ReadWriteOncestorageClassName:resources:requests:storage:1GivolumeName:testpv 执行:kubectlapplyffastcfsstaticpv。yml创建storageClass和动态卷 创建fastcfsstorageClass。ymlapiVersion:storage。k8s。iov1kind:StorageClassmetadata:name:csifcfsscprovisioner:fcfs。csi。vazmin。github。ioreclaimPolicy:DeletevolumeBindingMode:ImmediateallowVolumeExpansion:trueparameters:Thesecretshavetocontainadmincredentials。csi。storage。k8s。ioprovisionersecretname:csifcfssecretcsi。storage。k8s。ioprovisionersecretnamespace:defaultcsi。storage。k8s。iocontrollerexpandsecretname:csifcfssecretcsi。storage。k8s。iocontrollerexpandsecretnamespace:defaultcsi。storage。k8s。ionodestagesecretname:csifcfssecretcsi。storage。k8s。ionodestagesecretnamespace:defaultcsi。storage。k8s。ionodepublishsecretname:csifcfssecretcsi。storage。k8s。ionodepublishsecretnamespace:defaultclusterID:virtualclusterid1 创建fastcfsdynamicpv。ymlapiVersion:v1kind:PersistentVolumeClaimmetadata:name:csifcfsclaimspec:accessModes:ReadWriteOncestorageClassName:csifcfsscresources:requests:storage:1Gi 执行kubectlapplyffastcfsstorageClass。ymlkubectlapplyffastcfsdynamicpv。yml三、总结 FastCFS支持大规模的集群,对服务器要求不高,但是由于没有统一配置中心,如果节点比较多的话,配置会稍显麻烦,虽然官方也可以fcfs。sh运维工具,但是还是不够好用,可以考虑用ansible等工具来安装,后来笔者会写一个ansible的playbook来简化安装FastCFS集群。