簡介:
安裝 elasticsearch 版本是6.8.0 ,ubuntu環(huán)境
下載
到華為云鏡像
https://repo.huaweicloud.com/elasticsearch/6.8.10/elasticsearch-6.8.10.tar.gz
首先安裝java 環(huán)境
安裝es
tar zxf elasticsearch-6.8.0.tar.gz -C /opt/services/es
修改配置文件
vim /opt/services/es/elasticsearch/config/elasticsearch.yml
cluster.name: ESCluster #修改集群的名字,以免在網絡上混亂串門襟衰,加入別的集群里面勋锤。注釋會隨機生成集群名
node.name: node1 #自定義節(jié)點名字
path.data: /opt/services/es/elasticsearch/data #自定義節(jié)點名字
path.logs: /opt/services/es/elasticsearch/logs #自定義日志存儲路徑
bootstrap.memory_lock: true #鎖定內存嚼贡,防止用到 swap 分區(qū)
network.host: 0.0.0.0 #修改 ES 的監(jiān)聽地址沼瘫,這樣所有的機器都可以訪問這部 ES
http.port: 9200
discovery.zen.minimum_master_nodes: 1
bootstrap.system_call_filter: false
#添加新的配置項琅锻,允許跨域訪問酝蜒,這樣 head 插件方可對 ES 進行訪問
http.cors.enabled: true #開啟跨域訪問支持誊辉,默認為false
http.cors.allow-origin: "*" #跨域訪問允許的域名地址,使用正則表達式
vim /opt/services/es/elasticsearch/config/jvm.options
- 優(yōu)化內存大小亡脑,防止內存溢出導致進程奔潰堕澄,具體修改以下內容:
-Xms4g #默認為 1g
-Xmx4g #默認為 1g
修改系統(tǒng)的參數(shù)
vim /etc/security/limits.conf
- 添加
* soft nofile 100000
* hard nofile 100000
* soft nproc 100000
* hard nproc 100000
* soft memlock unlimited
* hard memlock unlimited
# 解決啟動報錯:
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
sudo vim /etc/sysctl.conf
fs.file-max = 1645037
vm.max_map_count = 655360
#即時生效:
sudo sysctl -p
#也可以重啟
啟動
cd es
./bin/elasticsearch -d
添加systemd 守護進程
# 添加 elasticsearch.service 到 /lib/systemd/system/
[Unit]
Description=elasticsearch-6.8.0
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment=JAVA_HOME=/opt/services/jdk
##為systmed 進程加文件限制數(shù)量
LimitCORE=infinity
LimitNOFILE=65536
LimitNPROC=65536
ExecStart=/opt/services/es/bin/elasticsearch -d
User=op
Group=op
[Install]
WantedBy=multi-user.target
方法二:
全局的配置,放在文件 /etc/systemd/system.conf 和 /etc/systemd/user.conf霉咨。 同時奈偏,也會加載兩個對應的目錄中的所有.conf文件 /etc/systemd/system.conf.d/.conf 和 /etc/systemd/user.conf.d/.conf
其中,system.conf 是系統(tǒng)實例使用的躯护,user.conf用戶實例使用的惊来。一般的sevice,使用system.conf中的配置即可棺滞。systemd.conf.d/*.conf中配置會覆蓋system.conf裁蚁。
DefaultLimitCORE=infinity
DefaultLimitNOFILE=100000
DefaultLimitNPROC=100000