Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 0381327

Browse files
committed
add supernode config
Signed-off-by: yunfeiyangbuaa <[email protected]>
1 parent bb999f2 commit 0381327

File tree

7 files changed

+360
-0
lines changed

7 files changed

+360
-0
lines changed

docs/config/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# About this folder
2+
3+
All the documents in `config` folder help user to configure Dragonfly.
4+
5+
## How to configure dragonfly
6+
7+
We can use cli and yaml file to configure Dragonfly when deploying the system.
8+
This tutorial only teaches you how to configure by yaml file.
9+
If you want to config Dragonfly by cli, you can read docs in [cli_reference folder](https://github.com/dragonflyoss/Dragonfly/tree/master/docs/cli_reference).
10+
In fact, learn this tutorial also will help you a lot, because the two ways are similar.
11+
12+
## About the yaml file
13+
14+
Because Dragonfly is composed of supernode, dfget, dfdaemon, you should learn how to configure them separately.
15+
You can reference the three tutorials([supernode](supernode_properties.md), [dfget](dfget_properties.md), [dfdaemon](dfdaemon_properties.md)) to finish the yaml file and deploy.
16+
17+
## About deploying in docker
18+
19+
When deploying with Docker, you can mount the default path when starting up image with `-v`.
20+
For supernode, you should start a supernode image using the following command.
21+
22+
```sh
23+
docker run -d --name supernode --restart=always -p 8001:8001 -p 8002:8002 -v /etc/dragonfly/supernode.yml:/etc/dragonfly/supernode.yml dragonflyoss/supernode:0.4.3
24+
```
25+
26+
For dfdaemon, you can start the image in the same way.
27+
28+
```sh
29+
docker run -d --net=host --name dfclient -p 65001:65001 -v /etc/dragonfly/dfdaemon.yml:/etc/dragonfly/dfdaemon.yml -v /root/.small-dragonfly:/root/.small-dragonfly dragonflyoss/dfclient:0.4.3
30+
```
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# This file is the template of dfdaemon configuration file.
2+
# You can configure your dfdaemon by change the parameter according your requirement.
3+
4+
# RegistryMirror configures the mirror of the official docker registry
5+
registry_mirror:
6+
# url for the registry mirror
7+
# Remote url for the registry mirror, default is https://index.docker.io
8+
  remote: https://index.docker.io
9+
# whether to ignore https certificate errors
10+
  insecure: false
11+
# optional certificates if the remote server uses self-signed certificates
12+
  certs: []
13+
14+
# Proxies is the list of rules for the transparent proxy. If no rules
15+
# are provided, all requests will be proxied directly. Request will be
16+
# proxied with the first matching rule.
17+
proxies:
18+
# proxy all http image layer download requests with dfget
19+
  - regx: blobs/sha256.*
20+
# change http requests to some-registry to https and proxy them with dfget
21+
  - regx: some-registry/
22+
    use_https: true
23+
# proxy requests directly, without dfget
24+
  - regx: no-proxy-reg
25+
    direct: true
26+
27+
# HijackHTTPS is the list of hosts whose https requests should be hijacked
28+
# by dfdaemon. Dfdaemon will be able to proxy requests from them with dfget
29+
# if the url matches the proxy rules. The first matched rule will be used.
30+
hijack_https:
31+
# key pair used to hijack https requests
32+
  cert: df.crt
33+
  key: df.key
34+
  hosts:
35+
    - regx: mirror.aliyuncs.com:443 # regexp to match request hosts
36+
# whether to ignore https certificate errors
37+
    insecure: false
38+
# optional certificates if the host uses self-signed certificates
39+
    certs: []
40+
41+
# dfget properties
42+
# node: specify the addresses
43+
# ip: IP address that server will listen on
44+
# port: port number that server will listen on
45+
# expiretime: caching duration for which cached file keeps no accessed by any process(default 3min). Deploying with Docker, this param is supported after dragonfly 0.4.3
46+
# alivetime: Alive duration for which uploader keeps no accessing by any uploading requests, after this period uploader will automically exit (default 5m0s)
47+
# f: filter some query params of URL, use char '&' to separate different params
48+
dfget_flags: ["--node","192.168.33.21","--verbose","--ip","192.168.33.23",
49+
"--port","15001","--expiretime","3m0s","--alivetime","5m0s",
50+
"-f","filterParam1&filterParam2"]
51+
52+
# Specify the addresses(host:port) of supernodes, it is just to be compatible with previous versions
53+
supernodes:
54+
- 127.0.0.1
55+
- 10.10.10.1
56+
57+
# Net speed limit,format:xxxM/K
58+
ratelimit: 20M
59+
60+
# Temp output dir of dfdaemon, it must be an absolute path. and the default value is `$HOME/.small-dragonfly/dfdaemon/data/`
61+
localrepo: /home/admin/.small-dragonfly/dfdaemon/data/
62+
63+
# dfget path, which is the relative file path for the dfdaemon
64+
dfpath: ./dfget
65+
66+
# https options
67+
# port: 12001
68+
# hostIp: 127.0.0.1
69+
# certpem: ""
70+
# keypem: ""
71+
72+
#Open detail info switch
73+
verbose: false
74+
75+
# The maximum number of CPUs that the dfdaemon can use
76+
maxprocs: 10

docs/config/dfdaemon_properties.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Customize dfdaemon properties
2+
3+
This topic explains how to customize the dragonfly dfdaemon startup parameters.
4+
5+
## Parameter instructions
6+
7+
The following startup parameters are supported for `dfdaemon`
8+
9+
| Parameter | Description |
10+
| ------------- | ------------- |
11+
| dfget_flags | dfget properties |
12+
| dfpath | dfget path |
13+
| hijack_https | HijackHTTPS is the list of hosts whose https requests should be hijacked by dfdaemon. The first matched rule will be used |
14+
| localrepo | Temp output dir of dfdaemon, by default `$HOME/.small-dragonfly/dfdaemon/data/` |
15+
| maxprocs| The maximum number of CPUs that the dfdaemon can use |
16+
| proxies | Proxies is the list of rules for the transparent proxy |
17+
| ratelimit | Net speed limit,format:xxxM/K |
18+
| registry_mirror | Registry mirror settings |
19+
| supernodes | Specify the addresses(host:port) of supernodes, it is just to be compatible with previous versions |
20+
| verbose | Open detail info switch |
21+
22+
## Examples
23+
24+
Parameters are configured in `/etc/dragonfly/dfdaemon.yml`.
25+
To make it easier for you, you can copy the [template](dfdaemon_config_template.yml) and modify it according to your requirement.
26+
27+
Properties holds all configurable properties of dfdaemon including `dfget` properties. By default, dragonfly configuration files locate at `/etc/dragonfly`. You can create `dfdaemon.yml` for configuring dfdaemon startup params.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file is the template of dfget configuration file.
2+
# You can configure your dfget by change the parameter according your requirement.
3+
4+
# Nodes specify supernodes.
5+
nodes:
6+
 - 127.0.0.1
7+
 - 10.10.10.1
8+
9+
# LocalLimit rate limit about a single download task, format: G(B)/g/M(B)/m/K(B)/k/B
10+
# pure number will also be parsed as Byte.
11+
localLimit: 20M
12+
13+
# Minimal rate about a single download task, format: G(B)/g/M(B)/m/K(B)/k/B
14+
# pure number will also be parsed as Byte.
15+
minRate: 512
16+
17+
# TotalLimit rate limit about the whole host, format: G(B)/g/M(B)/m/K(B)/k/B
18+
# pure number will also be parsed as Byte.
19+
totalLimit: 40M
20+
21+
# ClientQueueSize is the size of client queue
22+
# which controls the number of pieces that can be processed simultaneously.
23+
# It is only useful when the Pattern equals "source".
24+
# The default value is 6.
25+
clientQueueSize: 6

docs/config/dfget_properties.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Customize dfget properties
2+
3+
This topic explains how to customize the dragonfly dfget startup parameters.
4+
5+
## Parameter instructions
6+
7+
The following startup parameters are supported for `dfget`
8+
9+
| Parameter | Description |
10+
| ------------- | ------------- |
11+
| nodes | Nodes specify supernodes |
12+
| localLimit | LocalLimit rate limit about a single download task,format: 20M/m/K/k |
13+
| minRate | Minimal rate about a single download task. it's type is integer. The format of `M/m/K/k` will be supported soon |
14+
| totalLimit | TotalLimit rate limit about the whole host,format: 20M/m/K/k |
15+
| clientQueueSize | ClientQueueSize is the size of client queue, which controls the number of pieces that can be processed simultaneously. It is only useful when the Pattern equals "source". The default value is 6 |
16+
17+
## Examples
18+
19+
Parameters are configured in `/etc/dragonfly/dfget.yml`.
20+
To make it easier for you, you can copy the [template](dfget_config_template.yml) and modify it according to your requirement.
21+
22+
By default, dragonfly config files locate at `/etc/dragonfly`. You can create `dfget.yml` in the path if you want to install dfget in physical machine.
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# This file is the template of supernode configuration file.
2+
# You can configure your supernode by change the parameter according your requirement.
3+
4+
base:
5+
# AdvertiseIP is used to set the ip that we advertise to other peer in the p2p-network.
6+
# By default, the first non-loop address is advertised.
7+
advertiseIP: 127.0.0.1
8+
9+
# ListenPort is the port supernode server listens on.
10+
# default: 8002
11+
listenPort: 8005
12+
13+
# DownloadPort is the port for download files from supernode.
14+
# default: 8001
15+
downloadPort: 8001
16+
17+
# HomeDir is working directory of supernode.
18+
# default: /home/admin/supernode
19+
homeDir: /home/admin/supernode
20+
21+
# the core pool size of ScheduledExecutorService.
22+
# When a request to start a download task, supernode will construct a thread concurrent pool
23+
# to download pieces of source file and write to specified storage.
24+
# Note: source file downloading is into pieces via range attribute set in HTTP header.
25+
# default: 10
26+
schedulerCorePoolSize: 10
27+
28+
# DownloadPath specifies the path where to store downloaded files from source address.
29+
# This path can be set beyond BaseDir, such as taking advantage of a different disk from BaseDir's.
30+
# default: $BaseDir/downloads
31+
downloadPath: /home/admin/supernode/downloads
32+
33+
# PeerUpLimit is the upload limit of a peer. When dfget starts to play a role of peer,
34+
# it can only stand PeerUpLimit upload tasks from other peers.
35+
# default: 5
36+
peerUpLimit: 5
37+
38+
# PeerDownLimit is the download limit of a peer. When a peer starts to download a file/image,
39+
# it will download file/image in the form of pieces. PeerDownLimit mean that a peer can only
40+
# stand starting PeerDownLimit concurrent downloading tasks.
41+
# default: 4
42+
peerDownLimit: 4
43+
44+
# When dfget node starts to play a role of peer, it will provide services for other peers
45+
# to pull pieces. If it runs into an issue when providing services for a peer, its self failure
46+
# increases by 1. When the failure limit reaches EliminationLimit, the peer will isolate itself
47+
# as a unhealthy state. Then this dfget will be no longer called by other peers.
48+
# default: 5
49+
eliminationLimit: 5
50+
51+
# FailureCountLimit is the failure count limit set in supernode for dfget client.
52+
# When a dfget client takes part in the peer network constructed by supernode,
53+
# supernode will command the peer to start distribution task.
54+
# When dfget client fails to finish distribution task, the failure count of client
55+
# increases by 1. When failure count of client reaches to FailureCountLimit(default 5),
56+
# dfget client will be moved to blacklist of supernode to stop playing as a peer.
57+
# default: 5
58+
failureCountLimit: 5
59+
60+
# LinkLimit is set for supernode to limit every piece download network speed.
61+
# default: 20 MB, in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will also be parsed as Byte.
62+
linkLimit: 20M
63+
64+
# SystemReservedBandwidth is the network bandwidth reserved for system software.
65+
# default: 20 MB, in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will also be parsed as Byte.
66+
systemReservedBandwidth: 20M
67+
68+
# MaxBandwidth is the network bandwidth that supernode can use.
69+
# default: 200 MB, in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will also be parsed as Byte.
70+
maxBandwidth: 200M
71+
72+
# Whether to enable profiler
73+
# default: false
74+
enableProfiler: false
75+
76+
# Whether to open DEBUG level
77+
# default: false
78+
debug: false
79+
80+
# FailAccessInterval is the interval time after failed to access the URL.
81+
# default: 3m
82+
failAccessInterval: 3m
83+
84+
# gc related
85+
86+
# GCInitialDelay is the delay time from the start to the first GC execution.
87+
# default: 6s
88+
gcInitialDelay: 6s
89+
90+
# GCMetaInterval is the interval time to execute GC meta.
91+
# default: 2m0s
92+
gcMetaInterval: 2m
93+
94+
# TaskExpireTime when a task is not accessed within the taskExpireTime,
95+
# and it will be treated to be expired.
96+
# default: 3m0s
97+
taskExpireTime: 3m
98+
99+
# PeerGCDelay is the delay time to execute the GC after the peer has reported the offline.
100+
# default: 3m0s
101+
peerGCDelay: 3m
102+
103+
# GCDiskInterval is the interval time to execute GC disk.
104+
# default: 15s
105+
gcDiskInterval: 15s
106+
107+
# YoungGCThreshold if the available disk space is more than YoungGCThreshold
108+
# and there is no need to GC disk.
109+
# default: 100GB
110+
youngGCThreshold: 100G
111+
112+
# FullGCThreshold if the available disk space is less than FullGCThreshold
113+
# and the supernode should gc all task files which are not being used.
114+
# default: 5GB
115+
fullGCThreshold: 5G
116+
117+
# IntervalThreshold is the threshold of the interval at which the task file is accessed.
118+
# default: 2h0m0s
119+
IntervalThreshold: 2h
120+
plugins: {}
121+
storages: {}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Customize supernode properties
2+
3+
This topic explains how to customize the dragonfly supernode startup parameters.
4+
5+
## Parameter instructions
6+
7+
### The parameters we can configure in supernode are as follows
8+
9+
The following startup parameters are supported for `supernode`
10+
11+
| Parameter | Default | Description |
12+
| ------------- | ------------- | ------------- |
13+
| listenPort | 8002 | listenPort is the port that supernode server listens on |
14+
| downloadPort | 8001 | downloadPort is the port for download files from supernode |
15+
| homeDir | /home/admin/supernode | homeDir is the working directory of supernode |
16+
| advertiseIP | the first non-loop address | the supernode ip is the ip we advertise to other peers in the p2p-network |
17+
| schedulerCorePoolSize | 10 | pool size is the core pool size of ScheduledExecutorService(the parameter is aborted) |
18+
| downloadPath | /home/admin/supernode/repo/download | DownloadPath specifies the path where to store downloaded files from source address |
19+
| peerUpLimit | 5 | upload limit for a peer to serve download tasks |
20+
| peerDownLimit | 4 |the task upload limit of a peer when dfget starts to play a role of peer |
21+
| eliminationLimit | 5 | if a dfget fails to provide service for other peers up to eliminationLimit, it will be isolated |
22+
| failureCountLimit | 5 | when dfget client fails to finish distribution task up to failureCountLimit, supernode will add it to blacklist|
23+
| linkLimit | 20M | LinkLimit is set for supernode to limit every piece download network speed |
24+
| systemReservedBandwidth | 20M | network rate reserved for system |
25+
| maxBandwidth | 200M | network rate that supernode can use |
26+
| enableProfiler | false | profiler sets whether supernode HTTP server setups profiler |
27+
| debug | false | switch daemon log level to DEBUG mode |
28+
| failAccessInterval | 3m0s | fail access interval is the interval time after failed to access the URL |
29+
| gcInitialDelay | 6s | gc initial delay is the delay time from the start to the first GC execution |
30+
| gcMetaInterval | 2m0s | gc meta interval is the interval time to execute the GC meta |
31+
| taskExpireTime | 3m0s | task expire time is the time that a task is treated expired if the task is not accessed within the time |
32+
| peerGCDelay | 3m0s | peer gc delay is the delay time to execute the GC after the peer has reported the offline |
33+
| gcDiskInterval | 15s | GCDiskInterval is the interval time to execute GC disk |
34+
| youngGCThreshold | 100GB | if the available disk space is more than YoungGCThreshold and there is no need to GC disk |
35+
| fullGCThreshold | 5GB | if the available disk space is less than FullGCThreshold and the supernode should gc all task files which are not being used |
36+
| IntervalThreshold | 2h0m0s | IntervalThreshold is the threshold of the interval at which the task file is accessed |
37+
38+
### Some common configurations
39+
40+
We use `--config` to specify the configuration file directory, the default value is `/etc/dragonfly/supernode.yml`
41+
In Dragonfly, supernode provides `listenPort` for dfgets to connect, and dfget downloads document from `downloadPort` instead of `listenPort`.
42+
We can also configure the supernode's IP via `advertiseIP`.
43+
44+
### About gc parameters
45+
46+
In supernode, gc will begin `gcInitialDelay` time after supernode works.
47+
Then supernode will run peer-gc goroutine and task-gc goroutine every `gcMetaInterval` time.
48+
If a task isn't accessed by dfgets in `taskExpireTime` time, task-gc goroutine will gc this task.
49+
If a peer reports that it's offline and can't provide download service to other peers, peer-gc goroutine will gc this peer after `peerGCDelay` time.
50+
51+
## Examples
52+
53+
To make it easier for you, you can copy the [template](supernode_config_template.yml) and modify it according to your requirement.
54+
55+
When deploying in your physical machine, you can use `--config` to configure where is the configuration file.
56+
57+
```ssh
58+
supernode --config /etc/dragonfly/supernode.yml
59+
```

0 commit comments

Comments
 (0)