├── .gitignore ├── README.md ├── docker-compose.yml ├── nginx.conf └── storage.conf /.gitignore: -------------------------------------------------------------------------------- 1 | storage_base_path 2 | store_path0 3 | tracker_data 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fastdfs-docker-script 2 | 使用docker + docker-compose 一键弄个 fastdfs 吧 3 | 4 | ``` 5 | vi nginx.conf #没啥可编辑的 6 | vi storage.conf #也没啥可改的 7 | vi tracker.conf #不存在这个文件, 想改自己修改一下 yml 文件 8 | 9 | #起飞 10 | docker-compose up -d 11 | 12 | docker exec -it storage /bin/bash 13 | # 进入 storage 容器中使用命令上传一个图片, 可使用容器自带的测试图片, 也可 docker cp 将本机图片复制进来 14 | cd /fdfs_conf 15 | fdfs_upload_file storage.conf anti-steal.jpg #上传一个图片吧, 返回路径如 /group1/M00/00/00/xxxx 16 | # 访问 localhost:8088/group1/M00/00/00/xxxx 吧 17 | 18 | ``` 19 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | tracker: 4 | image: season/fastdfs:1.2 5 | container_name: tracker 6 | restart: always 7 | volumes: 8 | - "./tracker_data:/fastdfs/tracker/data" 9 | ports: 10 | - "22122:22122" 11 | command: "tracker" 12 | 13 | storage: 14 | image: season/fastdfs:1.2 15 | container_name: storage 16 | links: 17 | - tracker 18 | restart: always 19 | volumes: 20 | - "./storage.conf:/fdfs_conf/storage.conf" 21 | - "./storage_base_path:/fastdfs/storage/data" 22 | - "./store_path0:/fastdfs/store_path" 23 | ports: 24 | - "23000:23000" 25 | environment: 26 | TRACKER_SERVER: "tracker:22122" 27 | command: "storage" 28 | 29 | nginx: 30 | image: season/fastdfs:1.2 31 | container_name: fdfs-nginx 32 | restart: always 33 | volumes: 34 | - "./nginx.conf:/etc/nginx/conf/nginx.conf" 35 | - "./store_path0:/fastdfs/store_path" 36 | links: 37 | - tracker 38 | ports: 39 | - "8088:8088" 40 | environment: 41 | TRACKER_SERVER: "tracker:22122" 42 | command: "nginx" 43 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | #user nobody; 2 | worker_processes 1; 3 | 4 | #error_log logs/error.log; 5 | #error_log logs/error.log notice; 6 | #error_log logs/error.log info; 7 | 8 | #pid logs/nginx.pid; 9 | 10 | 11 | events { 12 | worker_connections 1024; 13 | } 14 | 15 | 16 | http { 17 | include mime.types; 18 | default_type application/octet-stream; 19 | 20 | #access_log logs/access.log main; 21 | 22 | sendfile on; 23 | #tcp_nopush on; 24 | 25 | #keepalive_timeout 0; 26 | keepalive_timeout 65; 27 | 28 | #gzip on; 29 | 30 | server { 31 | listen 8088; 32 | server_name localhost; 33 | 34 | #charset koi8-r; 35 | 36 | #缩略图需要使用插件,需要单独构建nginx镜像,此处忽略 37 | #location /group([0-9])/M00/.*\.(gif|jpg|jpeg|png)$ { 38 | # root /fastdfs/storage/data; 39 | # image on; 40 | # image_output off; 41 | # image_jpeg_quality 75; 42 | # image_backend off; 43 | # image_backend_server http://baidu.com/docs/aabbc.png; 44 | # } 45 | 46 | # group1 47 | location /group1/M00 { 48 | # 文件存储目录 49 | root /fastdfs/storage/data; 50 | ngx_fastdfs_module; 51 | } 52 | 53 | #error_page 404 /404.html; 54 | 55 | # redirect server error pages to the static page /50x.html 56 | # 57 | error_page 500 502 503 504 /50x.html; 58 | location = /50x.html { 59 | root html; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /storage.conf: -------------------------------------------------------------------------------- 1 | # is this config file disabled 2 | # false for enabled 3 | # true for disabled 4 | disabled=false 5 | 6 | # the name of the group this storage server belongs to 7 | group_name=group1 8 | 9 | # bind an address of this host 10 | # empty for bind all addresses of this host 11 | bind_addr= 12 | 13 | # if bind an address of this host when connect to other servers 14 | # (this storage server as a client) 15 | # true for binding the address configed by above parameter: "bind_addr" 16 | # false for binding any address of this host 17 | client_bind=true 18 | 19 | # the storage server port 20 | port=23000 21 | 22 | # connect timeout in seconds 23 | # default value is 30s 24 | connect_timeout=30 25 | 26 | # network timeout in seconds 27 | # default value is 30s 28 | network_timeout=60 29 | 30 | # heart beat interval in seconds 31 | heart_beat_interval=30 32 | 33 | # disk usage report interval in seconds 34 | stat_report_interval=60 35 | 36 | # the base path to store data and log files 37 | base_path=/fastdfs/storage 38 | 39 | # max concurrent connections the server supported 40 | # default value is 256 41 | # more max_connections means more memory will be used 42 | max_connections=256 43 | 44 | # the buff size to recv / send data 45 | # this parameter must more than 8KB 46 | # default value is 64KB 47 | # since V2.00 48 | buff_size = 256KB 49 | 50 | # accept thread count 51 | # default value is 1 52 | # since V4.07 53 | accept_threads=1 54 | 55 | # work thread count, should <= max_connections 56 | # work thread deal network io 57 | # default value is 4 58 | # since V2.00 59 | work_threads=4 60 | 61 | # if disk read / write separated 62 | ## false for mixed read and write 63 | ## true for separated read and write 64 | # default value is true 65 | # since V2.00 66 | disk_rw_separated = true 67 | 68 | # disk reader thread count per store base path 69 | # for mixed read / write, this parameter can be 0 70 | # default value is 1 71 | # since V2.00 72 | disk_reader_threads = 1 73 | 74 | # disk writer thread count per store base path 75 | # for mixed read / write, this parameter can be 0 76 | # default value is 1 77 | # since V2.00 78 | disk_writer_threads = 1 79 | 80 | # when no entry to sync, try read binlog again after X milliseconds 81 | # must > 0, default value is 200ms 82 | sync_wait_msec=50 83 | 84 | # after sync a file, usleep milliseconds 85 | # 0 for sync successively (never call usleep) 86 | sync_interval=0 87 | 88 | # storage sync start time of a day, time format: Hour:Minute 89 | # Hour from 0 to 23, Minute from 0 to 59 90 | sync_start_time=00:00 91 | 92 | # storage sync end time of a day, time format: Hour:Minute 93 | # Hour from 0 to 23, Minute from 0 to 59 94 | sync_end_time=23:59 95 | 96 | # write to the mark file after sync N files 97 | # default value is 500 98 | write_mark_file_freq=500 99 | 100 | # path(disk or mount point) count, default value is 1 101 | store_path_count=1 102 | 103 | # store_path#, based 0, if store_path0 not exists, it's value is base_path 104 | # the paths must be exist 105 | store_path0=/fastdfs/store_path 106 | #store_path1=/home/yuqing/fastdfs2 107 | 108 | # subdir_count * subdir_count directories will be auto created under each 109 | # store_path (disk), value can be 1 to 256, default value is 256 110 | subdir_count_per_path=256 111 | 112 | # tracker_server can ocur more than once, and tracker_server format is 113 | # "host:port", host can be hostname or ip address 114 | tracker_server=192.168.209.121:22122 115 | 116 | #standard log level as syslog, case insensitive, value list: 117 | ### emerg for emergency 118 | ### alert 119 | ### crit for critical 120 | ### error 121 | ### warn for warning 122 | ### notice 123 | ### info 124 | ### debug 125 | log_level=info 126 | 127 | #unix group name to run this program, 128 | #not set (empty) means run by the group of current user 129 | run_by_group= 130 | 131 | #unix username to run this program, 132 | #not set (empty) means run by current user 133 | run_by_user= 134 | 135 | # allow_hosts can ocur more than once, host can be hostname or ip address, 136 | # "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or 137 | # host[01-08,20-25].domain.com, for example: 138 | # allow_hosts=10.0.1.[1-15,20] 139 | # allow_hosts=host[01-08,20-25].domain.com 140 | allow_hosts=* 141 | 142 | # the mode of the files distributed to the data path 143 | # 0: round robin(default) 144 | # 1: random, distributted by hash code 145 | file_distribute_path_mode=0 146 | 147 | # valid when file_distribute_to_path is set to 0 (round robin), 148 | # when the written file count reaches this number, then rotate to next path 149 | # default value is 100 150 | file_distribute_rotate_count=100 151 | 152 | # call fsync to disk when write big file 153 | # 0: never call fsync 154 | # other: call fsync when written bytes >= this bytes 155 | # default value is 0 (never call fsync) 156 | fsync_after_written_bytes=0 157 | 158 | # sync log buff to disk every interval seconds 159 | # must > 0, default value is 10 seconds 160 | sync_log_buff_interval=10 161 | 162 | # sync binlog buff / cache to disk every interval seconds 163 | # default value is 60 seconds 164 | sync_binlog_buff_interval=10 165 | 166 | # sync storage stat info to disk every interval seconds 167 | # default value is 300 seconds 168 | sync_stat_file_interval=300 169 | 170 | # thread stack size, should >= 512KB 171 | # default value is 512KB 172 | thread_stack_size=512KB 173 | 174 | # the priority as a source server for uploading file. 175 | # the lower this value, the higher its uploading priority. 176 | # default value is 10 177 | upload_priority=10 178 | 179 | # the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a 180 | # multi aliases split by comma. empty value means auto set by OS type 181 | # default values is empty 182 | if_alias_prefix= 183 | 184 | # if check file duplicate, when set to true, use FastDHT to store file indexes 185 | # 1 or yes: need check 186 | # 0 or no: do not check 187 | # default value is 0 188 | check_file_duplicate=0 189 | 190 | # file signature method for check file duplicate 191 | ## hash: four 32 bits hash code 192 | ## md5: MD5 signature 193 | # default value is hash 194 | # since V4.01 195 | file_signature_method=hash 196 | 197 | # namespace for storing file indexes (key-value pairs) 198 | # this item must be set when check_file_duplicate is true / on 199 | key_namespace=FastDFS 200 | 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 | 205 | # you can use "#include filename" (not include double quotes) directive to 206 | # load FastDHT server list, when the filename is a relative path such as 207 | # pure filename, the base path is the base path of current/this config file. 208 | # must set FastDHT server list when check_file_duplicate is true / on 209 | # please see INSTALL of FastDHT for detail 210 | ##include /home/yuqing/fastdht/conf/fdht_servers.conf 211 | 212 | # if log to access log 213 | # default value is false 214 | # since V4.00 215 | use_access_log = false 216 | 217 | # if rotate the access log every day 218 | # default value is false 219 | # since V4.00 220 | rotate_access_log = false 221 | 222 | # rotate access log time base, time format: Hour:Minute 223 | # Hour from 0 to 23, Minute from 0 to 59 224 | # default value is 00:00 225 | # since V4.00 226 | access_log_rotate_time=00:00 227 | 228 | # if rotate the error log every day 229 | # default value is false 230 | # since V4.02 231 | rotate_error_log = false 232 | 233 | # rotate error log time base, time format: Hour:Minute 234 | # Hour from 0 to 23, Minute from 0 to 59 235 | # default value is 00:00 236 | # since V4.02 237 | error_log_rotate_time=00:00 238 | 239 | # rotate access log when the log file exceeds this size 240 | # 0 means never rotates log file by log file size 241 | # default value is 0 242 | # since V4.02 243 | rotate_access_log_size = 0 244 | 245 | # rotate error log when the log file exceeds this size 246 | # 0 means never rotates log file by log file size 247 | # default value is 0 248 | # since V4.02 249 | rotate_error_log_size = 0 250 | 251 | # if skip the invalid record when sync file 252 | # default value is false 253 | # since V4.02 254 | file_sync_skip_invalid_record=false 255 | 256 | # if use connection pool 257 | # default value is false 258 | # since V4.05 259 | use_connection_pool = false 260 | 261 | # connections whose the idle time exceeds this time will be closed 262 | # unit: second 263 | # default value is 3600 264 | # since V4.05 265 | connection_pool_max_idle_time = 3600 266 | 267 | # use the ip address of this storage server if domain_name is empty, 268 | # else this domain name will ocur in the url redirected by the tracker server 269 | http.domain_name= 270 | 271 | tracker_server=tracker:22122 272 | 273 | # the port of the web server on this storage server 274 | http.server_port=8888 275 | --------------------------------------------------------------------------------