ソフトウェア・バージョン:
ソフトウェア | 版 | 圧縮袋の名前 |
---|---|---|
seaweedfs | seaweedfs-1.11 | linux_amd64.tar.gz |
GitHubの:
https://github.com/chrislusf/seaweedfs
関連定義の説明:
名前を定義します | 説明 |
---|---|
マスター | ボリューム=>ロケーションサービスとロケーションマッピングファイルIDのシリアル番号を提供 |
ノード | 抽象ノードシステム、抽象データセンター、ラック |
データノード | 論理ボリュームを格納、管理するためのストレージノード |
データセンター | 異なるラックの現実に対応するデータセンター、 |
ラック | ラックは、キャビネットの現実、特定のデータセンターに属するラックに対応し、データセンタは、複数のラックを含むことができます。 |
ボリューム | 論理ボリューム、ストレージの論理構造は、針を格納する論理ボリュームは、VolumeServerは1つのストアが含まれています |
針 | 保存されたファイルに対応する論理ボリュームオブジェクトは、針のファイルサイズは今の4ギガバイトに制限されています。 |
コレクション | ファイルのセットは、「」デフォルトを使用し、コレクションを指定していないときに、ファイルが保存されている場合は、複数の論理ボリュームに分散することができます |
ファイラー | ファイルマネージャは、ストレージエリアファイラーにデータファイラー雑草ボリューム・サーバー、およびブロックに大きなファイル、およびブロックのメタデータ情報をアップロードします。 |
マウント | ユーザ空間、マウント・ファイラーと一緒に使用する、唯一のメタデータファイルを取得するためのファイラー、ファイルを直接マウントサーバ間のボリュームの実際の内容を読み取るには、その複数のフィルタを必要としません。 |
表示するコマンドと説明-h $ ./weed使用
パラメータと説明を表示するために-hコマンド$ ./weed [コマンド]を使用します
展開の計画:
ノード | マスター | ボリューム | ファイラー |
---|---|---|---|
CDH1 | √ | √ | √ |
CDH2 | √ | √ | √ |
CDH3 | √ | √ | √ |
解凍:
$ tar -zxvf ./linux_amd64.tar.gz
得到 weed 文件
コマンドを起動します。
フォルダを作成します:
$ mkdir seaweedfd_master
$ mkdir seaweedfd_data
masterコマンドを起動します。
$ ./weed master -ip cdh1 -maxCpu 1 -mdir ./seaweedfd_master -peers cdh1:9333,cdh2:9333,cdh3:9333 -port 9333 -pulseSeconds 5 -defaultReplication 001
$ ./weed master -ip cdh2 -maxCpu 1 -mdir ./seaweedfd_master -peers cdh1:9333,cdh2:9333,cdh3:9333 -port 9333 -pulseSeconds 5 -defaultReplication 001
$ ./weed master -ip cdh3 -maxCpu 1 -mdir ./seaweedfd_master -peers cdh1:9333,cdh2:9333,cdh3:9333 -port 9333 -pulseSeconds 5 -defaultReplication 001
スプリットブレインを避ける:マスターの唯一の奇数がサポートされています!
后台运行:$ nohupを./weedマスター-ip CDH3 -maxCpu 1 -mdir ./seaweedfd_master -peers CDH1:9333、CDH2:9333、CDH3:9333 -port 9333 -pulseSeconds 5 -defaultReplication 001> weed_master.out&
サービスは2つのマスターを乗り切る必要があります提供したいです
ボリュームを起動します。
$ ./weed volume -dataCenter dc1 -dir ./seaweedfd_data -ip cdh1 -ip.bind cdh1 -maxCpu 1 -mserver cdh1:9333,cdh2:9333,cdh3:9333 -port 9222 -port.public 9222 -publicUrl cdh1 -rack rack1
$ ./weed volume -dataCenter dc1 -dir ./seaweedfd_data -ip cdh2 -ip.bind cdh2 -maxCpu 1 -mserver cdh1:9333,cdh2:9333,cdh3:9333 -port 9222 -port.public 9222 -publicUrl cdh2 -rack rack1
$ ./weed volume -dataCenter dc1 -dir ./seaweedfd_data -ip cdh3 -ip.bind cdh3 -maxCpu 1 -mserver cdh1:9333,cdh2:9333,cdh3:9333 -port 9222 -port.public 9222 -publicUrl cdh3 -rack rack1
データセンター:名前データセンターの
ラック:名前ラック
舞台裏スタート:$ nohupを./weedボリューム-dataCenter DC1 -dir ./seaweedfd_data -ip CDH1 -ip.bind CDH1 -maxCpu 1 -max 200 -mserver CDH1:9333、CDH2:9333 、CDH3:9333 -port 9222 -port.public 9222 -publicUrl CDH1 -rack RACK1> weed_volume.out&
アクセスマスターのWebUI:
http://cdh3:9333/
ファイルディレクトリをアップロードするコマンド:
$ ./weed upload -dataCenter dc1 -master=cdh3:9333 -dir="./dir/"
ファイルアロケーションキー:
# 基本使用:
$ curl http://cdh1:9333/dir/assign
# 指定复制类型:
$ curl "http://cdh1:9333/dir/assign?replication=001"
# 指定保存时间
$ curl "http://cdh1:9333/dir/assign?count=5"
# 指定数据中心
$ curl "http://cdh1:9333/dir/assign?dataCenter=dc1"
ファイルの例をアップロードします。
# 获取file key
$ curl "http://cdh1:9333/dir/assign?dataCenter=dc1"
# 返回JSON
{"fid":"2,016beb339d","url":"cdh2:9222","publicUrl":"cdh2","count":1}
# 上传一个文件指定fid
$ curl -F file=@./file http://cdh2:9222/2,016beb339d
# 返回JSON
{"name":"file","size":41629428}
ファイルを取得します。
$ curl http://cdh2:9222/2,016beb339d
コンフィギュレーションの開始ファイラー:
# 查看配置文件 filer.toml
$ ./weed scaffold filer
Leveldbデフォルトのファイル管理
# 生成配置文件
$ ./weed scaffold -config filer -output="."
# 示例使用postgres作为元数据存储
# 创建表
=========================================
CREATE TABLE IF NOT EXISTS filemeta (
dirhash BIGINT,
name VARCHAR(1000),
directory VARCHAR(4096),
meta bytea,
PRIMARY KEY (dirhash, name)
);
=========================================
# 配置 filer.toml 中的[postgres]
$ vi filer.toml
起動します。
$ ./weed filer -master cdh1:9333,cdh2:9333,cdh3:9333 -port 8888 -port.public 8889
バックグラウンド化$ nohupを./weedファイラー-master CDH1:9333、CDH2:9333、CDH3:9333 -port 8888> weed_filer.out&
これは、複数の共有つのデータベース、より多くのものより開始することをお勧めします
ファイルのアップロード:
$ curl -F "[email protected]" "http://cdh1:8888/path/to/sources/"
アクセスWebUIのページ:
http://cdh1:8888/
Hadoopの対応:
# MavenCentral下载最新版本
https://mvnrepository.com/artifact/com.github.chrislusf/seaweedfs-hadoop-client
# 确认有 mapred-site.xml 文件
# 测试 ls
==================================================================================
../../bin/hdfs dfs -Dfs.defaultFS=seaweedfs://cdh1:8888 \
-Dfs.seaweedfs.impl=seaweed.hdfs.SeaweedFileSystem \
-libjars ./seaweedfs-hadoop-client-1.0.2.jar \
-ls /
# 返回
Found 2 items
drwxrwx--- - 0 2018-12-13 10:29 /path
drwxrwx--- - 0 2018-12-13 14:17 /weed
# 测试上传文件
==================================================================================
../../bin/hdfs dfs -Dfs.defaultFS=seaweedfs://cdh1:8888 \
-Dfs.seaweedfs.impl=seaweed.hdfs.SeaweedFileSystem \
-libjars ./seaweedfs-hadoop-client-1.0.2.jar \
-put ./slaves /
# 测试下载文件夹
==================================================================================
../../bin/hdfs dfs -Dfs.defaultFS=seaweedfs://cdh1:8888 \
-Dfs.seaweedfs.impl=seaweed.hdfs.SeaweedFileSystem \
-libjars ./seaweedfs-hadoop-client-1.0.2.jar \
-get /path
設定のHadoop:
$ vi core-site.xml
<property>
<name>fs.seaweedfs.impl</name>
<value>seaweed.hdfs.SeaweedFileSystem</value>
</property>
<!--可选 seaweedfs filer 的地址-->
<property>
<name>fs.defaultFS</name>
<value>seaweedfs://cdh1:8888</value>
</property>
# 配置SeaweedFS HDFS客户端jar
$ bin/hadoop classpath
$ cp ./seaweedfs-hadoop-client-1.0.2.jar /hadoop/share/hadoop/common/lib/
$ scp ./seaweedfs-hadoop-client-1.0.2.jar cdh2:/hadoop/share/hadoop/common/lib
$ scp ./seaweedfs-hadoop-client-1.0.2.jar cdh3:/hadoop/share/hadoop/common/lib
$ scp ./core-site.xml cdh2:/hadoop/etc/hadoop/
$ scp ./core-site.xml cdh3:/hadoop/etc/hadoop/
# 查看
$ ../../bin/hdfs dfs -ls seaweedfs://cdh3:8888/
# 返回
Found 3 items
drwxrwx--- - 0 2018-12-13 10:29 seaweedfs://cdh3:8888/path
-rw-r--r-- 1 dpnice dpnice 15 2018-12-13 14:41 seaweedfs://cdh3:8888/slaves
drwxrwx--- - 0 2018-12-13 14:17 seaweedfs://cdh3:8888/weed
API:
マスターサーバーのAPI:
ファイルアロケーションキー:
# Basic Usage:
curl http://localhost:9333/dir/assign
# To assign with a specific replication type:
curl "http://localhost:9333/dir/assign?replication=001"
# To specify how many file ids to reserve
curl "http://localhost:9333/dir/assign?count=5"
# To assign a specific data center
curl "http://localhost:9333/dir/assign?dataCenter=dc1"
アドレスボリュームを探します:
curl "http://localhost:9333/dir/lookup?volumeId=3&pretty=y"
{
"locations": [
{
"publicUrl": "localhost:8080",
"url": "localhost:8080"
}
]
}
# Other usages:
# You can actually use the file id to lookup, if you are lazy to parse the file id.
curl "http://localhost:9333/dir/lookup?volumeId=3,01637037d6"
# If you know the collection, specify it since it will be a little faster
curl "http://localhost:9333/dir/lookup?volumeId=3&collection=turbo"
ガベージコレクション:
curl "http://localhost:9333/vol/vacuum"
curl "http://localhost:9333/vol/vacuum?garbageThreshold=0.4"
ガベージコレクションは、.DATと.idxのファイルのコピーを作成して削除されたファイルをスキップし、元のファイルの削除のコピーを保持します。
garbageThresholdはオプションです。
事前に割り当てられたボリューム:
# specify a specific replication
curl "http://localhost:9333/vol/grow?replication=000&count=4"
{"count":4}
# specify a collection
curl "http://localhost:9333/vol/grow?collection=turbo&count=4"
# specify data center
curl "http://localhost:9333/vol/grow?dataCenter=dc1&count=4"
# specify ttl
curl "http://localhost:9333/vol/grow?ttl=5d&count=4"
代わって、いくつかの空のボリュームを生成数えます
コレクションを削除するには:
# delete a collection
curl "http://localhost:9333/col/delete?collection=benchmark&pretty=y"
システムの状態を確認します。
# 集群状态
curl "http://10.0.2.15:9333/cluster/status?pretty=y"
{
"IsLeader": true,
"Leader": "10.0.2.15:9333",
"Peers": [
"10.0.2.15:9334",
"10.0.2.15:9335"
]
}
# 拓扑状态
curl "http://localhost:9333/dir/status?pretty=y"
{
"Topology": {
"DataCenters": [
{
"Free": 567,
"Id": "dc1",
"Max": 600,
"Racks": [
{
"DataNodes": [
{
"Free": 190,
"Max": 200,
"PublicUrl": "cdh2",
"Url": "cdh2:9222",
"Volumes": 10
},
{
"Free": 190,
"Max": 200,
"PublicUrl": "cdh1",
"Url": "cdh1:9222",
"Volumes": 10
},
{
"Free": 187,
"Max": 200,
"PublicUrl": "cdh3",
"Url": "cdh3:9222",
"Volumes": 13
}
],
"Free": 567,
"Id": "rack1",
"Max": 600
}
]
}
],
"Free": 567,
"Max": 600,
"layouts": [
{
"collection": "",
"replication": "001",
"ttl": "5d",
"writables": [
15,
16,
17,
18
]
},
{
"collection": "",
"replication": "000",
"ttl": "",
"writables": [
13,
14,
10,
11,
12,
19,
20,
21,
22
]
},
{
"collection": "",
"replication": "001",
"ttl": "",
"writables": [
6,
3,
7,
2,
4,
5
]
},
{
"collection": "turbo",
"replication": "001",
"ttl": "",
"writables": [
8,
9
]
}
]
},
"Version": "1.11"
}
ボリューム・サーバーのAPI:
# 上传文件
curl -F file=@/home/chris/myphoto.jpg http://127.0.0.1:8080/3,01637037d6
キー割り当てファイルを習得する前の必要性
# 直接上传文件自动分配key( master的端口)
curl -F file=@/home/chris/myphoto.jpg http://localhost:9333/submit
{"fid":"3,01fbe0dc6f1f38","fileName":"myphoto.jpg","fileUrl":"localhost:8080/3,01fbe0dc6f1f38","size":68231}
# 删除文件
curl -X DELETE http://127.0.0.1:8080/3,01637037d6
# 查看分块大文件的列表文件内容
curl http://127.0.0.1:8080/3,01637037d6?cm=false
# 检查 Volume Server 的状态
curl "http://localhost:8080/status?pretty=y"
{
"Version": "0.34",
"Volumes": [
{
"Id": 1,
"Size": 1319688,
"RepType": "000",
"Version": 2,
"FileCount": 276,
"DeleteCount": 0,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 2,
"Size": 1040962,
"RepType": "000",
"Version": 2,
"FileCount": 291,
"DeleteCount": 0,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 3,
"Size": 1486334,
"RepType": "000",
"Version": 2,
"FileCount": 301,
"DeleteCount": 2,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 4,
"Size": 8953592,
"RepType": "000",
"Version": 2,
"FileCount": 320,
"DeleteCount": 2,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 5,
"Size": 70815851,
"RepType": "000",
"Version": 2,
"FileCount": 309,
"DeleteCount": 1,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 6,
"Size": 1483131,
"RepType": "000",
"Version": 2,
"FileCount": 301,
"DeleteCount": 1,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 7,
"Size": 46797832,
"RepType": "000",
"Version": 2,
"FileCount": 292,
"DeleteCount": 0,
"DeletedByteCount": 0,
"ReadOnly": false
}
]
}
ファイラーサーバーAPI:
# Basic Usage:
# create or overwrite the file, the directories /path/to will be automatically created
curl -F [email protected] "http://localhost:8888/path/to"
{"name":"report.js","size":866,"fid":"7,0254f1f3fd","url":"http://localhost:8081/7,0254f1f3fd"}
# get the file content
curl "http://localhost:8888/javascript/report.js"
# upload the file with a different name
curl -F [email protected] "http://localhost:8888/javascript/new_name.js"
{"name":"report.js","size":866,"fid":"3,034389657e","url":"http://localhost:8081/3,034389657e"}
# list all files under /javascript/
curl -H "Accept: application/json" "http://localhost:8888/javascript/?pretty=y"
{
"Directory": "/javascript/",
"Files": [
{
"name": "new_name.js",
"fid": "3,034389657e"
},
{
"name": "report.js",
"fid": "7,0254f1f3fd"
}
],
"Subdirectories": null
}
# 分页查看文件列表
curl "http://localhost:8888/javascript/?pretty=y&lastFileName=new_name.js&limit=2"
{
"Directory": "/javascript/",
"Files": [
{
"name": "report.js",
"fid": "7,0254f1f3fd"
}
]
}
# 删除文件
curl -X DELETE "http://localhost:8888/javascript/report.js"