Hi,
You can choose only one distance to dump the ETCD data, just define a rational
value for `etcd/dump/interval`:
```yaml
etcd:
...
dump:
interval: 300
```
And you can also set the others to disable the dump action:
```yaml
etcd:
...
dump:
interval: 0
load_on_failure: true
```
2021年4月15日 10:05,Chao Zhang <[email protected]<mailto:[email protected]>>
写道:
外部邮件,慎点链接。
Hi!
As this is an event with low probabilities, I think the dump function can
be implemented in a separate script, when the network is partitioned, running
this script (maybe in one of the pod/vm of etcd instances) and getting this
config.yaml,
uploading/mount it to the machine/pod of APISIX. APISIX only needs to support
load
the static configuration when communicating to etcd failed.
Chao Zhang
https://github<https://github/>.com/tokers
On April 14, 2021 at 17:46:04, 聂永
([email protected]<mailto:[email protected]>) wrote:
Hi,
We need the `etcd` cluster for storing gateway's config, but we are afraid of
it being inaccessible when we reload or deploy gateway distance as network
issues.
## Dump etcd
So, we need the apisix to dump the etcd's stored data into `conf/apisix.yaml `
file, when it is running every 5 minutes.
And, if the already existed apisix distance need to restart in some unexpected
case, or we need do deploy a large number of distance online in a short time,
if the distance queries data from `etcd` unsuccessfully when starting, we need
to load the dumped `conf/apisix.yaml` file into memory once.
Firstly, we need to import the `dump` for `etcd` config:
```yaml
etcd:
host:
- "http://172.19.5.10:23792<http://172.19.5.10:23792/>"
prefix: "/apisix"
dump:
interval: 300 # unit seconds
load_on_failure: true # if true, then try to load data from dumped
conf/apisix.yaml file when querying etcd failure first
```
And, when initializing, it will start a timer for dumping in cycles:
```lua
local dump_conf = etcd_conf.dump
local dump_interval = dump_conf.interval or 300
if dump_interval > 0 and 0 == ngx.worker.id<http://ngx.worker.id/>() then
ngx_timer_every(dump_interval, dump_etcd)
end
```
If it queries `etcd` failure first time, then will try to load data from
`conf/apisix.yaml` file once,(with its work flow
pichttps://user-images.githubusercontent.com/548385/114687020-e8dc7b80-9d45-11eb-94ea-1f28465e0580.png),
and its code snippet below:
```lua
local ok, err = sync_data(self)
if err then
if i == 1 and self.fail_load_yaml and not failure_map[self.key] then
failure_map[self.key] = 1
try_load_data_from_yaml(self)
end
......
```
## More usage
If we use [`Stand-alone
mode`](https://github.com/apache/apisix/blob/master/docs/en/latest/stand-alone.md)
below:
```yaml
config_center: yaml
```
We can also use it to update `conf/apisix.yaml` file periodically.