文件報錯“/bin/bash^M: 壞的解釋器:沒有那個文件或目錄” 問題
sed -i 's/\r$//' build.sh
先運行 go-fastdfs 再運行 go-fastdfs-web
go-fastdfs 下載
https://github.com/sjqzhang/go-fastdfs/tags
go-fastdfs-web 下載
https://github.com/perfree/go-fastdfs-web/tags
教程:
https://sjqzhang.gitee.io/go-fastdfs/install.html#quick
cd go-faster/
./fileserver 生成必要文件,ctrl+C 退出
cd conf 編輯cfg.json, 然后再運行 ./fileserver &
https://sjqzhang.gitee.io/go-fastdfs/install.html#quick
├── conf
│ └── cfg.json
├── data
│ ├── 20200102
│ ├── fileserver.db
│ ├── log.db
│ └── stat.json
├── files
│ ├── _big
│ └── default
├── fileserver
├── log
│ ├── access.log
│ ├── fileserver.log
│ └── tusd.log
└── static
└── uppy.html
如果我們想更改文件服務器的配置,只需要更改 conf/cfg.json文件即可
{
"綁定端號": "端口",
"addr": ":8080",
"PeerID": "集群內唯一,請使用0-9的單字符,默認自動生成",
"peer_id": "2",
"本主機地址": "本機http地址,默認自動生成(注意端口必須與addr中的端口一致),必段為內網,自動生成不為內網請自行修改,下同",
"host": "http://172.16.13.103:8080",
"集群": "集群列表,注意為了高可用,IP必須不能是同一個,同一不會自動備份,且不能為127.0.0.1,且必須為內網IP,默認自動生成",
"peers": ["http://172.16.13.103:8080","http://172.16.13.104:8080"],
"組號": "用於區別不同的集群(上傳或下載)與support_group_upload配合使用,帶在下載路徑中",
"group": "group1",
"是否合並小文件": "默認不合並,合並可以解決inode不夠用的情況(當前對於小於1M文件)進行合並",
"enable_merge_small_file": false,
"重試同步失敗文件的時間": "單位秒",
"refresh_interval": 1800,
"是否自動重命名": "默認不自動重命名,使用原文件名",
"rename_file": false,
"是否支持web上傳,方便調試": "默認支持web上傳",
"enable_web_upload": true,
"是否支持非日期路徑": "默認支持非日期路徑,也即支持自定義路徑,需要上傳文件時指定path",
"enable_custom_path": true,
"下載域名": "用於外網下載文件的域名,不包含http://",
"download_domain": "",
"場景列表": "當設定后,用戶指的場景必項在列表中,默認不做限制(注意:如果想開啟場景認功能,格式如下:'場景名:googleauth_secret' 如 default:N7IET373HB2C5M6D ",
"scenes": [],
"默認場景": "默認default",
"default_scene": "default",
"是否顯示目錄": "默認顯示,方便調試用,上線時請關閉",
"show_dir": true,
"郵件配置": "",
"mail": {
"user": "abc@163.com",
"password": "abc",
"host": "smtp.163.com:25"
},
"告警接收郵件列表": "接收人數組",
"alram_receivers": [],
"告警接收URL": "方法post,參數:subjet,message",
"alarm_url": "",
"下載是否需帶token": "真假",
"download_use_token": false,
"下載token過期時間": "單位秒",
"download_token_expire": 600,
"是否自動修復": "在超過1億文件時出現性能問題,取消此選項,請手動按天同步,請查看FAQ",
"auto_repair": true,
"文件去重算法md5可能存在沖突,默認md5": "sha1|md5",
"file_sum_arithmetic": "md5",
"是否支持按組(集群)管理,主要用途是Nginx支持多集群": "默認不支持,不支持時路徑為http://10.1.5.4:8080/action,支持時為http://10.1.5.4:8080/group(配置中的group參數)/action,action為動作名,如status,delete,sync等",
"support_group_manage": false,
"管理ip列表": "用於管理集的ip白名單,",
"admin_ips": ["127.0.0.1"],
"是否啟用遷移": "默認不啟用",
"enable_migrate": false,
"文件是否去重": "默認去重",
"enable_distinct_file": true,
"是否開啟跨站訪問": "默認開啟",
"enable_cross_origin": true,
"是否開啟Google認證,實現安全的上傳、下載": "默認不開啟",
"enable_google_auth": false,
"認證url": "當url不為空時生效,注意:普通上傳中使用http參數 auth_token 作為認證參數, 在斷點續傳中通過HTTP頭Upload-Metadata中的auth_token作為認證參數,認證流程參考認證架構圖",
"auth_url": "",
"下載是否認證": "默認不認證(注意此選項是在auth_url不為空的情況下生效)",
"enable_download_auth": false,
"默認是否下載": "默認下載",
"default_download": true,
"本機是否只讀": "默認可讀可寫",
"read_only": false,
"是否開啟斷點續傳": "默認開啟",
"enable_tus": true
}
yum install nginx
vi /etc/nginx/nginx.conf
worker_processes 2;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/html;
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 /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
sendfile on;
keepalive_timeout 65;
client_max_body_size 0;
proxy_redirect ~/big/upload/(.*) /big/upload/$1; #繼點續傳一定要設置(注意)
upstream go-fastdfs {
server 172.23.20.71:8080;
server 172.23.20.72:8080;
server 172.23.20.114:8080;
ip_hash; #notice:very important(注意)
}
server {
listen 80;
server_name localhost;
location / {
proxy_set_header Host $host; #notice:very important(注意)
proxy_set_header X-Real-IP $remote_addr; #notice:very important(注意)
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #notice:very important(注意)
proxy_pass http://go-fastdfs;
}
}
}
http://10.0.0.10:8088 go-fastdfs-web 進行必要 install設置,然后進入web
http://10.0.0.10:8080/group1/status 查看狀態
http://10.0.0.10 //web 后台上傳簡易地址
