Skip to content

Commit 1f6da9d

Browse files
committed
update
1 parent 3d17420 commit 1f6da9d

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed

docs/zh/2.13-config-dns.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: 动态DNS查询
3+
permalink: /docs/zh/config-dns
4+
key: docs-config-dns-zh
5+
---
6+
7+
8+
## 适用场景
9+
10+
[notify](./config-notify)[pull](./config-dir-pull)[push](./config-dir-push)操作过程中会使用到域名,动态dns查询支持动态更新域名解析。
11+
{:.success}
12+
^
13+
14+
## 配置
15+
16+
### resolver
17+
18+
*Syntax:* `resolver [dns-server];`
19+
*Default:* -
20+
*Context:* event
21+
22+
* **Desc**
23+
> 向DNS服务器查询服务器中使用到的域名。
24+
25+
### resolver_timeout
26+
*Syntax:* `resolver_timeout [time];`
27+
*Default:* 60s
28+
*Context:* event
29+
30+
* **Desc**
31+
> 等待DNS服务器返回结果的超时时间。
32+
33+
### dynamic_refresh_interval
34+
*Syntax:* `dynamic_refresh_interval [time];`
35+
*Default:* 5s
36+
*Context:* event
37+
38+
* **Desc**
39+
> 更新域名解析结果的间隔时间。
40+
41+
## 配置模板
42+
43+
```nginx
44+
user root;
45+
daemon off;
46+
master_process off;
47+
worker_processes 1;
48+
#worker_rlimit 4g;
49+
50+
#error_log logs/error.log;
51+
#error_log logs/error.log notice;
52+
error_log logs/error.log info;
53+
54+
worker_rlimit_nofile 102400;
55+
worker_rlimit_core 2G;
56+
working_directory /tmp;
57+
58+
#pid logs/nginx.pid;
59+
60+
events {
61+
use epoll;
62+
worker_connections 1024;
63+
multi_listen unix:/tmp/http 80;
64+
multi_listen unix:/tmp/rtmp 1935;
65+
66+
dynamic_refresh_interval 2s; # DNS更新间隔
67+
# dynamic_domain_buckets 1001;
68+
resolver 114.114.114.114; # DNS服务器
69+
resolver_timeout 30s; # DNS超时查询
70+
}
71+
72+
rtmp {
73+
server {
74+
listen 1935;
75+
76+
application * {
77+
pull rtmp://live.pingos.io/live/ice app=live; # 对域名 live.pingos.io 解析
78+
live on;
79+
}
80+
}
81+
}
82+
83+
http {
84+
include mime.types;
85+
default_type application/octet-stream;
86+
87+
server {
88+
listen 80;
89+
location / {
90+
chunked_transfer_encoding on;
91+
root html/;
92+
}
93+
}
94+
}
95+
```
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: 多进程模式
3+
permalink: /docs/zh/config-multiple-process
4+
key: docs-config-multiple-process-zh
5+
---
6+
7+
### 进程间回源
8+
9+
```mermaid
10+
graph LR;
11+
pub[推流端]
12+
p0[worker进程0]
13+
p1[worker进程1]
14+
p2[worker进程2]
15+
pl0[拉流端0]
16+
pl1[拉流端1]
17+
pl2[拉流端2]
18+
pl3[拉流端3]
19+
pub-->p0
20+
p0-->p1
21+
p0-->p2
22+
p1-->pl0
23+
p1-->pl1
24+
p2-->pl2
25+
p2-->pl3
26+
```
27+
28+
在nginx多进程情况下rtmp或http连接被分配到不同worker进程,推流端连接和拉流端连接可能会被分配到不同进程,从而导致一定概率的无法拉流。
29+
为了解决这个问题,我们可以让其他进程向推流端连接的进程回源。由于这种方式跟跨服务器之间的回源逻辑一致,所以我们将这种操作称为`进程间回源`{:.error}。
30+
{:.info}
31+
32+
### 配置
33+
34+
#### rtmp_auto_pull
35+
*Syntax:* `rtmp_auto_pull on|off`
36+
*Default:* `off`{:.info}
37+
*Context:* rtmp, server, application
38+
39+
* **Desc**
40+
进程间回源开关,on 开启进程间回源,off关闭进程间回源,如果你希望使用nginx的多进程模式,已经要将这个配置设置成on。
41+
42+
---
43+
44+
#### rtmp_auto_pull_port
45+
46+
*Syntax:* `rtmp_auto_pull_port value`
47+
*Default:* -
48+
*Context:* rtmp, server, application
49+
50+
* **Desc**
51+
进程间回源所使用的unix套接字地址,需要注意的是此地址必须要与`multi_listen`中的保持一致。
52+
53+
#### multi_listen
54+
*Syntax:* `multi_listen [unix socket] [rtmp port]`
55+
*Default:* -
56+
*Context:* event
57+
58+
* **Desc**
59+
multi_listen的作用是让每个worker进程监听不同的unix套接字,然后通过向不同unix套接字推拉流实现多进程的流共享。
60+
61+
### 配置模板
62+
63+
```nginx
64+
user root;
65+
daemon on;
66+
master_process on;
67+
worker_processes 6; # 开启6个worker进程
68+
69+
error_log logs/error.log info;
70+
71+
events {
72+
use epoll;
73+
worker_connections 1024;
74+
multi_listen unix:/tmp/rtmp 1935; # 为1935端口开启多进程端口映射,每个进程都开启一个unix套接字映射到1935端口上
75+
}
76+
77+
rtmp {
78+
rtmp_auto_pull on;
79+
rtmp_auto_pull_port unix:/tmp/rtmp; # 进程间回源使用的unix套接字地址,该地址必须与 multi_listen 中的配置一致
80+
server {
81+
listen 1935;
82+
application live {
83+
live on;
84+
}
85+
}
86+
}
87+
88+
http {
89+
server {
90+
listen 80;
91+
location /flv {
92+
flv_live 1935 app=live;
93+
}
94+
95+
location /ts {
96+
ts_live 1935 app=live;
97+
}
98+
}
99+
}
100+
101+
```

0 commit comments

Comments
 (0)