Elasticsearch安裝配置

1. 安裝:

要求至少Java 8(推薦使用Oracle JDK version 1.8.0_121)并設(shè)置$JAVA_HOME。

# 下載tar包或rpm包。
tarName="elasticsearch-5.3.2.tar.gz"
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/${tarName}
tar -xf ${tarName}
dirName=`tar -tf "${tarName}" | head -1`
dirName=${dirName%%\/*}
cd ${dirName}

#創(chuàng)建elastic賬號運(yùn)行如果用root賬號運(yùn)行則會報(bào)錯(cuò)(提示"can not run elasticsearch as root" !)
useradd elastic
chown elastic:elastic `pwd`
su  elastic

# 啟動(dòng) elasticsearch
./bin/elasticsearch

# 以daemon方式運(yùn)行 
#-p指定pid文件
./bin/elasticsearch -d -p pid  
#或 
nohup ./bin/elasticsearch  &

# 測試是否運(yùn)行
elServer="內(nèi)網(wǎng)ip:9200"
curl -XGET "${elServer}/?pretty"

# 停止進(jìn)程
kill -9 `cat pid`

2. 配置命令行參數(shù)

elasticsearch 默認(rèn)從 $ES_HOME/config/elasticsearch.yml 文件中加載其配置。
所有可以在配置文件中指定的設(shè)置也可以在命令行上指定,使用 -E 語法,如下所示

./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1

一般來說,所有cluster-wide的設(shè)置應(yīng)該寫在配置文件中,所有node-wide的設(shè)置應(yīng)該寫在命令行上。

3. 目錄結(jié)構(gòu)說明

3.1 tar包安裝方式的目錄結(jié)構(gòu)

  • home目錄 :使用$ES_HOME表示
  • bin/ : 位置 $ES_HOME/bin,包含了elasticsearch和elasticsearch-plugin等腳本
  • conf/ :位置 $ES_HOME/config,包含了 配置文件 elasticsearch.yml 和 log4j2.properties,使用 path.conf 指定
  • data/ :位置 $ES_HOME/data,包含了每個(gè)index/shard的數(shù)據(jù)文件,可以指定多個(gè)位置,使用 path.data 指定
  • logs/ : 位置 $ES_HOME/logs,使用 path.logs 指定
  • plguins/ : 位置$ES_HOME/plugins
  • repo/ :使用 path.repo指定,沒有默認(rèn)位置,表示共享文件系統(tǒng)repository的位置??梢灾付ǘ鄠€(gè)位置。
  • script/ :位置$ES_HOME/scripts,使用 path.scripts 指定。

3.2 RPM 安裝方式的目錄結(jié)構(gòu)

https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html

RPM方式安裝的elasticsearch 默認(rèn)會從 /etc/elasticsearch/elasticsearch.yml 加載其配置

RPM方式安裝的elasticsearch 還會使用 /etc/sysconfig/elasticsearch ,允許你設(shè)置如下的參數(shù):

  • ES_USER :默認(rèn) elasticsearch ,表示指定使用哪個(gè)用戶運(yùn)行elasticsearch。
  • ES_GROUP:默認(rèn)是 elasticsearch。
  • JAVA_HOME:設(shè)置自定義的要使用的JAVA path
  • MAX_OPEN_FILES:打開文件的最大數(shù)量。默認(rèn)是65536
  • MAX_LOCKED_MEMORY:最大locked memory size。如果你在elasticsearch.yml中使用了
  • bootstrap.memory_lock,則設(shè)置為unlimited 。
  • MAX_MAP_COUNT:內(nèi)存map區(qū)域的最大數(shù)量。如果你使用mmapfs作為index存儲類型,要確保這個(gè)值設(shè)置的夠大。這個(gè)值是在啟動(dòng)elasticsearch之前,通過sysctl設(shè)置。默認(rèn)值是 262144。
  • LOG_DIR :
  • DATA_DIR:
  • CONF_DIR:
  • ES_JAVA_OPTS:
  • RESTART_ON_UPGRADE:
rpm包安裝方式的目錄結(jié)構(gòu)
  • home目錄 默認(rèn)是/usr/share/elasticsearch
  • bin目錄 默認(rèn)是 $ES_HOME/bin
  • conf目錄 默認(rèn)是 /etc/elasticsearch
  • 環(huán)境變量文件 默認(rèn)是 /etc/sysconfig/elasticsearch
  • data/目錄 默認(rèn)是 /var/lib/elasticsearch
  • logs/目錄 默認(rèn)是 /var/log/elasticsearch
  • plugins目錄 默認(rèn)是 $ES_HOME/plugins
  • repo目錄 默認(rèn)沒有配置。
  • scripts目錄默認(rèn)位置是 /etc/elasticsearch/scripts

4. 配置elasticsearch

https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html

  • (1) 配置文件格式為YAML。支持 path.data的語法或 path: data: /var/lib/elasticsearch語法。
  • (2) 如果你不想將配置寫在配置文件中,使用 node.name: ${prompt.text} ,這樣在啟動(dòng)時(shí)會讓用戶輸入,但是這種用法不能用在服務(wù)或后臺運(yùn)行方式中
  • (3) 在命令行上設(shè)置默認(rèn)值 -Edefault.node.name="XXX"

4.1 重要的配置項(xiàng):

  • path.data 和 path.logs :如果使用的是tar包模式安裝的,默認(rèn)情況下,這兩個(gè)文件夾位于$ES_HOME下的子文件夾,當(dāng)升級elasticsearch時(shí)這兩個(gè)文件夾很容易被刪除,所以最好將其設(shè)置到其他位置。
    例如在 config/elasticsearch.yml 中設(shè)置
path.logs: /var/log/elasticsearch
 path.data: /var/data/elasticsearch
  • cluster.name : 在 config/elasticsearch.yml 中設(shè)置
cluster.name: logging-prod
  • node.name : 在 config/elasticsearch.yml 中設(shè)置
node.name: prod-data-2
node.name: ${HOSTNAME} #使用主機(jī)名
  • bootstrap.memory_lock:這個(gè)配置項(xiàng)對node的健康極其重要,JVM永遠(yuǎn)不swapped out to disk,即永遠(yuǎn)不使用交換分區(qū)將JVM交換到磁盤上。在 config/elasticsearch.yml 中設(shè)置
bootstrap.memory_lock: true

要查看該設(shè)置是否生效,通過如下的API請求,然后檢查返回內(nèi)容中的mlockall的值

GET _nodes?filter_path=**.mlockall

elServer="10.162.159.24:9200"
curl -XGET "${elServer}/_nodes?filter_path=**.mlockall"

如果你看到mlockall=false,那就意味著mlockall請求失敗了。
你還可以在logs中搜索 “Unable to lock JVM Memory” 來獲得更詳細(xì)的信息。
如果你看到mlockall=false,那就意味著mlockall請求失敗了。
你還可以在logs中搜索 “Unable to lock JVM Memory” 來獲得更詳細(xì)的信息。

要使這個(gè)設(shè)置生效,需要先配置其他的系統(tǒng)設(shè)置。
一般來說,最可能的原因是運(yùn)行elasticsearch的用戶沒有權(quán)限來lock memory,這可以通過如下方式解決:
(a) tar包方式安裝的: 在運(yùn)行elasticsearch之前使用root用戶設(shè)置 ulimit -l unlimited ,或在 /etc/security/limits.conf 中設(shè)置 memlock=unlimited。( elasticsearch - memlock unlimited )
(b) rpm包安裝于使用systemd 的系統(tǒng)的: 在環(huán)境變量配置文件中設(shè)置 LimitMEMLOCK=infinity

另一個(gè)可能的原因是臨時(shí)文件目錄/tmp被掛載為 noexec 。
這可以通過指定一個(gè)新的臨時(shí)文件夾來解決,通過設(shè)置 ES_JAVA_OPTS,如下所示

export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"

或在 jvm.options配置文件中設(shè)置JVM flag。

可選的方法還有 徹底禁用swap 和 設(shè)置 vm.swappiness=1 。 見后面的詳述

  • network.host: 默認(rèn)時(shí),elasticsearch只綁定loopback地址,例如 127.0.0.1 and [::1]。在生產(chǎn)環(huán)境中,為了和其他nodes通信并組成一個(gè)集群,你的node需要綁定到一個(gè)non-loopback地址。雖然有很多關(guān)于network的設(shè)置,但是一般你只需要設(shè)置 network.host (在 /etc/security/limits.conf 中設(shè)置):
network.host: 192.168.1.10 ,127.0.0.1
  • discovery.zen.ping.unicast.hosts: elasticsearch會綁定到可用的loopback 地址,并且掃描9300到9305,嘗試連接到同一個(gè)server上的其他nodes。
    這提供了一種自動(dòng)集群的體驗(yàn),而不用額外的配置。
    但是當(dāng)真的集群來臨時(shí),你需要提供集群中一組其他種子節(jié)點(diǎn)(這些節(jié)點(diǎn)可能是live且可連接的),如下所示:(在 /etc/security/limits.conf 中設(shè)置)
discovery.zen.ping.unicast.hosts:
192.168.1.10:9300
#默認(rèn)使用 transport.profiles.default.port,并且失敗后使用 transport.tcp.port 
192.168.1.11
#會解析成IP地址
- seeds.mydomain.com

上面的數(shù)據(jù)格式在命令行怎么寫?
discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"]

  • discovery.zen.minimum_master_nodes : 為了放棄數(shù)據(jù)丟失,這個(gè)參數(shù)極其重要。
    在 /etc/security/limits.conf 中設(shè)置

    discovery.zen.minimum_master_nodes: 2 #集群master節(jié)點(diǎn)數(shù)量/2+1
    
    

4.2 啟動(dòng)檢查

我們有許多關(guān)于用戶忍受不可預(yù)期的問題的體驗(yàn),因?yàn)樗麄儧]有配置上述重要的設(shè)置。
這些Bootstrap檢查會檢閱elasticsearch和操作系的設(shè)置,并看看是否安全。
如果elasticsearch是在開發(fā)模式,Bootstrap檢查只會warning 于log中。
如果是在生產(chǎn)模式下,任何的Bootstrap檢查都會導(dǎo)致啟動(dòng)fail。

heap size check:

如果JVM啟動(dòng)時(shí),initial和max heap size不一致,在JVM heap被resized時(shí)可能會導(dǎo)致暫停。
要通過heap size check,你必須配置heap size。
在 config/jvm.options中設(shè)置

-Xms2g
-Xmx2g

一般這個(gè)值有兩個(gè)原則,

  • (a)不要超過物理內(nèi)存的50%
  • (b)不要超過26G
file descriptor check:

打開文件數(shù)量的檢查,elasticsearch需要很多的file descriptor。
要通過檢查,你必須配置 file descriptor ,確保將其設(shè)置為至少65536。

  • 如果是用tar包的安裝方式:
    先通過使用root用戶 ulimit -n 65536 然后啟動(dòng)elasticsearch。
    或者 通過 /etc/security/limits.conf 文件設(shè)置 nofile 為65536。

    elasticsearch - nofile 65536 
    
    
  • RPM包安裝方式的默認(rèn)設(shè)置已經(jīng)是65536。

你可以通過如下API檢查 max_file_descriptors 配置

GET _nodes/stats/process?filter_path=**.max_file_descriptors
curl -XGET "${elServer}/_nodes/stats/process?filter_path=**.max_file_descriptors"

memory lock check:

在 config/elasticsearch.yml 中設(shè)置

bootstrap.memory_lock: true

要查看該設(shè)置是否生效,通過如下的API請求,然后檢查返回內(nèi)容中的mlockall的值

GET _nodes?filter_path=**.mlockall
elServer="10.162.159.24:9200"
curl -XGET "${elServer}/_nodes?filter_path=**.mlockall"

如果你看到mlockall=false,那就意味著mlockall請求失敗了。
你還可以在logs中搜索 “Unable to lock JVM Memory” 來獲得更詳細(xì)的信息。

要使這個(gè)設(shè)置生效,需要先配置其他的系統(tǒng)設(shè)置。
一般來說,最可能的原因是運(yùn)行elasticsearch的用戶沒有權(quán)限來lock memory,這可以通過如下方式解決:

  • tar包方式安裝的:
    在運(yùn)行elasticsearch之前使用root用戶設(shè)置 ulimit -l unlimited ,
    或在 /etc/security/limits.conf 中設(shè)置 memlock=unlimited。

    elasticsearch - memlock unlimited
    
    
  • rpm包安裝于使用systemd 的系統(tǒng)的:
    在環(huán)境變量配置文件中設(shè)置 LimitMEMLOCK=infinity

另一個(gè)可能的原因是臨時(shí)文件目錄/tmp被掛載為 noexec 。
這可以通過指定一個(gè)新的臨時(shí)文件夾來解決,通過設(shè)置 ES_JAVA_OPTS,如下所示

export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"

或在jvm.options配置文件中設(shè)置JVM flag。

maximum number of threads check:

elasticsearch執(zhí)行是通過將查詢分解成不同的階段,然后在不同的階段使用不同的thread pool Executors。
所以elasticsearch需要大量的線程。
你必須至少讓elasticsearch能創(chuàng)建2048個(gè)線程。
這可以通過 /etc/security/limits.conf 的 nproc 設(shè)置來做到。

elasticsearch - nproc 2048

maximum size virtual memory check:

elasticsearch和Lucene使用 mmap 來增強(qiáng)影響map index到elasticsearch的地址空間。
這會保持特定的index data off the JVM heap但是在內(nèi)存中來燃燒快速的access。
要使它生效,elasticsearch需要擁有unlimited address space。
maximum size virtual memory check強(qiáng)制elasticsearch進(jìn)程擁有unlimited地址空間。
要通過這個(gè)檢查,你必須配置你的系統(tǒng)允許elasticsearch進(jìn)程用擁有unlimited地址空間的能力。
這可以通過 /etc/security/limits.conf 的 as = unlimited 來做到。

elasticsearch - as unlimited

maximum map count check:

和上面一個(gè)設(shè)置一樣,使用 mmap,elasticsearch還要求有創(chuàng)建很多內(nèi)存map區(qū)域的能力。
maximum map count check檢查內(nèi)核允許一個(gè)進(jìn)程至少有 262144個(gè)memory內(nèi)存區(qū)域。
要通過這個(gè)檢查,你必須配置 sysctl vm.max_map_count >= 262144

client JVM check:

OpenJDK-derived JVMs提供了兩種不同的JVMs:client JVM 和 server JVM。
這些JVMs使用不同的compilers來從Java bytecode產(chǎn)生不同的可執(zhí)行maching code。
client JVM 被調(diào)優(yōu)于啟動(dòng)速度和內(nèi)存占用,server JVM 被調(diào)優(yōu)于 性能最大化。
性能是兩種JVM的本質(zhì)區(qū)別。
client JVM check保證了elasticsearch沒有運(yùn)行于client JVM。
要通過這個(gè)檢查,你必須使用server VM來啟動(dòng)elasticsearch。
在現(xiàn)代的操作系統(tǒng)中,使用server VM是默認(rèn)選項(xiàng)。
另外,elasticsearch默認(rèn)被配置為強(qiáng)制使用server VM。
在 jvm.options 中默認(rèn)有 -server 選項(xiàng)。

use serial collector check:

openjdk-derived JVMs有很多種垃圾收集器,用于不同的workloads。
serial collector 非常適用于 single logical CPU 機(jī)器 或 非常小的heaps,但這些都不適用于elasticsearch。
使用這種collector會極大地破壞elasticsearch的性能。
要通過這個(gè)檢查,你必須不能使用這種collector,默認(rèn)情況下,JVM配置為使用CMS collector。
在 jvm.options 中默認(rèn)有 -XX:+UseConcMarkSweepGC 選項(xiàng)。

system call filter check:

elasticsearch根據(jù)不同的操作系統(tǒng)安裝不同風(fēng)格的system call filters,例如在linux上是seccomp。
這些system call filters被安裝,是用于阻止執(zhí)行system calls來forking的防御機(jī)制,防御任意代碼執(zhí)行于elasticsearch之上。
system call filter check保證了如果system call filter被啟用了,它們被成功安裝。
要通過這個(gè)檢查,你必須修復(fù)那些任何阻止system call filter被安裝的Configuration errors(通過檢查logs),或者禁用system call filters(自負(fù)風(fēng)險(xiǎn)),通過在 /etc/security/limits.conf 中設(shè)置

bootstrap.system_call_filter: false

OnError and OnOutOfMemoryError checks:

JVM的選項(xiàng) OnError 和 OnOutOfMemoryError 使得 如果 JVM遭遇了一個(gè)fatal error(OnError)或一個(gè)OutOfMemoryError(OnOutOfMemoryError)時(shí)可以執(zhí)行任意代碼。
但是默認(rèn)情況下,elasticsearch的system call filter(seccomp)是啟用的,并且這些filters會阻止forking。
因此,使用OnError或OnOutOfMemoryError和system call filters是矛盾的。
這個(gè)檢查阻止elasticsearch啟動(dòng),如果system call filter被啟用的同時(shí)這兩個(gè)選項(xiàng)也開啟。
這個(gè)check總是強(qiáng)制的。要通過這個(gè)檢查,就不要啟用OnError或OnOutOfMemoryError

替代方案是升級到Java 8u92然后使用 ExitOnOutOfMemoryError

G1GC check:

JDK8提供的早期版本的HotSpot JVM 已知確認(rèn)有問題,當(dāng)G1GC collector被啟用時(shí)會導(dǎo)致 index corruption 。
G1GC check會檢測這些早期版本的HotSpot JVM。

4.3 重要的操作系統(tǒng)配置

(1) 理想狀態(tài)下,elasticsearch應(yīng)該霸占整個(gè)server。

要達(dá)到這個(gè)目的,你應(yīng)該配置elasticsearch盡可能多地使用操作系統(tǒng)的資源。

(2) 默認(rèn)情況下,elasticsearch假設(shè)你工作于開發(fā)模式下,這些重要的配置只是會記錄為log中的warning。

當(dāng)你設(shè)置了類似 network.host的配置項(xiàng)之后,elasticsearch會假設(shè)你已經(jīng)在生產(chǎn)環(huán)境下,并且會將warning升級為Exception。
這會導(dǎo)致elasticsearch啟動(dòng)失敗。

(3) 在哪里配置操作系統(tǒng)設(shè)置基于你的安裝方式和你使用的操作系統(tǒng)。

  • 如果你是通過tar包安裝的,system settings可以通過如下方式配置:
    (a) 通過 ulimit 進(jìn)行臨時(shí)配置
    (b) 通過 /etc/security/limits.conf 進(jìn)行永久配置

  • 如果你是通過systemd方式安裝,則可以通過systemd配置文件來設(shè)置。

使用ulimit設(shè)置:

(必須使用root,而且limit的設(shè)置只應(yīng)用于當(dāng)前session)

sudo su
ulimit -n 65536
su elasticsearch

通過 /etc/security/limits.conf 設(shè)置:

(可以為特定用戶永久設(shè)置),在這個(gè)文件中增加:

elasticsearch - nofile 65536

通過 /etc/sysconfig/elasticsearch 文件設(shè)置:

當(dāng)使用RPM包安裝時(shí),可以通過這個(gè)文件進(jìn)行設(shè)置環(huán)境變量和system settings。

通過 systemd Configuration 設(shè)置:

當(dāng)使用RPM包安裝于使用systemd的系統(tǒng)時(shí),limits必須通過systemd配置。
systemd的服務(wù)文件 /usr/lib/systemd/system/elasticsearch.service 包含了默認(rèn)的配置。
要覆蓋這個(gè)默認(rèn)配置,可以增加一個(gè)文件于 /etc/systemd/system/elasticsearch.service.d/elasticsearch.conf 并配置一些更改,例如:

[Service]
LimitMEMLOCK=infinity

設(shè)置JVM選項(xiàng):

設(shè)置JVM選項(xiàng)(包括系統(tǒng)屬性和JVM選項(xiàng))的推薦方法是通過 jvm.options 配置文件。
該文件默認(rèn)位置為 config/jvm.options。
這個(gè)文件的每一行都必須是以 - 開頭,你可以在其中增加自己的JVM選項(xiàng)。
另一種方式是通過 ES_JAVA_OPTS 環(huán)境變量,例如:

export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"

這個(gè)環(huán)境變量可以在 /etc/sysconfig/elasticsearch 中指定。

設(shè)置 JVM heap size:

默認(rèn)情況下,elasticsearch告訴JVM使用最小heap size和最大heap size為2GB。
當(dāng)在生產(chǎn)環(huán)境中時(shí),需要增加這個(gè)值。
在 jvm.options 中通過 -Xms 和 -Xmx 來設(shè)置這個(gè)值。
這個(gè)值的大小取決于 可用內(nèi)存的大小。好的規(guī)則如下:

  • (a) 將 Xms 和 Xmx 設(shè)置成一樣的值

  • (b) 越多的heap設(shè)置,elasticsearch就能緩存更多的數(shù)據(jù)。
    但是注意太大的heap會導(dǎo)致你長時(shí)間的垃圾回收中斷。

  • (c) 設(shè)置Xmx不要超過你的物理內(nèi)存的50%,要為內(nèi)核文件系統(tǒng)留有足夠的內(nèi)存。

  • (d) 不要設(shè)置Xmx 超過JVM 用于 壓縮 object pointers的臨界點(diǎn),這個(gè)臨界點(diǎn)大約為32GB。你可以通過查看日志中的一行(如下所示)來驗(yàn)證它:
    heap size [1.9gb], compressed ordinary object pointers [true]

  • (e) 最好是嘗試停留在below the threshold for zero-based compressed oops;精確的臨界值是變化的,但是26GB一般而言是安全的,但是在有些系統(tǒng)上可以達(dá)到30GB。你可以驗(yàn)證它,通過使用JVM選項(xiàng) -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode 啟動(dòng)elasticsearch,并查找像下面的行:
    heap address: 0x000000011be00000, size: 27648 MB, zero based Compressed Oops
    這顯示了 zero-based compressed oops are enabled,而不是
    heap address: 0x0000000118400000, size: 28672 MB, Compressed Oops with base: 0x00000001183ff000

還可以通過環(huán)境變量配置JAVA 選項(xiàng):

ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch 
ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch 

(5) 禁用swapping :

大部分操作系統(tǒng)都嘗試使用盡可能多的文件系統(tǒng)緩存并急切地swap out未使用的應(yīng)用程序緩存。
這會導(dǎo)致JVM heap被swapped out to disk。
swapping對于性能和node的穩(wěn)定性來說是很壞的,應(yīng)該盡可能阻止它發(fā)生。
它會導(dǎo)致垃圾回收達(dá)數(shù)分鐘而不是毫秒級別。

啟用 bootstrap.memory_lock :

第一個(gè)選項(xiàng)是使用 mlockall 來嘗試lock進(jìn)程地址到RAM中,阻止任何的elasticsearch 內(nèi)存被swapped out。
在配置文件中設(shè)置:

bootstrap.memory_lock: true

注意:mlockall可能會導(dǎo)致JVM或shell session退出,如果它嘗試分配了超過了可用的內(nèi)存!
在elasticsearch啟動(dòng)后你可以看到這個(gè)配置是否生效了,通過

GET _nodes?filter_path=**.mlockall
elServer="10.162.159.24:9200"
curl -XGET "${elServer}/_nodes?filter_path=**.mlockall"

如果你看到 mlockall=false,那就意味著mlockall請求失敗了。你還會在logs中看到一行更詳細(xì)的信息

Unable to lock JVM Memory.

一般來說,最可能的原因是運(yùn)行elasticsearch的用戶沒有權(quán)限來lock memory,這可以通過如下方式解決:

  • (1) tar包方式安裝的:
    在運(yùn)行elasticsearch之前使用root用戶設(shè)置 ulimit -l unlimited ,或在 /etc/security/limits.conf 中設(shè)置 memlock=unlimited。

    elasticsearch - memlock unlimited
    
    
  • (2) rpm包安裝于使用systemd系統(tǒng)的:
    在環(huán)境變量配置文件中設(shè)置 LimitMEMLOCK=infinity

另一個(gè)可能的原因是臨時(shí)文件目錄/tmp被掛載為 noexec 。
這可以通過指定一個(gè)新的臨時(shí)文件夾來解決,通過設(shè)置 ES_JAVA_OPTS,如下所示

export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"

或在jvm.options配置文件中設(shè)置JVM flag。

第二個(gè)選項(xiàng)是徹底禁用swap
一般來說elasticsearch獨(dú)立運(yùn)行于一個(gè)box中,并且它的Memory usage通過JVM選項(xiàng)操縱。
那就不需要啟用swapped。
在linux操作系統(tǒng)中,你可以通過如下命令來來禁用它:

sudo swapoff -a

要永久禁用,就編輯 /etc/fstab 并注釋任何包含swap的行。

另一個(gè)選項(xiàng)是設(shè)置 vm.swappiness=1 。

這不會影響整個(gè)操作系統(tǒng)在緊急情況下的swap。

File Descriptors :

elasticsearch需要使用大量的文件描述符,如果用超了,會是災(zāi)難性的并很可能導(dǎo)致數(shù)據(jù)丟失。
確保將其設(shè)置為至少65536。

  • 如果是用tar包的安裝方式:
    先通過使用root用戶 ulimit -n 65536 然后啟動(dòng)elasticsearch。
    或者 通過 /etc/security/limits.conf 文件設(shè)置 nofile 為65536。

    elasticsearch - nofile 65536
    
    
  • RPM包安裝方式的默認(rèn)設(shè)置已經(jīng)是65536。

你可以通過如下API檢查 max_file_descriptors 配置

GET _nodes/stats/process?filter_path=**.max_file_descriptors
elServer="10.162.159.24:9200"
curl -XGET "${elServer}/_nodes/stats/process?filter_path=**.max_file_descriptors"

Virutal memory:

elasticsearch默認(rèn)使用 hybrid mmapfs / niofs 文件夾存儲它的indices。
操作系統(tǒng)默認(rèn)的mmap counts limits一般都太小了,可能會導(dǎo)致內(nèi)存溢出。

你可以使用root執(zhí)行下面的命令來增加這個(gè)limits:

sysctl -w vm.max_map_count=262144

要永久設(shè)置,就更新 /etc/sysctl.conf 中的 vm.max_map_count 設(shè)置。
RPM包安裝方式會自動(dòng)設(shè)置,不需要額外的配置。

number of threads:

elasticsearch使用很多的thread pools來執(zhí)行不同類型的操作。
要確保elasticsearch至少可以創(chuàng)建2048個(gè)線程。
可以通過使用root用戶執(zhí)行 ulimit -u 2048 來臨時(shí)設(shè)置,或通過 /etc/security/limits.conf 設(shè)置 nproc=2048來永久設(shè)置。

elasticsearch - nproc 2048

2.6 升級 elasticsearch

https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html

2.7 停止elasticsearch

  • (1) 一個(gè)常規(guī)的shutdown可以讓elasticsearch有機(jī)會cleanup并close outstanding resources。例如一個(gè)node會將其自身從cluster中移除,sync translogs到磁盤上,執(zhí)行其他的相關(guān)cleanup activities。
  • (2) 如果你使用service的方式運(yùn)行elasticsearch,你可以通過systemctl stop的方式
  • (3) 如果你使用直接運(yùn)行的方式運(yùn)行elasticsearch,你可以通過Ctrl+C或發(fā)送SIGTERM信號。
  • (4) 在elasticsearch VM的生命周期內(nèi),可能會發(fā)生fatal errors,這會導(dǎo)致VM處于一個(gè)有問題的狀態(tài)。這些erros包括內(nèi)存溢出、VM的內(nèi)部錯(cuò)誤、嚴(yán)重的I/O錯(cuò)誤。

當(dāng)elasticsearch檢測到VM遇到這樣的錯(cuò)誤時(shí),它會嘗試log error并halt VM。
當(dāng)elasticsearch開始了這樣的一個(gè)shutdown,它不會饞鬼的shutdown,其進(jìn)程也會返回一個(gè)特定的狀態(tài)碼來指示發(fā)生了什么錯(cuò)誤。

3. API 約定

elasticsearch REST APIs使用HTTP返回JSON數(shù)據(jù)。

3.1 Multiple Indices:

所有的index參數(shù)都支持多個(gè),可以簡單的 test1,test2,...,_all表示所有Indices,
支持通配符,test* 或 test 或 tet 或 test ,
還支持 + 和 -,例如 +test* , -test3 。

3.2 date math support in index names:

例子: index的名稱使用了date math

GET /<logstash-{now/d}>/_search
GET /%3Clogstash-%7Bnow%2Fd%7D%3E/_search
elServer="10.162.159.24:9200"
curl -XGET "${elServer}/%3Clogstash-%7Bnow%2Fd%7D%3E/_search" -H 'Content-Type: application/json' -d'
      {
        "query" : {
          "match": {
            "test": "data"
          }
        }
      }

注意 < > 需要urlcode

格式為 <static_name{date_math_expr{date_format|time_zone}}>

3.3 通用選項(xiàng)

  • (1) ?pretty=true 表示返回的JSON有縮進(jìn),只在debugging時(shí)使用它!

  • (2) Date math

  • (3) response filtering: filter_path, 例子:

    GET /_search?q=elasticsearch&filter_path=took,hits.hits._id,hits.hits._score
    elServer="10.162.159.24:9200"
    curl -XGET "${elServer}/_search?q=elasticsearch&filter_path=took,hits.hits._id,hits.hits._score"
    
    
  • (4) flat settings: 當(dāng)其設(shè)置為true時(shí),返回的是flat格式的數(shù)據(jù)。

  • (5) Parameters: false是指 false、0、no、off 。其他的值都是 true。
    時(shí)間單位:2d = days h=hours m=minutes micros=microseconds nanos=nanoseconds
    byte size units:b=Bytes kb mb gb tb pb
    沒有單位的quantities:k m g t p
    長度單位: mi或miles、yd或yards、ft或feet、in或inch、km或kilometers、m或meters、cm或centimiters、mm或millimeters、NM或nmi或nauticalmiles(海里)
    Fuzziness(模糊不清的):0,1,2=匹配任意一個(gè) 0..2 、3..5 、 >5
    啟用Stack traces:默認(rèn)情況下,當(dāng)一個(gè)請求返回錯(cuò)誤時(shí),elasticsearch不包含stacktrace。你可以啟用它,通過設(shè)置 error_trace=true。

  • Request body In query string: 對于一些非POST請求不接受Request body的庫來說,你可以通過將Request body作為source的參數(shù)來代替。

3.4 URL-based access control:

  • (1) 很多用戶使用with URL-based access control的代理來安全訪問到elasticsearch indices。

  • (2) 對于 multi-search、multi-get和bulk請求,用戶可以在URL中選擇指定一個(gè)index,和在每個(gè)individual Request的Request body中。這會導(dǎo)致URL-based access control面臨挑戰(zhàn)。

  • (3) 要阻止用戶覆蓋URL中已經(jīng)指定的index,可以在 config.yml 中設(shè)置

    rest.action.multi.allow_explicit_index: false
    
    

    這個(gè)值默認(rèn)是true。當(dāng)設(shè)置為false時(shí),elasticsearch會拒絕這樣的請求,
    什么樣的請求?就是在Request body中顯式指定了index 的請求。

4. Modules

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules.html

這個(gè)章節(jié)包含各個(gè)modules,它們負(fù)責(zé)elasticsearch功能的各個(gè)方面。
每個(gè)module都可能包含靜態(tài)配置(在每個(gè)node上通過 elasticsearch.yml 文件配置)和動(dòng)態(tài)配置(通過 Cluster APIs中的cluster-update-settings 進(jìn)行動(dòng)態(tài)配置)。

這個(gè)章節(jié)包含的模塊有:

4.1 Cluster-level routing and shard allocation

(控制 where、when、how shards被分配到nodes上) :
master的一個(gè)主要職能就是決定哪些shards被分配到哪些nodes上,和什么時(shí)候在nodes之間移動(dòng)shards以達(dá)到rebalance集群。

4.1.1 Cluster level shard Allocation:

shard Allocation是分配shards到nodes上的過程。
這可以發(fā)生在 initial recovery時(shí)、replica Allocation時(shí)、rebalancing時(shí)、或當(dāng)nodes被增加或移除時(shí)。
這部分設(shè)置主要是動(dòng)態(tài)設(shè)置,關(guān)于shard Allocation settings、shard rebalancing settings、shard balancing heuristics(啟發(fā)法)。

4.1.2 Disk-based Shard Allocation:

elasticsearch在決定是否分配新的shards到那個(gè)節(jié)點(diǎn)之前,或?qū)hards從那個(gè)節(jié)點(diǎn)重新分配到別處之前,會將可用的磁盤空間作為考慮的因素。 這部分設(shè)置可以是靜態(tài)配置,也可以動(dòng)態(tài)更改(使用cluster-update-settings API)。

4.1.3 Shard Allocation Awareness:

當(dāng)在同一個(gè)物理主機(jī)上運(yùn)行多個(gè)VMs時(shí),或在多個(gè)機(jī)架上運(yùn)行、或在多個(gè)可awareness的zones上運(yùn)行時(shí),很有可能同一臺server上、同一個(gè)機(jī)架上、或同一個(gè)zone上會同時(shí)發(fā)生crash。
如果elasticsearch可以識別你的硬件的物理配置,它就可以確保primary shards和它的replica shards分開存放。
這部分設(shè)置可以是靜態(tài)配置,也可以動(dòng)態(tài)更改(使用cluster-update-settings API)。

4.1.4 Shard Allocation Filtering:

雖然 Index Shard Allocation APIs提供了per-index級別的設(shè)置來控制shards到nodes的Allocation,cluster-level shard Allocation Filtering還能允許你允許或禁止任意index的shards到特定nodes的Allocation。
經(jīng)典使用案例是當(dāng)你想decommission(使退役) 一個(gè)節(jié)點(diǎn)時(shí),并且你想將shards從那個(gè)節(jié)點(diǎn)移到其他節(jié)點(diǎn)。
使用動(dòng)態(tài) APIs 設(shè)置

4.1.5 Miscellaneous(混雜的) cluster settings:

包括Metadata、index tombstones(墓碑)、Logger的設(shè)置。

4.2 Discovery

(nodes如何彼此發(fā)現(xiàn)來組成集群) :
負(fù)責(zé)發(fā)現(xiàn)集群中的節(jié)點(diǎn),并選舉master node。
注意,elasticsearch是一個(gè)基于點(diǎn)到點(diǎn)的系統(tǒng),nodes之間直接互相通信。
所有的main APIs(index、delete、search)并不和master節(jié)點(diǎn)通信。
master節(jié)點(diǎn)的職責(zé)是維護(hù)整個(gè)cluster的狀態(tài),還有當(dāng)節(jié)點(diǎn)加入或離開集群時(shí)重新分配shards。
集群的狀態(tài)發(fā)生更改時(shí),集群的狀態(tài)會通知到集群中其他節(jié)點(diǎn)(傳播方式基于實(shí)際的Discovery實(shí)現(xiàn)方式)。
Zen Discovery是elasticsearch內(nèi)置的Discovery module,也是默認(rèn)值。
Zen Discovery和其他module集成在一起使用,例如,節(jié)點(diǎn)之間所有的通信使用transport module完成。
它被分成了幾個(gè)子modules,包括ping、unicast、master election、fault detection、cluster state updates、no master block

4.3 Gateway

(在recovery可以開始之前需要多少nodes加入到集群中):
Local gateway module存儲在整個(gè)集群重啟時(shí)的集群狀態(tài)和shards data。
這部分設(shè)置主要是靜態(tài)配置,必須配置好于master node

4.4 HTTP

(控制HTTP REST Interface的設(shè)置):
http module允許你通過HTTP暴露elasticsearch APIs。
這部分配置通過 elasticsearch.yml 配置。
包括

  • http.port :(默認(rèn)是9200-9300)、會綁定第一個(gè)可用的端口。
  • http.publish_port : HTTP客戶端用來跟node通信的端口。用于當(dāng)節(jié)點(diǎn)位于proxy或防火墻后面,并且 http.port 不能直接從外面訪問。默認(rèn)值和通過 http.port 的設(shè)置值相同。
  • http.bind_host: 默認(rèn)值同 http.host 或 network.bind_host
  • http.publish_host: 默認(rèn)值同 http.host 或 network.bind_host
  • http.host : 用于設(shè)置 http.bind_host 和 http.publish_host 。默認(rèn)值同 network.host
  • ...

還可以禁用HTTP, ( http.enabled=false )。
elasticsearch節(jié)點(diǎn)(還有Java clients)之間的內(nèi)部通信使用 transport interface通信,不是HTTP。所以在那些不準(zhǔn)備提供HTTP APIs的節(jié)點(diǎn)上禁用HTTP APIs也是有用的。

4.5 Indices

(全局的index相關(guān)的設(shè)置):
indices module控制index相關(guān)的設(shè)置,這些設(shè)置全局管理所有的indices,而不是per-index級別。
可用的設(shè)置包括:

  • Circuit breaker: 設(shè)置內(nèi)存使用的限制來避免內(nèi)存溢出。
  • Fielddata cache:設(shè)置用于fielddata cache的in-memory的heap的使用量限制。
  • node query cache:
  • indexing buffer:
  • shard request cache:
  • recovery:

4.6 Network

(默認(rèn)的network設(shè)置) :
elasticsearch默認(rèn)只綁定到localhost。
常用的network設(shè)置有:

  • network.host : 節(jié)點(diǎn)會綁定到這個(gè)hostname或IP地址,并發(fā)布這個(gè)host給其他節(jié)點(diǎn)。默認(rèn)是 local ,其他可選的還有 [networkInterface] 、 site 、 global ,分別表示特定網(wǎng)卡節(jié)點(diǎn)綁定的IP地址、site-local地址(例如 192.168.0.1)、全局地址(例如8.8.8.8)
  • discovery.zen.ping.unicast.hosts : 為了加入集群,節(jié)點(diǎn)需要知道集群中其他一些節(jié)點(diǎn)的IP地址。
  • http.port :
  • transport.tcp.port : 綁定的用于節(jié)點(diǎn)之間通信使用的端口。默認(rèn)是9300-9400。
  • ...

4.7 Node client

(加入到集群但是不扮演master node的角色) :
集群中的每個(gè)節(jié)點(diǎn)默認(rèn)都可以處理HTTP和transport traffic。
transport layer只用于節(jié)點(diǎn)(還有Java TransportClient)之間的通信;
HTTP layer只用于外部REST client的訪問。
集群中的所有節(jié)點(diǎn)都知道其他所有的節(jié)點(diǎn),并轉(zhuǎn)發(fā)client請求到相應(yīng)的節(jié)點(diǎn),每個(gè)節(jié)點(diǎn)都服務(wù)于一個(gè)或多個(gè)用途:

  • master-eligible node: 設(shè)置 node.master:true ,也是默認(rèn)值,這使得節(jié)點(diǎn)有資格被選舉為master node,master node控制集群。
  • data node:設(shè)置 node.data:true ,也是默認(rèn)值,data節(jié)點(diǎn)持有數(shù)據(jù)并執(zhí)行數(shù)據(jù)相關(guān)的操作,例如CRUD、search和Aggregations。
  • ingest(攝取,吸收) node :設(shè)置 node.ingest:true ,也是默認(rèn)值。ingest node可以應(yīng)用一個(gè) ingest pipeline到一個(gè)document,以便在index它之前轉(zhuǎn)換并充實(shí)該document。這個(gè)工作很重,所以使用專門的ingest node,并且在master node和data node上設(shè)置 ingest.node:false
  • tribe node: 通過設(shè)置 tribe.* 相關(guān)設(shè)置,這些設(shè)置可以讓節(jié)點(diǎn)可以連接多個(gè)集群并可以跨集群 執(zhí)行search和其他操作 。

默認(rèn)情況下,節(jié)點(diǎn)是 master-eligible和data node,而且可以當(dāng)作 ingest node(雖然不建議)。
隨著集群的增長,建議master node和data node也分開。

4.8 Painless

(elasticsearch使用的內(nèi)置的腳本語言,被設(shè)計(jì)為讓elasticsearch盡可能地安全)

4.9 Plugins

(使用擴(kuò)展的插件) :

4.10 Scripting

(使用Lucene表達(dá)式、Groovy、Python、Javascript的自定義的腳本。你也可以使用內(nèi)置的腳本語言Painless來編寫腳本) : https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html

scripting module讓你能夠使用腳本來evaluate自定義的表達(dá)式。
例如,你可以使用腳本來返回一個(gè)“script fields”作為搜索請求的一部分。
默認(rèn)的腳本語言是 Painless。
額外的 lang 插件讓你能夠運(yùn)行其他語言的腳本。
一般用途的語言有 painless、groovy、javascript、python,特定用途的語言(不靈活,但對特定任務(wù)有很好的性能)有 expression、mustache、java。

如何使用?

"script":{"lang":"...","inline"|"sorted"|"filter":"...","params":{ ... } }

4.11 Snapshot/Restore

(使用 snapshot/restore 備份你的data) :
snapshot and restore module 允許你創(chuàng)建單獨(dú)Indices或整個(gè)集群的snapshots到一個(gè)遠(yuǎn)端repository,像共享文件系統(tǒng)、S3、HDFS。
這些snapshots不是檔案文件,因?yàn)樗鼈冎荒鼙豢梢宰R別index的elasticsearch版本恢復(fù)。
這意味著 在2.x版本創(chuàng)建的snapshots可以被恢復(fù)到5.x,在1.x版本創(chuàng)建的snapshots可以被恢復(fù)到2.x,但是1.x版本創(chuàng)建的snapshots不能被恢復(fù)到5.x。

  • 在snapshot或restore操作之前,你必須先注冊一個(gè)snapshot repository到elasticsearch中。通過一個(gè)HTTP API
  • 一個(gè)repository可以包含同一個(gè)集群的多個(gè)snapshots。snapshots通過唯一的名稱標(biāo)識自己。

4.12 Thread pools

(elasticsearch使用的專用的thread pools的信息) :
一個(gè)節(jié)點(diǎn)持有幾個(gè)thread pools以達(dá)到改善threads的內(nèi)存消耗。
許多這樣的pools一般還有一個(gè)queues與它們關(guān)聯(lián),這些queues允許pending requests而不是丟棄他們。
一些重要的thread pools有:

  • generic :通用操作(例如 后臺的node recovery)使用。threadpool類型為scaling
  • index: index/delete操作使用。threadpool類型為fixed,其size是 # of available processors,queue size of 200.這個(gè)pool的最大size是 1 + # of available processors
  • search: count/search/suggest操作使用。threadpool類型為fixed,其size是 int((# of available_processors * 3) / 2) + 1, queue_size of 1000 。
  • get : get操作使用。threadpool類型為fixed,其size是 # of available processors, queue_size of 1000.
  • bulk : bulk操作使用。 threadpool類型為fixed,其size是 # of available processors, queue_size of 50 。這個(gè)pool的最大size是 1 + # of available processors
  • ...

4.13 Transport

(配置transport networking layer,用于Elasticsearch在內(nèi)部nodes之間通信用的使用) :
Transport機(jī)制是完全異步的,這意味著沒有任何一個(gè)thread會阻塞等待一個(gè)response。
這樣做的好處是首先解決了C10k problem,同時(shí)也是scatter(broadcast)/gather操作的理想解決方案,例如在elasticsearch中的search操作。

TCP Transport是Transport module的一個(gè)實(shí)現(xiàn)。它有如下設(shè)置:

transport.tcp.port : 默認(rèn)是 9300-9400
transport.host : 
...

4.14 Tribe nodes

(加入一個(gè)或多個(gè)clusters的tribe node,并扮演它們之間聯(lián)邦 client的角色) :
tribe node 會檢索其連接的所有集群的集群狀態(tài),并將它們合并成一個(gè)全局的集群狀態(tài)。
有了這些信息在手上,它能夠?qū)λ屑旱墓?jié)點(diǎn)執(zhí)行讀寫操作,就像它們在本地一樣。
要想讓一個(gè)節(jié)點(diǎn)稱為tribe node,只需要簡單的在 elasticsearch.yml 中配置:

tribe:
        t1: 
            cluster.name:   cluster_one
        t2: 
            cluster.name:   cluster_two 

t1和t2是任意的名稱,表示要連接到的集群。


5. Index Modules

https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html
Index Modules are modules created per index,并控制一個(gè)index相關(guān)的方方面面。
index level settings可以被設(shè)置為per-index??梢允莿?dòng)態(tài)設(shè)置,也可以靜態(tài)設(shè)置。


6. Ingest Node

https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html
ingest=提取

你可以使用ingest node在實(shí)際的indexing 發(fā)生之前 來預(yù)處理documents,這些預(yù)處理操作會攔截bulk和index請求,應(yīng)用transformations,然后將documents傳回給index或bulk APIs。

你可以讓任意的節(jié)點(diǎn)具有ingest功能,也可以設(shè)置專門的ingest node(推薦)。
ingest默認(rèn)是在所有節(jié)點(diǎn)上啟用的。
要禁用它就在 elasticsearch.yml 中設(shè)置:

node.ingest: false


7. How to

https://www.elastic.co/guide/en/elasticsearch/reference/current/how-to.html

7.1 常規(guī)推薦

  • 不要返回大的結(jié)果集:返回top documents是非常好的。如果你非要返回大的結(jié)果集,請使用Scroll API。
  • 避免大的documents: 默認(rèn)的 http.max_context_length=100MB ,elasticsearch會拒絕index超過這個(gè)值得documents。你可以決定增大這個(gè)值,但是Lucene仍然有最大值為大約2GB。
  • 避免sparsity(數(shù)據(jù)稀疏):在Lucene后面的數(shù)據(jù)結(jié)構(gòu),是elasticsearch為了index和存儲數(shù)據(jù)所依賴的,最好工作于抽魔的數(shù)據(jù),例如所有的documents都擁有相同的fields。
  • 避免在相同的index中存放不相關(guān)的數(shù)據(jù)
  • 標(biāo)準(zhǔn)化document structures
  • 避免types:types可能聽起來是一個(gè)不錯(cuò)的方式來存儲多個(gè)tenants到一個(gè)單獨(dú)的index中。但是它們不是:如果你的types不是有非常類似的mappings,你需要考慮將他們移動(dòng)到專用的index中
  • 禁用 norms 和 doc_values on sparse(稀疏的、缺少的) fields:如果上面的建議都不符合你的情況,你可能要檢查在你的sparse fields上你是否真的需要 norms 和 doc_values 。norms 可以被禁用,如果producing scores不是必須的,doc_values可以被禁用如果不使用sorting和Aggregations。注意不要輕易下這個(gè)決定,因?yàn)檫@些參數(shù)不能動(dòng)態(tài)更改,所以你需要reindex,如果你意識到你需要 norms 或 doc_values。

7.2 Recipes(食譜)

  • mixing exact search with stemming(詞干提取):
  • getting consistent scoring :
    (a) scores are not reproducible:
    (b) relevancy looks wrong:

7.3 調(diào)優(yōu) indexing speed

  • 使用bulk requests
  • 使用multiple workers/threads 來發(fā)送數(shù)據(jù)給elasticsearch:
  • 增加refresh間隔
  • 禁用refresh和replicas for initial loads
  • 禁用swapping
  • 為filesystem cache留出內(nèi)存
  • 使用auto-generated ids
  • 使用更快的hardware
  • indexing buffer size

7.4 調(diào)優(yōu) search speed

  • 為filesystem cache留出內(nèi)存
  • 使用更快的hardware
  • document 建模
  • Pre-index data
  • Mappings :一些數(shù)據(jù)是數(shù)字并不意味著它總是應(yīng)該被mapped as a numeric field。有時(shí)應(yīng)該被mapped as keyword 而不是integer 或 long。
  • avoid scripts:如果一定要使用,你應(yīng)該選擇 painless 和 expressions 引擎。
  • search rounded date: 在 日期類型的fields上的查詢使用 now 一般不能cacheable。然而使用一個(gè)rounded date經(jīng)常是可以接受的,并且可以使用緩存。
  • 強(qiáng)制合并 read-only indices:
  • warm up gloal ordinals:
  • warm up the filesystem cache

7.5 調(diào)優(yōu) disk usage

  • 禁用你不需要的features
  • 不要使用默認(rèn)的動(dòng)態(tài)string mappings
  • 禁用 _all
  • 使用 best_compression :
  • 使用smallest numeric type that is sufficient

作者:堅(jiān)持到底v2
鏈接:http://www.itdecent.cn/p/6a700cc61913

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容