ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
  1 安装 1.1 准备环境 三台主机(主机数应为副本数的倍数),主机名为xhw380,xhw381,xhw382.每台主机上用root用户进行操作。 1.2 安装 在物理机上使用rpm包安装,rpm包下载源 https://buildlogs.centos.org/centos/7/storage/x86_64/gluster-3.8/ ![](https://box.kancloud.cn/4e1200deac21c8ce9cc7d4cf51ea4dfb_753x189.png) 2 操作 2.1 开启服务 `systemctl start glusterd.service` 2.2 查看服务 `systemctl status glusterd.service` 2.3 添加节点到集群 不需要添加执行操作的机器,例如在xhw380上操作时,只需要执行: ~~~ gluster peer probe xhw381 gluster peer probe xhw382 ~~~ 2.4 从集群中删除节点 `gluster peer detach nodename` 2.5 查看节点状态 可以看到除自己之外的所有节点 `gluster peer status` ![](https://box.kancloud.cn/a50dd751a37b2aa2402a29c90bec9337_408x178.png) 2.6 配置volume GlusterFS中的volume的模式有很多中,包括以下几种:+ 1) 分布卷(默认模式):即DHT, 也叫 分布卷: 将文件已hash算法随机分布到 一台服务器节点中存储。 2) 复制模式:即AFR, 创建volume 时带 replica x 数量: 将文件复制到 replica x 个节点中。 3) 条带模式:即Striped, 创建volume 时带 stripe x 数量: 将文件切割成数据块,分别存储到 stripe x 个节点中 ( 类似raid 0 )。在大文件读取上有优势。 4) 注:条带化有个最小限制:128KB。即当文件大小小于这个参数时,不进行分隔。其他储存单元中,存在同名文件,但是大小为0. 5) 分布式条带模式:是DHT 与 Striped 的组合型。 6) 分布式复制模式:是DHT 与 AFR 的组合型。 7) 条带复制卷模式:是 Striped 与 AFR 的组合型。 8) 三种模式混合 根据业务需求,我们创建复制数为3的复制卷 ~~~ xhw380: mkdir /data01/gfs xhw381: mkdir /data01/gfs xhw382: mkdir /data01/gfs ~~~ 在任意一台主机上创建复制卷: `gluster volume create cbbs replica 3 xhw{380,381,382}:/data01/gfs` 注:节点数一定要是复制数的倍数。 ~~~ 启动卷:gluster volume start cbbs 查看卷信息:gluster volume info 挂载客户端(每台主机执行): mount.glusterfs xhw380:/cbbs /cbbs/gfs 停止卷:gluster volume stop cbbs 删除卷:gluster volume delete cbbs ~~~ 3 优化 具体选项: ~~~ Auth_allow  #IP访问授权;缺省值(*.allow all);合法值:Ip地址 Cluster.min-free-disk  #剩余磁盘空间阀值;缺省值(10%);合法值:百分比 Cluster.stripe-block-size  #条带大小;缺省值(128KB);合法值:字节 Network.frame-timeout  #请求等待时间;缺省值(1800s);合法值:1-1800 Network.ping-timeout  #客户端等待时间;缺省值(42s);合法值:0-42 Nfs.disabled  #关闭NFS服务;缺省值(Off);合法值:Off|on Performance.io-thread-count  #IO线程数;缺省值(16);合法值:0-65 Performance.cache-refresh-timeout  #缓存校验时间;缺省值(1s);合法值:0-61 Performance.cache-size  #读缓存大小;缺省值(32MB);合法值:字节 Performance.quick-read: #优化读取小文件的性能 Performance.read-ahead: #用预读的方式提高读取的性能,有利于应用频繁持续性的访问文件,当应用完成当前数据块读取的时候,下一个数据块就已经准备好了。 Performance.write-behind:先写入缓存内,在写入硬盘,以提高写入的性能。 Performance.io-cache:缓存已经被读过的。 ~~~ 3.1 开启指定volume的配额 `gluster volume quota cbbs enable` 3.2 限制指定volume的配额 `gluster volume quota cbbs limit-usage / 100GB` 3.3 打开预读方式访问存储 `gluster volume set cbbs performance.read-ahead on` 3.4 设置cache大小,默认32MB `gluster volume set cbbs performance.cache-size 4GB` 3.5 设置 io 线程, 太大会导致进程崩溃 `gluster volume set cbbs performance.io-thread-count 16` 3.6 设置网络检测时间 `gluster volume set cbbs network.ping-timeout 10` 3.7 设置写缓冲区的大小, 默认1M `gluster volume set cbbs performance.write-behind-window-size 1024MB` 4 监控及维护 4.1 查看卷状态 `gluster volume status cbbs` 4.2 查看配额 `gluster volume quota cbbs list` 4.3 I/O信息查看 Profile Command 提供接口查看一个卷中的每一个brick的IO信息。 启动profiling,之后则可以进行IO信息查看: ` gluster volume profile cbbs start` 4.3.1 查看I/O信息: ` gluster volume profile cbbs info` 4.3.2 查看后关闭profiling功能 4.4 TOP监控 Top command 允许你查看bricks的性能例如:read, write, file open calls, file read calls, file write calls, directory open calls, and directory real calls 所有的查看都可以设置top数,默认100 4.4.1 查看当前打开的文件数及最大打开的文件数 `gluster volume top VOLNAME open [brick BRICK-NAME] [list-cnt cnt]` ![](https://box.kancloud.cn/88c5e5a10a6cf1a24c5d7944fccd7aaf_662x316.png) 4.4.2 查看读频率最高的文件 `gluster volume top VOLNAME read [brick BRICK-NAME] [list-cnt cnt]` ![](https://box.kancloud.cn/5ff957ac3220cf82eb0aaa4dc2230031_437x234.png) 4.4.3 查看写频率最高的文件 `gluster volume top VOLNAME write [brick BRICK-NAME] [list-cnt cnt]` ![](https://box.kancloud.cn/ed399689036678f7cad3d34b5a2c452a_568x503.png) 4.4.4 查看打开频率最高的目录 `gluster volume top VOLNAME opendir [brick BRICK-NAME] [list-cnt cnt]` 4.4.5 查看读写频率最高的目录 `gluster volume top VOLNAME readdir [brick BRICK-NAME] [list-cnt cnt]` 4.4.6 查看每个Brick的读性能 ~~~ gluster volume top VOLNAME read-perf [bs blk-size count count] [brick BRICK-NAME] [list-cnt cnt] ~~~ ![](https://box.kancloud.cn/0920e1b8e54b45c0251f67d9b64c0159_642x243.png) 4.4.7 查看每个Brick的写性能 ~~~ gluster volume top VOLNAME write-perf [bs blk-size count count] [brick BRICK-NAME] [list-cnt cnt] ~~~ ![](https://box.kancloud.cn/d5bed306faeae50940f4a1cf8ed41141_726x511.png)