代刷网站推广,好玩的网页传奇,制作网页需要什么专业,番禺制作网站系统知识概念 
分布式文件系统 
通过计算机网络将各个物理存储资源连接起来。通过分布式文件系统#xff0c;将网络上任意资源以逻辑上的树形结构展现#xff0c;让用户访问网络上的共享文件更见简便。 
文件存储的变迁#xff1a; 
直连存储#xff1a;直接连接与存储#xf…知识概念 
分布式文件系统 
通过计算机网络将各个物理存储资源连接起来。通过分布式文件系统将网络上任意资源以逻辑上的树形结构展现让用户访问网络上的共享文件更见简便。 
文件存储的变迁 
直连存储直接连接与存储扩展性、灵活性差。如Tomcat、nginx。中心化存储网络互联。分布式存储资源存储在多个服务器这个存储资源构成一个虚拟的存储设备。 
常见的DFS 
FastDFS 开源的轻量级分布式文件系统HDFS  Hadoop 子项目 Hadoop 的存储系统。Taobao FileSystem 高扩展、高可用、高性能、面向互联网服务的分布式文件系统针对海量非结构化数据构建在普通linux机器集群上提供高可靠、高并发的存储访问。 为淘宝提供海量小文件存储通常不超1M。采用HA架构和平滑扩容。  HA架构通过设计减少系统不可用的时间。通过 冗余集群  自动故障转移来实现。 GridFSmongodb内置功能。文件分成两份索引和文件内容。它们存储在集合中文件内容等分成若干块存储在文档中。一般以4M作为分块存储单位。Google File System 非开源。MogileFS  由Six Apart开发广泛应用在 包括LiveJournal等web2.0站点上 。 
文件系统FastDFSHDFSTFSMogileFS数据存储 方式文件/块文件文件文件集群通讯 协议私有协议私有协议私有协议Http扩容支持支持支持支持冗余备份支持支持支持不 支持单点故障不存在存在存在存在跨集群同 步部分支持不支持支持不支持开发语言CJavaCPerl适合类型4KB - 500MB大文件所有文件海量小图片复杂度简单简单复杂复杂易用性安装简单社区 活跃安装简单文档 专业安装复杂文档 较少安装复杂文档 较少研发团队国内开发者-余庆ApacheAlibabaDanga InteractiveFUSE不支持支持不支持支持POSIX不支持支持无资料不支持 
常见DFS提供商 
阿里OSS七牛云存储百度云存储 
FastDFS简介 
FastDFS是用C语言编写的一款开源的分布式文件系统它是由淘宝资深架构师余庆编写并开源。 FastDFS专为互联网量身定制充分考虑了冗余备份、负载均衡、线性扩容等机制并注重高可用、高 性能等指标使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传、下载等服务。 
功能概况 
文件存储、文件同步、文件访问文件上传、文件下载等解决了大容量存储和负载均衡 的问题。特别适合以中小文件 建议范围 4KB 到 500MB  为载体的在线服务如相册网站、视 频网站等等 
架构 
FastDFS架构包括 Tracker Server和Storage Server 。 Tracker Server负责处理客户端的文件上传、下载请求通过调度追踪定位 Storage Server 目标最后由其完成文件下载、上传。  
Tracker Server 
作用是负载均衡和调度。在FastDFS集群中可以有多台Tracker Server 同时提供服务不存在单点故障。 
Storage Server 
处理文件存储使用操作系统的文件系统管理文件。 采用分组存储方式集群由多个一个或多个分组组成集群容量是集群内所有组的总和不同组之间不会互相通信同组内相互连接同步文件所以组的容量由组内最小容量的节点决定。 使用分组的方式比较灵活易扩展。客户端可以直接指定上传的组也可以由Tracker进行调度当访问压力大的时候也可以通过增加组内存储服务器来提高服务能力当容量不足时可以增加分组提高容量。 
Storage 状态收集 
Storage会连接所有Tracker然后汇报自己的状态。包括磁盘空间、文件同步情况、文件上传下载次数等统计信息。 
文件上传流程 客户端拿到file_id之后存储起来后续通过file_id拿到文件。 file_id相当于一个索引其文件索引信息包括组名虚拟磁盘路径数据两级目录文件名。 例如group1/M00/00/00/wKjIgGNslmOAf5VSAACQjdb7ANw5904822 组名文件上传后所在的分组虚拟磁盘路径通过store_path指定的 Storage 虚拟路径。 store_path0相当于一个组内节点 是M00 了store_path1则是M01以此类推。数据两级目录  在 虚拟磁盘路径下创建的两级目录用于存储数据文件。文件名由存储服务器根据特定信息源存储服务器IP地址、文件创建时间戳、文件大小、随机数和文件拓展名等信息生成。 
文件下载流程 通过组名 tracker 能快速锁定所在分组然后 tracker 会选择一个合适的存储节点并把节点信息返回给客户端。客户端访问存储服务器的时候存储服务器可以通过文件虚拟路径、数据两级目录来快速定位文件并根据文件名找到访问的文件。 
准备环境 
开几个ubuntu18虚拟机 
节点IP域名端口开放tracker1192.168.204.167tracker122122tracker2192.168.204.168tracker222122storage1192.168.204.169storage123000、8888storage2192.168.204.170storage123000、8888 
修改一下自己电脑的host文件 
192.168.204.167 tracker1
192.168.204.168 tracker2
192.168.204.169 storage1
192.168.204.170 storage2下载镜像 docker pull morunchang/fastdfs https://hub.docker.com/r/morunchang/fastdfs tracker 
在tracker1、tracker2服务器运行下面命令运行前检查tracker_data目录是否创建了。 默认端口22122。 
docker run -d --name tracker -p 22122:22122 -v ~/tracker_data:/data/fast_data  --nethost morunchang/fastdfs sh tracker.sh –net支持 bridge/host/none/container 四种类型 storage 
在storage1、storage2服务器运行下面命令运行前检查storage_data、store_path目录是否创建了。 docker run -d --name storage \
-v ~/storage_data:/data/fast_data \
-v ~/conf/nginx.conf:/etc/nginx/conf/nginx.conf \
--nethost -e GROUP_NAMEgroup1 \
-e TRACKER_IPtracker1:22122,tracker2:22122 \
morunchang/fastdfs sh storage.sh 
#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       8888;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}location ~ /M00 {root /data/fast_data/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;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apaches document root# concurs with nginxs one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}} 
整合SpringBoot 
去github拉取源码然后mvn clean install到本地仓库官方没有发布到maven中心仓库最后再引入依赖 dependency		groupIdorg.csource/groupIdartifactIdfastdfs-client-java/artifactIdversion1.30-SNAPSHOT/version/dependency# http连接超时时间
connect_timeout  2
# tracker与storage网络通信超时时间
network_timeout  30
charset  UTF-8
http.tracker_http_port  80
http.anti_steal_token  no
http.secret_key  FastDFS1234567890
# tracker服务器地址可以重复配置多个
tracker_server  tracker1:22122
tracker_server  tracker2:22122# 连接池配置
connection_pool.enabled  true
connection_pool.max_count_per_entry  500
connection_pool.max_idle_time  3600
connection_pool.max_wait_time_in_ms  1000 
package com.example.demofastdfs.test;import org.csource.common.MyException;
import org.csource.common.NameValuePair;
import org.csource.fastdfs.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;import java.io.*;
import java.util.Arrays;/*** className: FastDFSDemo* description: TODO 类描述* author: liangshijie* date: 2023/3/5**/
public class FastDFSDemo {private static final String CONF_NAME  fdfs_client.conf;private StorageClient storageClient;private TrackerServer trackerServer;Beforepublic void initStorageClient() throws Exception {ClientGlobal.init(CONF_NAME);System.out.println(network_timeout ClientGlobal.g_network_timeout  ms);System.out.println(charset  ClientGlobal.g_charset);TrackerClient tracker  new TrackerClient();trackerServer  tracker.getTrackerServer();StorageServer storageServer  new StorageServer(storage1, 23000, 0);storageClient  new StorageClient(trackerServer, storageServer);
//        storageClient  new StorageClient(trackerServer, storageServer);}/*** 测试上传文件*/Testpublic void upload() throws Exception {// http://storage2:23000/group1/M00/00/00/wKjMqWQHVleAFzK7AAAWWKCNj-E2720984.jpgNameValuePair[] metaList  new NameValuePair[1];String local_filename  dog.png;metaList[0]  new NameValuePair(fileName, local_filename);File file  new File(C:\\Users\\admin\\Desktop\\dog.png);InputStream inputStream  new FileInputStream(file);int length  inputStream.available();byte[] bytes  new byte[length];inputStream.read(bytes);String[] result  storageClient.upload_file(bytes, jpg, metaList);
//        String[] result  storageClient.upload_file(bytes, null, metaList);System.out.println(result {}  Arrays.asList(result));}//查询文件Testpublic void testQueryFile() throws IOException, MyException {
//        group1, M00/00/00/wKjMqWQGk_WAesAEAAAWWKCNj-E4269595FileInfo fileInfo  storageClient.query_file_info(group1, M00/00/00/wKjMqWQGk_WAesAEAAAWWKCNj-E4269595);System.out.println(fileInfo);}/*** 测试下载*/Testpublic void download() throws Exception {String[] uploadresult  {group1,M00/00/00/wKjMqWQGk_WAesAEAAAWWKCNj-E4269595};byte[] result  storageClient.download_file(uploadresult[0],uploadresult[1]);String local_filename  dog_two.png;
//文件写入磁盘writeByteToFile(result, local_filename);File file  new File(local_filename);System.out.println(file.isFile    file.isFile());}Afterpublic void closeClient() {System.out.println(close connection);if (storageClient ! null) {try {storageClient.close();} catch (Exception e) {e.printStackTrace();} catch (Throwable e) {e.printStackTrace();}}}public void writeByteToFile(byte[] fbyte, String fileName) throwsIOException {BufferedOutputStream bos  null;FileOutputStream fos  null;File file  new File(fileName);try {fos  new FileOutputStream(file);bos  new BufferedOutputStream(fos);bos.write(fbyte);} catch (Exception e) {e.printStackTrace();} finally {if (bos ! null) {bos.close();}if (fos ! null) {fos.close();}}}} 
测试地址 
http://storage1:8888/group1/M00/00/00/wKjMqWQHWfqAGM9mAAAWWKCNj-E813.jpg 文章转载自: http://www.morning.kzcz.cn.gov.cn.kzcz.cn http://www.morning.jytrb.cn.gov.cn.jytrb.cn http://www.morning.nzsdr.cn.gov.cn.nzsdr.cn http://www.morning.ftlgy.cn.gov.cn.ftlgy.cn http://www.morning.lwqst.cn.gov.cn.lwqst.cn http://www.morning.rbnp.cn.gov.cn.rbnp.cn http://www.morning.drhnj.cn.gov.cn.drhnj.cn http://www.morning.bpmfz.cn.gov.cn.bpmfz.cn http://www.morning.ddzqx.cn.gov.cn.ddzqx.cn http://www.morning.pkrb.cn.gov.cn.pkrb.cn http://www.morning.zmpsl.cn.gov.cn.zmpsl.cn http://www.morning.gnkdp.cn.gov.cn.gnkdp.cn http://www.morning.krnzm.cn.gov.cn.krnzm.cn http://www.morning.wdykx.cn.gov.cn.wdykx.cn http://www.morning.fhsgw.cn.gov.cn.fhsgw.cn http://www.morning.tfpmf.cn.gov.cn.tfpmf.cn http://www.morning.yqpzl.cn.gov.cn.yqpzl.cn http://www.morning.fengnue.com.gov.cn.fengnue.com http://www.morning.sfnr.cn.gov.cn.sfnr.cn http://www.morning.wzwyz.cn.gov.cn.wzwyz.cn http://www.morning.lszjq.cn.gov.cn.lszjq.cn http://www.morning.wctqc.cn.gov.cn.wctqc.cn http://www.morning.lnsnyc.com.gov.cn.lnsnyc.com http://www.morning.zqcsj.cn.gov.cn.zqcsj.cn http://www.morning.tpyrn.cn.gov.cn.tpyrn.cn http://www.morning.hxrfb.cn.gov.cn.hxrfb.cn http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com http://www.morning.pjtw.cn.gov.cn.pjtw.cn http://www.morning.fnnkl.cn.gov.cn.fnnkl.cn http://www.morning.mbbgk.com.gov.cn.mbbgk.com http://www.morning.hphfy.cn.gov.cn.hphfy.cn http://www.morning.rnxw.cn.gov.cn.rnxw.cn http://www.morning.mnclk.cn.gov.cn.mnclk.cn http://www.morning.qlck.cn.gov.cn.qlck.cn http://www.morning.ryglh.cn.gov.cn.ryglh.cn http://www.morning.fglzk.cn.gov.cn.fglzk.cn http://www.morning.rxnr.cn.gov.cn.rxnr.cn http://www.morning.jfbpf.cn.gov.cn.jfbpf.cn http://www.morning.wzjhl.cn.gov.cn.wzjhl.cn http://www.morning.rqbr.cn.gov.cn.rqbr.cn http://www.morning.nydgg.cn.gov.cn.nydgg.cn http://www.morning.btns.cn.gov.cn.btns.cn http://www.morning.yqpzl.cn.gov.cn.yqpzl.cn http://www.morning.rgtp.cn.gov.cn.rgtp.cn http://www.morning.pkggl.cn.gov.cn.pkggl.cn http://www.morning.kpxzq.cn.gov.cn.kpxzq.cn http://www.morning.sgtq.cn.gov.cn.sgtq.cn http://www.morning.bpmdr.cn.gov.cn.bpmdr.cn http://www.morning.qbjgw.cn.gov.cn.qbjgw.cn http://www.morning.qznkn.cn.gov.cn.qznkn.cn http://www.morning.yfwygl.cn.gov.cn.yfwygl.cn http://www.morning.yptwn.cn.gov.cn.yptwn.cn http://www.morning.mbmh.cn.gov.cn.mbmh.cn http://www.morning.prgdy.cn.gov.cn.prgdy.cn http://www.morning.mgbcf.cn.gov.cn.mgbcf.cn http://www.morning.rnnq.cn.gov.cn.rnnq.cn http://www.morning.fmswb.cn.gov.cn.fmswb.cn http://www.morning.pwdgy.cn.gov.cn.pwdgy.cn http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn http://www.morning.eviap.com.gov.cn.eviap.com http://www.morning.rbjf.cn.gov.cn.rbjf.cn http://www.morning.sbjbs.cn.gov.cn.sbjbs.cn http://www.morning.djmdk.cn.gov.cn.djmdk.cn http://www.morning.qnypp.cn.gov.cn.qnypp.cn http://www.morning.qtqk.cn.gov.cn.qtqk.cn http://www.morning.kpgbz.cn.gov.cn.kpgbz.cn http://www.morning.jjxnp.cn.gov.cn.jjxnp.cn http://www.morning.mgbsp.cn.gov.cn.mgbsp.cn http://www.morning.kmrgl.cn.gov.cn.kmrgl.cn http://www.morning.rglp.cn.gov.cn.rglp.cn http://www.morning.gqnll.cn.gov.cn.gqnll.cn http://www.morning.ssgqc.cn.gov.cn.ssgqc.cn http://www.morning.lynkz.cn.gov.cn.lynkz.cn http://www.morning.nkiqixr.cn.gov.cn.nkiqixr.cn http://www.morning.gwqkk.cn.gov.cn.gwqkk.cn http://www.morning.rykw.cn.gov.cn.rykw.cn http://www.morning.pgfkl.cn.gov.cn.pgfkl.cn http://www.morning.fxxmj.cn.gov.cn.fxxmj.cn http://www.morning.mngyb.cn.gov.cn.mngyb.cn http://www.morning.wcjk.cn.gov.cn.wcjk.cn