码迷,mamicode.com
首页 > 其他好文 > 详细

fastdfs配置

时间:2019-08-27 19:03:29      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:trunc   ip地址   设置   hit   复制   sub   net   The   mamicode   

有3个配置文件,所在的目录:/etc/fdfs

client.conf.sample  storage.conf.sample  tracker.conf.sample

复制上面的3个文件,文件名去掉sample

修改tracker.conf配置文件

1,设置有效

# is this config file disabled
# false for enabled
# true for disabled
disabled=false

2,绑定IP地址,不设置代表本机的所有IP地址

# bind an address of this host
# empty for bind all addresses of this host
bind_addr=

3,修改端口号

# the tracker server port
port=22122

4,修改数据和日志的目录

#the base path to store data and log files
base_path=/home/自己的用户名/文件夹名

修改storage.conf配置文件(存储节点)

1,

2,

3,

4,

和tracker一样

5,设置存储目录的数量和每个目录的实际路径

# path(disk or mount point) count, default value is 1
# 如果把下面的1修改为3,则store_path1和store_path2,就必须设置
store_path_count=1

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/home/ys/fastdfs/storage
#store_path1=/home/yuqing/fastdfs2

6,指定tracker进程所在的机器的IP和使用的端口

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=192.168.209.121:22122

7,设置当前节点所属的组

# the name of the group this storage server belongs to
#
# comment or remove this item for fetching from tracker server,
# in this case, use_storage_id must set to true in tracker.conf,
# and storage_ids.conf must be configed correctly.
group_name=group1

修改client.conf配置文件

1,修改数据和日志的目录

# the base path to store log files
base_path=/home/ys/fastdfs/client

2,指定tracker进程所在的机器的IP和使用的端口

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=10.210.65.125:22122

tracker启动命令

fdfs_trackerd /etc/fdfs/tracker.conf

用下面的确认是否启动成功

ps aux | grep fdfs*

如果有下面的结果,说明启动成功。如果没有,去设置的log文件夹看trackerd.log文件里的错误消息。

ys        1260  0.2  0.2  90452  5804 ?        Sl   22:15   0:00 fdfs_trackerd /etc/fdfs/tracker.conf

启动成功后,是守护进程。

重新启动或者停止的命令

sudo fdfs_trackerd /etc/fdfs/tracker.conf restart/stop

storage启动命令

fdfs_storaged /etc/fdfs/storage.conf

用下面的确认是否启动成功

ps aux | grep fdfs*

如果有下面的结果,说明启动成功。如果没有,去设置的log文件夹看storaged.log文件里的错误消息。

ys        1352  0.0  0.1  85200  3424 ?        Sl   22:26   0:00 fdfs_storaged /etc/fdfs/storage.conf

启动成功后,是守护进程。

重新启动或者停止的命令

sudo fdfs_storaged /etc/fdfs/storage.conf restart/stop

实验一下tracker和storage是否正常工作,用下面命令

fdfs_monitor /etc/fdfs/client.conf

如果显示下面的结果,说明正常工作。

主要看storage是否是ACTIVE

[2019-08-21 22:31:35] DEBUG - base_path=/home/ys/fastdfs/client, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

server_count=1, server_index=0

tracker server is 192.168.0.200:22122

group count: 1

Group 1:
group name = group1
disk total space = 60217 MB
disk free space = 42740 MB
trunk free space = 0 MB
storage server count = 1
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0

        Storage 1:
                id = 192.168.0.200
                ip_addr = 192.168.0.200 (ys-VirtualBox)  ACTIVE
                http domain =
                version = 5.12
                join time = 2019-08-21 22:20:33
                up time = 2019-08-21 22:26:46
                total storage = 60217 MB
                free storage = 42740 MB
                upload priority = 10
                store_path_count = 1
                subdir_count_per_path = 256
                storage_port = 23000
                storage_http_port = 8888
                current_write_path = 0
                source storage id =
                if_trunk_server = 0
                connection.alloc_count = 256
                connection.current_count = 0
                connection.max_count = 0
                total_upload_count = 0
                success_upload_count = 0
                total_append_count = 0
                success_append_count = 0
                total_modify_count = 0
                success_modify_count = 0
                total_truncate_count = 0
                success_truncate_count = 0
                total_set_meta_count = 0
                success_set_meta_count = 0
                total_delete_count = 0
                success_delete_count = 0
                total_download_count = 0
                success_download_count = 0
                total_get_meta_count = 0
                success_get_meta_count = 0
                total_create_link_count = 0
                success_create_link_count = 0
                total_delete_link_count = 0
                success_delete_link_count = 0
                total_upload_bytes = 0
                success_upload_bytes = 0
                total_append_bytes = 0
                success_append_bytes = 0
                total_modify_bytes = 0
                success_modify_bytes = 0
                stotal_download_bytes = 0
                success_download_bytes = 0
                total_sync_in_bytes = 0
                success_sync_in_bytes = 0
                total_sync_out_bytes = 0
                success_sync_out_bytes = 0
                total_file_open_count = 0
                success_file_open_count = 0
                total_file_read_count = 0
                success_file_read_count = 0
                total_file_write_count = 0
                success_file_write_count = 0
                last_heart_beat_time = 2019-08-21 22:31:15
                last_source_update = 1970-01-01 08:00:00
                last_sync_update = 1970-01-01 08:00:00
                last_synced_timestamp = 1970-01-01 08:00:00

这时,就可以上传和下载文件了

上传

fdfs_upload_file /etc/fdfs/client.conf 要上传的文件

执行结果:

group1/M00/00/00/wKgAyF1dWGyAbQF1AAAACrGxDWg811.txt

group1/M00/00/00里的第一个00是文件夹,第二00也是文件夹,

去storage的【base_path=/home/自己的用户名/文件夹名】文件夹里,可以找到上传的文件。

下载

fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKgAyF1dWGyAbQF1AAAACrGxDWg811.txt

指定上传时生产的【fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKgAyF1dWGyAbQF1AAAACrGxDWg811.txt】的名字,就能下载到本地。

c/c++ 学习互助QQ群:877684253

技术图片

本人微信:xiaoshitou5854

fastdfs配置

标签:trunc   ip地址   设置   hit   复制   sub   net   The   mamicode   

原文地址:https://www.cnblogs.com/xiaoshiwang/p/11420120.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!