国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

云服務器|WEB服務器|FTP服務器|郵件服務器|虛擬主機|服務器安全|DNS服務器|服務器知識|Nginx|IIS|Tomcat|

服務器之家 - 服務器技術 - 服務器知識 - 如何使用 docker-compose 搭建 fastDFS文件服務器

如何使用 docker-compose 搭建 fastDFS文件服務器

2021-11-19 17:02edoclin 服務器知識

這篇文章主要介紹了如何使用 docker compose 搭建 fastDFS文件服務器,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

上篇文章給大家介紹了使用docker compose安裝FastDfs文件服務器的實例詳解

今天給大家介紹如何使用 docker compose 搭建 fastDFS文件服務器,內容詳情如下所示:

平臺 :Mac M1

備注:關于 IP Address

關于 docker 的網絡模式,上述文中提到了 docker 的 Host 模式

如果啟動容器的時候使用host模式,那么這個容器將不會獲得一個獨立的Network Namespace,而是和宿主機共用一個 Network Namespace。容器將不會虛擬出自己的網卡,配置自己的 IP 等,而是使用宿主機的 IP 和端口。但是,容器的其他方面,如文件系統、進程列表等還是和宿主機隔離的。

問題在于:使用宿主機的 IP 和端口的話,配置文件中 IP 填寫 localhost的話按理說能訪問到容器,然而事實上卻不行。個人理解(如果理解有問題的話煩請指正)的 IP Address填寫方法如下:

啟動 tracker 時控制臺輸出:

如何使用 docker-compose 搭建 fastDFS文件服務器

192.168.64.2的網絡為:

如何使用 docker-compose 搭建 fastDFS文件服務器

192.168.65.4的網絡為:

如何使用 docker-compose 搭建 fastDFS文件服務器

文件目錄

?
1
2
3
4
5
6
7
8
9
├── docker-compose.yaml
├── nginx
│   └── nginx.conf
├── storage
│   └── data
└── tracker
│   └── conf
│       └── client.conf
└── store_path

./docker-compose.yaml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
version: "2"
services:
    fastdfs-tracker:
        hostname: fastdfs-tracker
        container_name: fastdfs-tracker
        image: season/fastdfs:1.2
        network_mode: "host"
        command: tracker
        volumes:
          - ./tracker/data:/fastdfs/tracker/data
          - ./tracker/conf:/etc/fdfs
    fastdfs-storage:
        hostname: fastdfs-storage
        container_name: fastdfs-storage
        image: season/fastdfs:1.2
        network_mode: "host"
        volumes:
          - ./storage/data:/fastdfs/storage/data
          - ./store_path:/fastdfs/store_path
        environment:
          - TRACKER_SERVER=192.168.64.2:22122
        command: storage
        depends_on:
          - fastdfs-tracker
    fastdfs-nginx:
        hostname: fastdfs-nginx
        container_name: fastdfs-nginx
        image: season/fastdfs:1.2
        network_mode: "host"
        volumes:
          - ./nginx/nginx.conf:/etc/nginx/conf/nginx.conf
          - ./store_path:/fastdfs/store_path
        environment:
          - TRACKER_SERVER=192.168.64.2:22122
        command: nginx

./tracker/conf/client.conf

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# connect timeout in seconds
# default value is 30s
connect_timeout=30
# network timeout in seconds
# default value is 30s
network_timeout=60
 
# the base path to store log files
base_path=/fastdfs/client
 
# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# 需要修改此處 ip
tracker_server=192.168.64.2:22122
 
#standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info
 
# if use connection pool
# default value is false
# since V4.05
use_connection_pool = false
 
# connections whose the idle time exceeds this time will be closed
# unit: second
# default value is 3600
# since V4.05
connection_pool_max_idle_time = 3600
 
# if load FastDFS parameters from tracker server
# since V4.05
# default value is false
load_fdfs_parameters_from_tracker=false
 
# if use storage ID instead of IP address
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# default value is false
# since V4.05
use_storage_id = false
 
# specify storage ids filename, can use relative or absolute path
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V4.05
storage_ids_filename = storage_ids.conf
 
#HTTP settings
http.tracker_server_port=80
 
#use "#include" directive to include HTTP other settiongs
##include http.conf

