1. 程式人生 > >Elasticsearch + Elasticsearch-head搭建

Elasticsearch + Elasticsearch-head搭建

Elasticsearch搭建:

[[email protected] elk]# tar -xvf elasticsearch-6.2.4.tar

[[email protected] elk]# cd elasticsearch-6.2.4

[[email protected] elasticsearch-6.2.4]# mkdir es-data

[[email protected] elk]# useradd elasticsearch

[[email protected] elk]# passwd elasticsearch

[[email protected]

elk]# chown -R elasticsearch:elasticsearch elasticsearch-6.2.4

[[email protected] config]# cd /home/software/elk/elasticsearch-6.2.4/config

[[email protected] config]# cp elasticsearch.yml  elasticsearch.yml_install

 

[[email protected] config]# vim elasticsearch.yml

 

cluster.name: the-test   #叢集名稱

node.attr.rack: elk-1     #節點名稱

path.data: /home/elk/elasticsearch-6.2.4/es-data   #data存放的路徑

path.logs: /home/elk/elasticsearch-6.2.4/logs       #logs存放的路徑

network.host: 0.0.0.0         #監聽的網路地址

http.port: 9200              #開啟監聽的埠

http.cors.enabled: true        #增加新的引數,這樣head外掛可以訪問es

http.cors.allow-origin: "*"       #增加新的引數,這樣head外掛可以訪問es

bootstrap.memory_lock: false     #配置記憶體使用用交換分割槽

bootstrap.system_call_filter: false

 

 

[[email protected] config]# vim jvm.options 

-Xms4g       #更改jvm啟動使用記憶體

-Xmx4g

 

[[email protected] elk]# vim /etc/security/limits.conf

* soft nofile 65536

* hard nofile 65536

 

[[email protected] home]# vim /etc/sysctl.conf

vm.max_map_count=655360

 

[[email protected] elasticsearch-6.2.4]# sysctl –p

 

此時要重新登入一下終端,要不然有的配置不會生效

 

[[email protected] elasticsearch-6.2.4]# rm -rf /home/software/elk/elasticsearch-6.2.4/logs/*

#刪除一下日誌,然後切換使用者啟動,避免日誌寫入許可權報錯

 

[[email protected] ~]# su – elasticsearch

[[email protected] ~]$ cd /home/software/elk/elasticsearch-6.2.4/

[[email protected] elasticsearch-6.2.4]$ bin/elasticsearch -d

Elasticsearch-head安裝:

 

[[email protected] elk]# wget https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz

[[email protected] elk]# tar -xvf node-v10.13.0-linux-x64.tar.xz

 

[[email protected] node-v10.13.0-linux-x64]# vim /etc/profile

#node

export PATH=$PATH:/home/software/elk/node-v10.13.0-linux-x64/bin

 

[[email protected] node-v10.13.0-linux-x64]# source /etc/profile

[[email protected] node-v10.13.0-linux-x64]# node -v

v10.13.0

[[email protected] node-v10.13.0-linux-x64]# npm -v

6.4.1

 

Elasticsearch-head搭建:

[[email protected] elasticsearch-6.2.4]# cd /home/software/elk/elasticsearch-6.2.4

[[email protected] elasticsearch-6.2.4]# git clone git://github.com/mobz/elasticsearch-head.git

 

[[email protected] elasticsearch-head]# npm install  

出現類似報錯:

npm ERR! [email protected] install: `node install.js`

 

[[email protected] elasticsearch-head]# npm cache clean --force

[[email protected] elasticsearch-head]# npm -g install  [email protected] --ignore-script

 

[[email protected] elasticsearch-head]# npm start &