• FastDFS的安装及上传下载(二)


     

    百度云:所有附件的地址

    一 安装前的检查

    检查Linux上是否安装了 gcc、libevent、libevent-devel,执行如下yum命令检查:

    1. [root@node02 ~]# yum list installed | grep gcc
    2. gcc.x86_64 4.8.5-39.el7 @base
    3. gcc-c++.x86_64 4.8.5-39.el7 @base
    4. libgcc.x86_64 4.8.5-39.el7 @base
    5. [root@node02 ~]# yum list installed | grep libevent
    6. libevent.x86_64 2.0.21-4.el7 @anaconda
    7. libevent-devel.x86_64 2.0.21-4.el7 @base
    8. [root@node02 ~]# yum list installed | grep libevent-devel
    9. libevent-devel.x86_64 2.0.21-4.el7 @base
    10. [root@node02 ~]#
    ​如果没有安装,则需进行安装,执行如下命令安装:
    
    yum install gcc libevent libevent-devel -y
    

    二 安装 libfastcommon 库

    libfastcommon 库是 FastDFS 文件系统运行需要的公共 C 语言函数库;

    1. [root@node02 mnt]# tar -zvxf libfastcommon-1.0.36.tar.gz
    2. libfastcommon-1.0.36/
    3. libfastcommon-1.0.36/HISTORY
    4. libfastcommon-1.0.36/INSTALL
    5. libfastcommon-1.0.36/README
    6. [root@node02 libfastcommon-1.0.36]# ./make.sh
    7. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o hash.o hash.c
    8. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o chain.o chain.c
    9. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o shared_func.o shared_func.c
    10. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o ini_file_reader.o ini_file_reader.c
    11. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o logger.o logger.c
    12. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o sockopt.o sockopt.c
    13. [root@node02 libfastcommon-1.0.36]# ./make.sh install
    14. mkdir -p /usr/lib64
    15. mkdir -p /usr/lib
    16. install -m 755 libfastcommon.so /usr/lib64
    17. install -m 755 libfastcommon.so /usr/lib
    18. mkdir -p /usr/include/fastcommon
    19. install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h /usr/include/fastcommon
    20. [root@node02 libfastcommon-1.0.36]#

    至此 libfastcommon 库安装完毕;

    三 安装FastDFS

    1、下载FastDFS,下载地址:https://github.com/happyfish100/fastdfs/releases

    注:上面从百度云下载也可以

    2、解压下载下来的tar.gz包:tar -zxvf fastdfs-5.11.tar.gz

    3、切换到解压后的目录:cd fastdfs-5.11

    4、执行编译: ./make.sh

    5、然后再执行安装 ./make.sh install

    至此FastDFS安装完成,安装后所有编译出来的文件存放在/usr/bin目录下,所有配置文件存放在/etc/fdfs目录下; 使用命令查看: ll /usr/bin/fdfs*

    6、另外注意需要把解压后的fastdfs-5.11/conf目录下的两个文件拷贝到/etc/fdfs/ 1、cp http.conf /etc/fdfs/ 2、cp mime.types /etc/fdfs/

    这两个文件后续需要用到,所以先拷贝过去;

    代码如下:

    1. [root@node02 mnt]# tar -zvxf fastdfs-5.11.tar.gz
    2. fastdfs-5.11/
    3. fastdfs-5.11/COPYING-3_0.txt
    4. fastdfs-5.11/HISTORY
    5. fastdfs-5.11/INSTALL
    6. fastdfs-5.11/README.md
    7. fastdfs-5.11/client/
    8. [root@node02 fastdfs-5.11]# ./make.sh
    9. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -c -o ../common/fdfs_global.o ../common/fdfs_global.c -I../common -I/usr/include/fastcommon
    10. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -c -o tracker_proto.o tracker_proto.c -I../common -I/usr/include/fastcommon
    11. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -c -o tracker_mem.o tracker_mem.c -I../common -I/usr/include/fastcommon
    12. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -c -o tracker_service.o tracker_service.c -I../common -I/usr/include/fastcommon
    13. cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -c -o tracker_status.o tracker_status.c -I../common -I/usr/include/fastcommon
    14. [root@node02 fastdfs-5.11]# ./make.sh install
    15. mkdir -p /usr/bin
    16. mkdir -p /etc/fdfs
    17. cp -f fdfs_trackerd /usr/bin
    18. if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi
    19. if [ ! -f /etc/fdfs/storage_ids.conf.sample ]; then cp -f ../conf/storage_ids.conf /etc/fdfs/storage_ids.conf.sample; fi
    20. mkdir -p /usr/bin
    21. mkdir -p /etc/fdfs
    22. cp -f fdfs_storaged /usr/bin
    23. if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi
    24. [root@node02 fastdfs-5.11]# ll /usr/bin/fdfs*
    25. -rwxr-xr-x 1 root root 317344 118 21:40 /usr/bin/fdfs_appender_test
    26. -rwxr-xr-x 1 root root 317120 118 21:40 /usr/bin/fdfs_appender_test1
    27. -rwxr-xr-x 1 root root 303976 118 21:40 /usr/bin/fdfs_append_file
    28. -rwxr-xr-x 1 root root 303696 118 21:40 /usr/bin/fdfs_crc32
    29. -rwxr-xr-x 1 root root 304032 118 21:40 /usr/bin/fdfs_delete_file
    30. -rwxr-xr-x 1 root root 304768 118 21:40 /usr/bin/fdfs_download_file
    31. -rwxr-xr-x 1 root root 304360 118 21:40 /usr/bin/fdfs_file_info
    32. -rwxr-xr-x 1 root root 322256 118 21:40 /usr/bin/fdfs_monitor
    33. -rwxr-xr-x 1 root root 1111376 118 21:40 /usr/bin/fdfs_storaged
    34. -rwxr-xr-x 1 root root 327248 118 21:40 /usr/bin/fdfs_test
    35. -rwxr-xr-x 1 root root 326464 118 21:40 /usr/bin/fdfs_test1
    36. -rwxr-xr-x 1 root root 453720 118 21:40 /usr/bin/fdfs_trackerd
    37. -rwxr-xr-x 1 root root 304960 118 21:40 /usr/bin/fdfs_upload_appender
    38. -rwxr-xr-x 1 root root 305984 118 21:40 /usr/bin/fdfs_upload_file
    39. [root@node02 fastdfs-5.11]#
    40. [root@node02 fastdfs-5.11]# cd conf/
    41. [root@node02 conf]# ll
    42. 总用量 84
    43. -rw-rw-r-- 1 root root 23981 63 2017 anti-steal.jpg
    44. -rw-rw-r-- 1 root root 1461 63 2017 client.conf
    45. -rw-rw-r-- 1 root root 955 63 2017 http.conf
    46. -rw-rw-r-- 1 root root 31172 63 2017 mime.types
    47. -rw-rw-r-- 1 root root 7927 63 2017 storage.conf
    48. -rw-rw-r-- 1 root root 105 63 2017 storage_ids.conf
    49. -rw-rw-r-- 1 root root 7389 63 2017 tracker.conf
    50. [root@node02 conf]# cp http.conf /etc/fdfs/
    51. [root@node02 conf]# cp mime.types /etc/fdfs/
    52. [root@node02 conf]#

    四 FastDFS配置

    FastDFS安装后配置文件位于/etc/fdfs/目录下,修改该目录下的配置文件;把所有的.sample后缀都去掉,使用 mv 命令改文件名,去掉文件名后缀;

    1. [root@node02 etc]# cd fdfs/
    2. [root@node02 fdfs]# ll
    3. 总用量 60
    4. -rw-r--r-- 1 root root 1461 118 21:40 client.conf.sample
    5. -rw-r--r-- 1 root root 955 118 21:43 http.conf
    6. -rw-r--r-- 1 root root 31172 118 21:44 mime.types
    7. -rw-r--r-- 1 root root 7927 118 21:40 storage.conf.sample
    8. -rw-r--r-- 1 root root 105 118 21:40 storage_ids.conf.sample
    9. -rw-r--r-- 1 root root 7389 118 21:40 tracker.conf.sample
    10. [root@node02 fdfs]# pwd
    11. /etc/fdfs
    12. [root@node02 fdfs]# mv client.conf.sample client.conf
    13. [root@node02 fdfs]# mv storage.conf.sample storage.conf
    14. [root@node02 fdfs]# mv storage_ids.conf.sample storage_ids.conf
    15. [root@node02 fdfs]# mv tracker.conf.sample tracker.conf
    16. [root@node02 fdfs]# ll
    17. 总用量 60
    18. -rw-r--r-- 1 root root 1461 118 21:40 client.conf
    19. -rw-r--r-- 1 root root 955 118 21:43 http.conf
    20. -rw-r--r-- 1 root root 31172 118 21:44 mime.types
    21. -rw-r--r-- 1 root root 7927 118 21:40 storage.conf
    22. -rw-r--r-- 1 root root 105 118 21:40 storage_ids.conf
    23. -rw-r--r-- 1 root root 7389 118 21:40 tracker.conf
    24. [root@node02 fdfs]#
    • 修改tracker.conf文件

      base_path=/opt/fastdfs/tracker

    • 修改storage.conf文件

      base_path=/opt/fastdfs/storage

      store_path0=/opt/fastdfs/storage/files

      tracker_server=192.168.180.104:22122

    1. [root@node02 fdfs]# vim tracker.conf
    2. # is this config file disabled
    3. # false for enabled
    4. # true for disabled
    5. disabled=false
    6. # bind an address of this host
    7. # empty for bind all addresses of this host
    8. bind_addr=
    9. # the tracker server port
    10. port=22122
    11. # connect timeout in seconds
    12. # default value is 30s
    13. connect_timeout=30
    14. # network timeout in seconds
    15. # default value is 30s
    16. network_timeout=60
    17. # the base path to store data and log files
    18. base_path=/opt/fastdfs/tracker
    19. # max concurrent connections this server supported
    20. max_connections=256
    21. # accept thread count
    22. # default value is 1
    23. # since V4.07
    24. accept_threads=1
    25. # work thread count, should <= max_connections
    26. # default value is 4
    27. # since V2.00
    28. work_threads=4
    29. # min buff size
    30. # default value 8KB
    31. min_buff_size = 8KB
    32. # max buff size
    33. # default value 128KB
    34. max_buff_size = 128KB
    35. [root@node02 fdfs]# cat storage.conf
    36. # is this config file disabled
    37. # false for enabled
    38. # true for disabled
    39. disabled=false
    40. # the name of the group this storage server belongs to
    41. #
    42. # comment or remove this item for fetching from tracker server,
    43. # in this case, use_storage_id must set to true in tracker.conf,
    44. # and storage_ids.conf must be configed correctly.
    45. group_name=group1
    46. # bind an address of this host
    47. # empty for bind all addresses of this host
    48. bind_addr=
    49. # if bind an address of this host when connect to other servers
    50. # (this storage server as a client)
    51. # true for binding the address configed by above parameter: "bind_addr"
    52. # false for binding any address of this host
    53. client_bind=true
    54. # the storage server port
    55. port=23000
    56. # connect timeout in seconds
    57. # default value is 30s
    58. connect_timeout=30
    59. # network timeout in seconds
    60. # default value is 30s
    61. network_timeout=60
    62. # heart beat interval in seconds
    63. heart_beat_interval=30
    64. # disk usage report interval in seconds
    65. stat_report_interval=60
    66. # the base path to store data and log files
    67. base_path=/opt/fastdfs/storage
    68. # max concurrent connections the server supported
    69. # default value is 256
    70. # more max_connections means more memory will be used
    71. max_connections=256
    72. # the buff size to recv / send data
    73. # this parameter must more than 8KB
    74. # default value is 64KB
    75. # since V2.00
    76. buff_size = 256KB
    77. # accept thread count
    78. # default value is 1
    79. # since V4.07
    80. accept_threads=1
    81. # work thread count, should <= max_connections
    82. # work thread deal network io
    83. # default value is 4
    84. # since V2.00
    85. work_threads=4
    86. # if disk read / write separated
    87. ## false for mixed read and write
    88. ## true for separated read and write
    89. # default value is true
    90. # since V2.00
    91. disk_rw_separated = true
    92. # disk reader thread count per store base path
    93. # for mixed read / write, this parameter can be 0
    94. # default value is 1
    95. # since V2.00
    96. disk_reader_threads = 1
    97. # disk writer thread count per store base path
    98. # for mixed read / write, this parameter can be 0
    99. # default value is 1
    100. # since V2.00
    101. disk_writer_threads = 1
    102. # when no entry to sync, try read binlog again after X milliseconds
    103. # must > 0, default value is 200ms
    104. sync_wait_msec=50
    105. # after sync a file, usleep milliseconds
    106. # 0 for sync successively (never call usleep)
    107. sync_interval=0
    108. # storage sync start time of a day, time format: Hour:Minute
    109. # Hour from 0 to 23, Minute from 0 to 59
    110. sync_start_time=00:00
    111. # storage sync end time of a day, time format: Hour:Minute
    112. # Hour from 0 to 23, Minute from 0 to 59
    113. sync_end_time=23:59
    114. # write to the mark file after sync N files
    115. # default value is 500
    116. write_mark_file_freq=500
    117. # path(disk or mount point) count, default value is 1
    118. store_path_count=1
    119. # store_path#, based 0, if store_path0 not exists, it's value is base_path
    120. # the paths must be exist
    121. store_path0=/opt/fastdfs/storage/files
    122. #store_path1=/home/yuqing/fastdfs2
    123. # subdir_count * subdir_count directories will be auto created under each
    124. # store_path (disk), value can be 1 to 256, default value is 256
    125. subdir_count_per_path=256
    126. # tracker_server can ocur more than once, and tracker_server format is
    127. # "host:port", host can be hostname or ip address
    128. tracker_server=192.168.180.104:22122
    129. #standard log level as syslog, case insensitive, value list:
    130. ### emerg for emergency
    131. ### alert
    132. ### crit for critical
    133. ### error
    134. ### warn for warning
    135. ### notice
    136. ### info
    137. ### debug
    138. log_level=info
    139. #unix group name to run this program,
    140. #not set (empty) means run by the group of current user
    141. run_by_group=
    142. #unix username to run this program,
    143. #not set (empty) means run by current user
    144. run_by_user=
    145. # allow_hosts can ocur more than once, host can be hostname or ip address,
    146. # "*" (only one asterisk) means match all ip addresses
    147. # we can use CIDR ips like 192.168.5.64/26
    148. # and also use range like these: 10.0.1.[0-254] and host[01-08,20-25].domain.com
    149. # for example:
    150. # allow_hosts=10.0.1.[1-15,20]
    151. # allow_hosts=host[01-08,20-25].domain.com
    152. # allow_hosts=192.168.5.64/26
    153. allow_hosts=*
    154. # the mode of the files distributed to the data path
    155. # 0: round robin(default)
    156. # 1: random, distributted by hash code
    157. file_distribute_path_mode=0
    158. # valid when file_distribute_to_path is set to 0 (round robin),
    159. # when the written file count reaches this number, then rotate to next path
    160. # default value is 100
    161. file_distribute_rotate_count=100
    162. # call fsync to disk when write big file
    163. # 0: never call fsync
    164. # other: call fsync when written bytes >= this bytes
    165. # default value is 0 (never call fsync)
    166. fsync_after_written_bytes=0
    167. # sync log buff to disk every interval seconds
    168. # must > 0, default value is 10 seconds
    169. sync_log_buff_interval=10
    170. # sync binlog buff / cache to disk every interval seconds
    171. # default value is 60 seconds
    172. sync_binlog_buff_interval=10
    173. # sync storage stat info to disk every interval seconds
    174. # default value is 300 seconds
    175. sync_stat_file_interval=300
    176. # thread stack size, should >= 512KB
    177. # default value is 512KB
    178. thread_stack_size=512KB
    179. # the priority as a source server for uploading file.
    180. # the lower this value, the higher its uploading priority.
    181. # default value is 10
    182. upload_priority=10
    183. # the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
    184. # multi aliases split by comma. empty value means auto set by OS type
    185. # default values is empty
    186. if_alias_prefix=
    187. # if check file duplicate, when set to true, use FastDHT to store file indexes
    188. # 1 or yes: need check
    189. # 0 or no: do not check
    190. # default value is 0
    191. check_file_duplicate=0
    192. # file signature method for check file duplicate
    193. ## hash: four 32 bits hash code
    194. ## md5: MD5 signature
    195. # default value is hash
    196. # since V4.01
    197. file_signature_method=hash
    198. # namespace for storing file indexes (key-value pairs)
    199. # this item must be set when check_file_duplicate is true / on
    200. key_namespace=FastDFS
    201. # set keep_alive to 1 to enable persistent connection with FastDHT servers
    202. # default value is 0 (short connection)
    203. keep_alive=0
    204. # you can use "#include filename" (not include double quotes) directive to
    205. # load FastDHT server list, when the filename is a relative path such as
    206. # pure filename, the base path is the base path of current/this config file.
    207. # must set FastDHT server list when check_file_duplicate is true / on
    208. # please see INSTALL of FastDHT for detail
    209. ##include /home/yuqing/fastdht/conf/fdht_servers.conf
    210. # if log to access log
    211. # default value is false
    212. # since V4.00
    213. use_access_log = false
    214. # if rotate the access log every day
    215. # default value is false
    216. # since V4.00
    217. rotate_access_log = false
    218. # rotate access log time base, time format: Hour:Minute
    219. # Hour from 0 to 23, Minute from 0 to 59
    220. # default value is 00:00
    221. # since V4.00
    222. access_log_rotate_time=00:00
    223. # if rotate the error log every day
    224. # default value is false
    225. # since V4.02
    226. rotate_error_log = false
    227. # rotate error log time base, time format: Hour:Minute
    228. # Hour from 0 to 23, Minute from 0 to 59
    229. # default value is 00:00
    230. # since V4.02
    231. error_log_rotate_time=00:00
    232. # rotate access log when the log file exceeds this size
    233. # 0 means never rotates log file by log file size
    234. # default value is 0
    235. # since V4.02
    236. rotate_access_log_size = 0
    237. # rotate error log when the log file exceeds this size
    238. # 0 means never rotates log file by log file size
    239. # default value is 0
    240. # since V4.02
    241. rotate_error_log_size = 0
    242. # keep days of the log files
    243. # 0 means do not delete old log files
    244. # default value is 0
    245. log_file_keep_days = 0
    246. # if skip the invalid record when sync file
    247. # default value is false
    248. # since V4.02
    249. file_sync_skip_invalid_record=false
    250. # if use connection pool
    251. # default value is false
    252. # since V4.05
    253. use_connection_pool = false
    254. # connections whose the idle time exceeds this time will be closed
    255. # unit: second
    256. # default value is 3600
    257. # since V4.05
    258. connection_pool_max_idle_time = 3600
    259. # use the ip address of this storage server if domain_name is empty,
    260. # else this domain name will ocur in the url redirected by the tracker server
    261. http.domain_name=
    262. # the port of the web server on this storage server
    263. http.server_port=8888
    264. [root@node02 fdfs]#
  • 相关阅读:
    计算机毕业设计(42)java小程序毕设作品之小说电子书阅读小程序系统
    Redis——Linux下安装以及命令操作
    错误记录-FileStream访问被拒绝
    C#面:C#面向对象的思想主要包括什么?
    Hi,我是ChunJun,一个有趣好用的开源项目
    并发bug之源(二)-有序性
    【广州华锐互动】全屋智能家电VR虚拟仿真演示系统
    NIO+代码实现---Buffer+Channel+Selector
    【iOS】Category、Extension和关联对象
    安装部署 Guacamole 远程桌面网关
  • 原文地址:https://blog.csdn.net/qq_29860591/article/details/127736501