--- title: Elasticsearch Back up a cluster’s configuration tags: Elasticsearch description: View the slide with "Slide Mode". --- # Elasticsearch Back up a cluster’s configuration ## 總結 1. 對RPM安裝的環境來說,ES_PATH_CONF=<font color=red>`/etc/elasticsearch`</font> 2. 在這個資料夾裡面很重要的檔案有兩種,<font color=red>設定檔跟 elasticsearch.keystore</font> - 設定檔:elasticsearch.yml, jvm.options, log4j2.properties 3. 其他沒規範在設定檔裡的設定,可以在呼叫snapshot API的時候備份出來 - 參數:include_global_state: true 5. 最好對這些設定檔進行版控 --- ## 以下為詳細文件閱讀紀錄 [官方文件](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/backup-cluster-configuration.html) >In addition to backing up the data in a cluster, it is important to back up its configuration—​especially when the cluster becomes large and difficult to reconstruct. > >Configuration information resides in [regular text files](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/settings.html#config-files-location) on every cluster node. Sensitive setting values such as passwords for the Watcher notification servers, are specified inside a binary secure container, the [elasticsearch.keystore](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/secure-settings.html) file. Some setting values are file paths to the associated configuration data, such as the ingest geo ip database. <font color=blue>All these files are contained inside the ES_PATH_CONF directory.</font> :::info :point_right: All changes to configuration files are done <font color=red>by manually</font> editing the files or using command line utilities, but <font color=red>not</font> through APIs. In practice, these changes are infrequent after the initial setup. ::: > We recommend that you take regular (ideally, daily) backups of your Elasticsearch config ($ES_PATH_CONF) directory using the file backup software of your choice. > [name=昱齊] For RPM, ES_PATH_CONF=<font color=red>`/etc/elasticsearch`</font> > [regular text file筆記](#Configuring-Elasticsearch) :::info :man-tipping-hand: We recommend that you have a configuration management plan for these configuration files. You may wish to check them into <font color=red>version control</font>, or provision them though your choice of configuration management tool. ::: >[name=昱齊]對設定檔做管理,像是版控 ### 機敏資料 >Some of these files may contain sensitive data such as passwords and TLS keys, therefore you should investigate whether your backup software and/or storage solution are able to encrypt this data. >[name=昱齊]對passwords and TLS keys作加密,再做備份 >Some settings in configuration files might be overridden by cluster settings. You can <font color=red>capture these settings</font> in a <font color=red>data backup snapshot</font> by specifying the <font color=red>include_global_state: true</font> (default) parameter for the snapshot API. Alternatively, you can extract these configuration values in text format by using the get settings API: >[name=昱齊] <font color=red>cluster setting可以在摳snapshot api的時候做</font> ## Configuring Elasticsearch 絕大部分的設定都是可以用[Cluster Update Settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/cluster-update-settings.html) API,除了node資訊或者cluster name這種,還是得放在各個node的設定檔中 ### Config files location Elasticsearch has <font color=blue>three</font> configuration files: 1. ==elasticsearch.yml== for configuring Elasticsearch 1. ==jvm.options== for configuring Elasticsearch JVM settings 1. ==log4j2.properties== for configuring Elasticsearch logging ## Secure settings - 可以把機敏設定存放在`elasticsearch.keystore` - 每個node都有一份 `elasticsearch.keystore` - 指令為 `$ bin/elasticsearch-keystore` - create - list - add :::warning All the modifications to the keystore take affect only after restarting Elasticsearch. ::: --- [問號,這啥] ```htmlmixed= [root@ ~]# ls /var/lib/elasticsearch/nodes/0 node.lock _state ```