分别在节点部署FastDFS
每台节点部署FastDFS,具体部署方式详见其他文章
集群配置的区别在于配置文件 vi /etc/fdfs/storage.conf 添加
tracker_server = 10.10.10.203:22122
tracker_server = 10.10.10.206:22122
也就是有tracker节点有几个这里就添加几个
上传文件进行测试
配置client.conf
vi /etc/fdfs/client.conf 添加
tracker_server=10.10.10.203:22122
tracker_server=10.10.10.206:22122
执行命令
fdfs_upload_file /etc/fdfs/client.conf http.conf
http.conf是我要上传的文件 内容如下:
# HTTP default content type
http.default_content_type = application/octet-stream
# MIME types mapping filename
# MIME types file format: MIME_type extensions
# such as: image/jpeg jpeg jpg jpe
# you can use apache's MIME file: mime.types
http.mime_types_filename = mime.types
# if use token to anti-steal
# default value is false (0)
http.anti_steal.check_token = false
# token TTL (time to live), seconds
# default value is 600
http.anti_steal.token_ttl = 900
# secret key to generate anti-steal token
# this parameter must be set when http.anti_steal.check_token set to true
# the length of the secret key should not exceed 128 bytes
http.anti_steal.secret_key = FastDFS1234567890
# return the content of the file when check token fail
# default value is empty (no file sepecified)
http.anti_steal.token_check_fail = /home/yuqing/fastdfs/conf/anti-steal.jpg
# if support multi regions for HTTP Range
# default value is true
http.multi_range.enabed = true
上传后会返回一串文件所在的路径
[root@localhost-203-root-all fdfs]# fdfs_upload_file /etc/fdfs/client.conf http.conf
group1/M00/00/00/CgoKy2EvT_mATZDVAAADxc1O66M88.conf
打开这个文件发会现跟http.conf内容一模一样
此时在另外一个节点也可以查看这个文件
其中group1/M00这个路径是配置的存储路径opt/fastdfs_storage_data/data,后面就是具体的文件路径 cat /opt/fastdfs_storage_data/data/00/00/CgoKy2EvT_mATZDVAAADxc1O66M88.conf 根据第一个节点返回的路径去第二个节点的路径找,文件名是不一样的