======================================1、相关人员======================================
【人员】:楼斌

======================================2、应用部署说明======================================

依赖包两个:https://pan.baidu.com/s/1S8rlcXiqaDxeJMKNiG3i-w

1.一个go语言依赖,解压后 tar -xvf go1.12.6.linux-amd64.tar.gz 设置环境变量,vim /etc/profile

export GOROOT=/opt/local/go(具体解压路径)
export GOARCH=386
export GOOS=linux
export GOBIN=$GOROOT/bin
export GOTOOLS=$GOROOT/pkg/tool/
export PATH=$PATH:$GOBIN:$GOTOOLS

设置完成后保存,source /etc/profile 生效 go version验证下

2.安装seaweedFS,解压后tar -C /mnt/disk50/seaweedFS/seaweed/ -xzf linux_amd64.tar.gz,创建一些文件夹在当前路径/mnt/disk50/seaweedFS下,

mkdir data

cd data

mkdir fileData

在data 和 fileData下创建必须的文件

cd /mnt/disk50/seaweedFS/data

touch filer_sfs.log

touch t_v1_sfs.log

touch t_v2_sfs.log

mkdir t_v1

mkdir t_v2

cd /mnt/disk50/seaweedFS/data/fileData

touch server_sfs.log

3.在当前路径下启动

nohup ./weed master -mdir=/mnt/disk50/seaweedFS/data/fileData/ -port=9333 -defaultReplication="010" -ip="10.12.107.112" -ip.bind="10.12.107.112" >>/mnt/disk50/seaweedFS/data/fileData/server_sfs.log &

./weed volume -dir=/mnt/disk50/seaweedFS/data/t_v1 -dataCenter="dc1" -rack="dc1rack1" -max=10 -mserver="10.12.107.112:9333" -port=9080 -ip="10.12.107.112" -ip.bind="10.12.107.112" >>/mnt/disk50/seaweedFS/data/t_v1_sfs.log &
./weed volume -dir=/mnt/disk50/seaweedFS/data/t_v2 -dataCenter="dc1" -rack="dc1rack2" -max=10 -mserver="10.12.107.112:9333" -port=9081 -ip="10.12.107.112" -ip.bind="10.12.107.112" >>/mnt/disk50/seaweedFS/data/t_v2_sfs.log &

nohup ./weed filer -master="10.12.107.112:9333" -ip="10.12.107.112" -port=9999 -defaultReplicaPlacement="010" >>/mnt/disk50/seaweedFS/data/filer.out 2>&1 &

查看下进程ps -ef | grep weed
Seaweedfs文件系统搭建_第1张图片

4.-defaultReplication="000" 表示不备份,就存一份(但会造成集群找不到资源跳转volume具体地址的重定向情况)
附:备份策略:
000:没有复制,只有一个副本
001:在同一机架上复制一次
010:在同一数据中心的不同机架上复制一次【建议使用】
100:在不同的数据中心复制一次
200:在另外两个不同的数据中心上复制两次
110:在不同的机架上复制一次,并在不同的数据中心上复制一次


5、最后,测试是否启动成功:
浏览器里输入
http://10.12.107.112:9333/dir/assign

如果启动成功会返回如下json字符串:

{
"fid": "4,02bb481acb",
"url": "10.12.107.112:9080",
"publicUrl": "10.12.107.112:9080",
"count": 1
}

6.nginx配置 参考铜山生产环境157.0.243.27

upstream seaweedfs{
server 172.16.0.8:9080 weight=1;
server 172.16.0.8:9081 weight=1;
#server 172.16.0.8:9082 weight=1;
}

upstream filer{
server 172.16.0.8:9999 weight=1;
}

server {
listen 9888;
server_name 172.16.0.5;

#charset koi8-r;
#access_log logs/host.access.log seaweedfs;
gzip off;
etag off;

location / {
add_header Access-Control-Allow-Origin ''; #¿¿¿¿¿¿¿¿
add_header Access-Control-Allow-Credentials 'true';
add_header Access-Control-Allow-Methods 'GET, PUT, POST, DELETE, OPTIONS'; #¿¿¿¿¿¿
add_header Access-Control-Allow-Headers 'Content-Type,
';
add_header Cache-Control "no-store, no-cache, must-revalidate"; #¿¿¿¿¿¿¿¿

proxy_http_version 1.1;
proxy_cache_revalidate on;

proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_send_timeout 10;
if ( $request_uri ~ "\d," )
{
proxy_pass http://seaweedfs;
}
if ( $request_uri ~ "." )
{
#expires -1;
proxy_pass http://filer;
}
}
}