快速开始

编译构建

使用如下命令同时构建server,client及相关的依赖:

  1. $ git clone http://github.com/chubaofs/chubaofs.git
  2. $ cd chubaofs
  3. $ make build

如果构建成功,将在build/bin 目录中生成可执行文件cfs-servercfs-client

集群部署

启动资源管理节点

  1. nohup ./cfs-server -c master.json &

示例 master.json :注意:master服务最少应该启动3个节点实例

  1. {
  2. "role": "master",
  3. "ip": "192.168.31.173",
  4. "listen": "80",
  5. "prof":"10088",
  6. "id":"1",
  7. "peers": "1:192.168.31.173:80,2:192.168.31.141:80,3:192.168.30.200:80",
  8. "retainLogs":"20000",
  9. "logDir": "/export/Logs/master",
  10. "logLevel":"info",
  11. "walDir":"/export/Data/master/raft",
  12. "storeDir":"/export/Data/master/rocksdbstore",
  13. "consulAddr": "http://consul.prometheus-cfs.local",
  14. "exporterPort": 9510,
  15. "clusterName":"cfs",
  16. "metaNodeReservedMem": "134217728"
  17. }

详细配置参数请参考 资源管理节点

启动元数据节点

  1. nohup ./cfs-server -c metanode.json &

示例 meta.json :注意:metanode服务最少应该启动3个节点实例

  1. {
  2. "role": "metanode",
  3. "listen": "9021",
  4. "prof": "9092",
  5. "logLevel": "info",
  6. "metadataDir": "/export/Data/metanode",
  7. "logDir": "/export/Logs/metanode",
  8. "raftDir": "/export/Data/metanode/raft",
  9. "raftHeartbeatPort": "9093",
  10. "raftReplicaPort": "9094",
  11. "totalMem": "17179869184",
  12. "consulAddr": "http://consul.prometheus-cfs.local",
  13. "exporterPort": 9511,
  14. "masterAddr": [
  15. "192.168.31.173:80",
  16. "192.168.31.141:80",
  17. "192.168.30.200:80"
  18. ]
  19. }

详细配置参数请参考 元数据节点.

启动数据节点

  • 准备数据目录

推荐 使用单独磁盘作为数据目录,配置多块磁盘能够达到更高的性能。

磁盘准备

1.1 查看机器磁盘信息,选择给ChubaoFS使用的磁盘

  1. fdisk -l

1.2 格式化磁盘,建议格式化为XFS

  1. mkfs.xfs -f /dev/sdx

1.3 创建挂载目录

  1. mkdir /data0

1.4 挂载磁盘

  1. mount /dev/sdx /data0
  • 启动数据节点
  1. nohup ./cfs-server -c datanode.json &

示例 datanode.json :注意:datanode服务最少应该启动4个节点实例

  1. {
  2. "role": "datanode",
  3. "listen": "6000",
  4. "prof": "6001",
  5. "logDir": "/export/Logs/datanode",
  6. "logLevel": "info",
  7. "raftHeartbeat": "9095",
  8. "raftReplica": "9096",
  9. "raftDir":"export/Logs/datanode/raft",
  10. "consulAddr": "http://consul.prometheus-cfs.local",
  11. "exporterPort": 9512,
  12. "masterAddr": [
  13. "192.168.31.173:80",
  14. "192.168.31.141:80",
  15. "192.168.30.200:80"
  16. ],
  17. "rack": "",
  18. "disks": [
  19. "/data0:21474836480",
  20. "/data1:21474836480"
  21. ]
  22. }

详细配置参数请参考 数据节点.

创建Volume卷

  1. curl -v "http://192.168.31.173/admin/createVol?name=test&capacity=10000&owner=cfs"
  2.  
  3. 如果执行性能测试,请调用相应的API,创建足够多的数据分片(data partition),如果集群中有8块磁盘,那么需要创建80datapartition

挂载客户端

  • 运行 modprobe fuse 插入FUSE内核模块。

  • 运行 yum install -y fuse 安装libfuse。

  • 运行 nohup client -c fuse.json & 启动客户端。

样例 fuse.json ,

  1. {
  2. "mountPoint": "/mnt/fuse",
  3. "volName": "test",
  4. "owner": "cfs",
  5. "masterAddr": "192.168.31.173:80,192.168.31.141:80,192.168.30.200:80",
  6. "logDir": "/export/Logs/client",
  7. "profPort": "10094",
  8. "logLevel": "info"
  9. }

详细配置参数请参考 客户端.

升级注意事项

集群数据节点和元数据节点升级前,请先禁止集群自动为卷扩容数据分片.

  • 冻结集群
  1. curl -v "http://192.168.31.173/cluster/freeze?enable=true"
  • 升级节点
  • 开启自动扩容数据分片
  1. curl -v "http://192.168.31.173/cluster/freeze?enable=false"