./nginx/nginx.conf

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#user  nobody;
worker_processes  1;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
events {
    worker_connections  1024;
}
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
 
    server {
        listen       9800;
        server_name  localhost;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        # 修改部分
        location / {
            root /fastdfs/store_path/data;
            ngx_fastdfs_module;
        }
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

SpringBoot 集成 fastDFS

添加依賴

?
1
2
3
4
5
<dependency>
    <groupId>com.github.tobato</groupId>
    <artifactId>fastdfs-client</artifactId>
    <version>1.27.2</version>
</dependency>

 

applicaiton.yaml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 分布式文件系統配置
fdfs:
  #根據自己的ip進行更改
  ip: 192.168.64.2
  #socket連接超時時長
  soTimeout: 1500
  connectTimeout: 600
  #支持多個
  trackerList:
    - ${fdfs.ip}:22122
  # fastDFS 中的 nginx 的 ip 和 port
  # IDEA 提示使用 https,
  # nginx 配置 SSL 請移步:
  web-server-url: http://${fdfs.ip}:9800/

FastDFSConfig.java

?
1
2
3
4
5
6
7
@Configuration
// 導入FastDFS-Client組件
@Import(FdfsClientConfig.class)
// 解決jmx重復注冊bean的問題
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
public aspect FastDFSConfig {
}

FastDFSUtil.java

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@Component
public class FastDFSUtil {
    @Resource
    private FastFileStorageClient fastFileStorageClient;
    @Resource
    private FdfsWebServer fdfsWebServer;
 
    public String uploadFile(MultipartFile file) throws IOException {
        StorePath storePath = fastFileStorageClient.uploadFile(file.getInputStream(), file.getSize(), FilenameUtils.getExtension(file.getOriginalFilename()), null);
        String fullPath = storePath.getFullPath();
        getResAccessUrl(fullPath);
        return fullPath;
    }
 
    public String uploadFile(File file) {
        try {
            FileInputStream inputStream = new FileInputStream(file);
            StorePath storePath = fastFileStorageClient.uploadFile(inputStream, file.length(), FilenameUtils.getExtension(file.getName()), null);
            return storePath.getFullPath();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
 
    public byte[] downloadFile(String filePath) {
        StorePath storePath = StorePath.parseFromUrl(filePath);
        return fastFileStorageClient.downloadFile(storePath.getGroup(), storePath.getPath(), new DownloadByteArray());
    }
 
    public Boolean deleteFile(String filePath) {
        if (StringUtils.isEmpty(filePath)) {
            return false;
        }
        try {
            StorePath storePath = StorePath.parseFromUrl(filePath);
            fastFileStorageClient.deleteFile(storePath.getGroup(), storePath.getPath());
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
 
    /**
     * 封裝文件完整 URL 地址
     *
     * @param path
     * @return
     */
    public String getResAccessUrl(String path) {
        return fdfsWebServer.getWebServerUrl() + path;
    }
}

FastDFSController.java

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@RestController
@RequestMapping("/fast-dfs")
public class FastDFSController {
    /**
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("")
    @Transactional
    public void uploadFile(MultipartFile file, String cuisineId) throws IOException {
        String s = fastDfsUtil.uploadFile(file);
        String resAccessUrl = fastDfsUtil.getResAccessUrl(s);
    }
 
    /**
     * @param response
     * @throws IOException
     */
    @GetMapping("")
    public void downloadFile(String filePath, HttpServletResponse response) throws IOException {
        byte[] bytes = fastDfsUtil.downloadFile(filePath);
 
        String[] split = filePath.split("/");
        String fileName = split[split.length - 1];
        // 設置強制下載不打開
        response.setContentType("application/force-download");
 
        fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8);
        response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
        IOUtils.write(bytes, response.getOutputStream());
    }
 
    /**
     * 流媒體的方式播放視頻,只能從頭看到尾,不能手動點擊重新看已經看過的內容
     * @param filePath
     * @param response
     * @throws IOException
     */
    @GetMapping("/play")
    public void streamMedia(String filePath, HttpServletResponse response) throws IOException {
        byte[] bytes = fastDfsUtil.downloadFile(filePath);
        IOUtils.copy(new ByteArrayInputStream(bytes), response.getOutputStream());
        response.flushBuffer();
    }
}

到此這篇關于如何使用 docker compose 搭建 fastDFS文件服務器的文章就介紹到這了,更多相關docker compose 搭建 fastDFS內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://www.cnblogs.com/edoclin/p/14648832.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美视频在线播放 | av中文字幕在线观看 | 国产激情在线观看 | 手机av在线 | 国产精品久久久久久久9999 | 天天操天天拍 | 日韩在线观看第一页 | 久久久久久91 | 午夜小视频在线 | 中文字幕精品一区二区三区精品 | 日日夜夜视频 | 日韩精品在线观看一区 | 毛片区 | 久久精品无码一区二区三区 | 国产欧美日韩综合精品一区二区 | 久久视频免费 | 国产亚洲精品久久19p | 国产一区二区综合 | 日韩免费在线 | 91精品国产综合久久久久久 | 亚洲大片av| 看av片| 亚洲欧美精品一区二区三区 | 色屁屁影院 | 男女啪啪做爰高潮www成人福利 | 国产精品女同一区二区免费站 | 欧美精品一区三区 | www.av在线 | 久久中文字幕一区二区 | 欧美日韩一级视频 | 国产精品一区二区av | 在线播放亚洲 | av免费在线观看网站 | 午夜精品一区二区三区在线观看 | 日韩三级电影免费观看 | 久久黄网站| 动漫羞免费网站中文字幕 | 亚洲国产中文字幕在线观看 | 欧美日韩成人网 | 有码在线| 免费人成黄页网站在线一区二区 |