Elasticsearch CentOS6.5下安裝ElasticSearch6.2.4+elasticsearch-head+Kibana

CentOS6.5下安裝ElasticSearch6.2.4
(1)配置JDK環境html

配置環境變量

export JAVA_HOME="/opt/jdk1.8.0_144"java

export PATH="$JAVA_HOME/bin:$PATH"node

export CLASSPATH=".:$JAVA_HOME/lib"git

(2)安裝ElasticSearch6.2.4github

下載地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-2-4npm

啓動報錯:
bootstrap

 

解決方式:vim


bin/elasticsearch -Des.insecure.allow.root=true跨域


 

或者修改bin/elasticsearch,加上ES_JAVA_OPTS屬性:數組

 


ES_JAVA_OPTS="-Des.insecure.allow.root=true"


 

再次啓動:

這是出於系統安全考慮設置的條件。因爲ElasticSearch能夠接收用戶輸入的腳本而且執行,爲了系統安全考 慮,建議建立一個單獨的用戶用來運行ElasticSearch。

若是沒有普通用戶就要建立一個普通用戶組和普通用戶,下面介紹一下怎麼建立用戶組和普通用戶

建立用戶組和用戶:

 


groupadd esgroup

useradd esuser -g esgroup -p espassword


 

更改elasticsearch文件夾及內部文件的所屬用戶及組:

 


cd /opt

chown -R esuser:esgroup elasticsearch-6.2.4


 

切換用戶並運行:

su esuser

./bin/elasticsearch

再次啓動顯示已殺死:

 

須要調整JVM的內存大小:

vi bin/elasticsearch

ES_JAVA_OPTS="-Xms512m -Xmx512m"

再次啓動:啓動成功

若是顯示以下相似信息:

 


[INFO ][o.e.c.r.a.DiskThresholdMonitor] [ZAds5FP] low disk watermark [85%] exceeded on [ZAds5FPeTY-ZUKjXd7HJKA][ZAds5FP][/opt/elasticsearch-6.2.4/data/nodes/0] free: 1.2gb[14.2%], replicas will not be assigned to this node


 

須要清理磁盤空間。

 


後臺運行:./bin/elasticsearch -d

測試鏈接:curl 127.0.0.1:9200


 

會看到一下JSON數據:


[root@localhost ~]# curl 127.0.0.1:9200
{
"name" : "rBrMTNx",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "-noR5DxFRsyvAFvAzxl07g",
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
}



實現遠程訪問:
須要對config/elasticsearch.yml進行 配置:
network.host: hadoop-001

再次啓動報錯:Failed to load settings from [elasticsearch.yml]

這個錯就是參數的冒號先後沒有加空格,加了以後就好,我找了很久這個問題;

後來在一個外國網站找到了這句話.

 

Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected end of settings but encountered additional content starting at line number: [3], column number: [1]]; nested: ParserException[expected '<document start>', but found BlockMappingStart

 in 'reader', line 3, column 1:

    node.rack : r1

    ^

];

Likely root cause: expected '<document start>', but found BlockMappingStart

 in 'reader', line 3, column 1:

    node.rack : r1

 

這個是行的開頭沒有加空格,fuck!

Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ScannerException[while scanning a simple key

 in 'reader', line 11, column 2:

     discovery.zen.ping.unicast.hosts ... 

     ^

 

參數冒號後加空格,或者是數組中間加空格

例如:

# discovery.zen.minimum_master_nodes: 3

 

再次啓動

仍是報錯

max file descriptors [4096] for elasticsearch process is too low

 

處理第一個錯誤:

vim /etc/security/limits.conf //文件最後加入

esuser soft nofile 65536

esuser hard nofile 65536

esuser soft nproc 4096

esuser hard nproc 4096

 

處理第二個錯誤:

進入limits.d目錄下修改配置文件。

vim /etc/security/limits.d/20-nproc.conf
修改成 esuser soft nproc 4096

 

注意從新登陸生效!!!!!!!!

處理第三個錯誤:

vim /etc/sysctl.conf

vm.max_map_count=655360

執行如下命令生效:
sysctl -p

關閉防火牆:systemctl stop firewalld.service

啓動又又又報錯

 

system call filters failed to install; check the logs and fix your configuration or disable sys

 

直接在

config/elasticsearch.yml  末尾加上一句


bootstrap.system_call_filter: false

 

再次啓動成功!

 


安裝Head插件


Head是elasticsearch的集羣管理工具,能夠用於數據的瀏覽和查詢

(1)elasticsearch-head是一款開源軟件,被託管在github上面,因此若是咱們要使用它,必須先安裝git,經過git獲取elasticsearch-head

(2)運行elasticsearch-head會用到grunt,而grunt須要npm包管理器,因此nodejs是必需要安裝的

nodejs和npm安裝:

http://blog.java1234.com/blog/articles/354.html

git安裝


yum install -y git


 

 

(3)elasticsearch5.0以後,elasticsearch-head不作爲插件放在其plugins目錄下了。
使用git拷貝elasticsearch-head到本地

cd ~

git clone git://github.com/mobz/elasticsearch-head.git

(4)安裝elasticsearch-head依賴包

[root@localhost local]# npm install -g grunt-cli

[root@localhost _site]# cd /usr/local/elasticsearch-head/

[root@localhost elasticsearch-head]# cnpm install

(5)修改Gruntfile.js

[root@localhost _site]# cd /usr/local/elasticsearch-head/

[root@localhost elasticsearch-head]# vi Gruntfile.js

在connect-->server-->options下面添加:hostname:’*’,容許全部IP能夠訪問

(6)修改elasticsearch-head默認鏈接地址
[root@localhost elasticsearch-head]# cd /usr/local/elasticsearch-head/_site/

[root@localhost _site]# vi app.js

將this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";中的localhost修改爲你es的服務器地址

(7)配置elasticsearch容許跨域訪問

打開elasticsearch的配置文件elasticsearch.yml,在文件末尾追加下面兩行代碼便可:

http.cors.enabled: true

http.cors.allow-origin: "*"

(8)打開9100端口

[root@localhost elasticsearch-head]# firewall-cmd --zone=public --add-port=9100/tcp --permanent

重啓防火牆

[root@localhost elasticsearch-head]# firewall-cmd --reload

(9)啓動elasticsearch

(10)啓動elasticsearch-head

 


[root@localhost _site]# cd ~/elasticsearch-head/

[root@localhost elasticsearch-head]# node_modules/grunt/bin/grunt server  或者 npm run start


 

(11)訪問elasticsearch-head

關閉防火牆:systemctl stop firewalld.service

瀏覽器輸入網址:hadoop-001:9100/

 

 

安裝Kibana
Kibana是一個針對Elasticsearch的開源分析及可視化平臺,使用Kibana能夠查詢、查看並與存儲在ES索引的數據進行交互操做,使用Kibana能執行高級的數據分析,並能以圖表、表格和地圖的形式查看數據

(1)下載Kibana
https://www.elastic.co/downloads/kibana

(2)把下載好的壓縮包拷貝到/soft目錄下

(3)解壓縮,並把解壓後的目錄移動到/user/local/kibana

(4)編輯kibana配置文件

[root@localhost /]# vi /usr/local/kibana/config/kibana.yml

 

將server.host,elasticsearch.url修改爲所在服務器的ip地址

 


 

server.port: 5601 //監聽端口

server.host: "hadoo-001" //監聽IP地址,建議內網ip

elasticsearch.url: "http:/hadoo-001" //elasticsearch鏈接kibana的URL,也能夠填寫192.168.137.188,由於它們是一個集羣

 


 

(5)開啓5601端口

Kibana的默認端口是5601

開啓防火牆:systemctl start firewalld.service

開啓5601端口:firewall-cmd --permanent --zone=public --add-port=5601/tcp

重啓防火牆:firewall-cmd –reload

(6)啓動Kibana

[root@localhost /]# /usr/local/kibana/bin/kibana

瀏覽器訪問:http://192.168.137.188:5601

 

安裝中文分詞器

一.離線安裝

(1)下載中文分詞器
https://github.com/medcl/elasticsearch-analysis-ik

下載elasticsearch-analysis-ik-master.zip

(2)解壓elasticsearch-analysis-ik-master.zip

unzip elasticsearch-analysis-ik-master.zip

(3)進入elasticsearch-analysis-ik-master,編譯源碼

mvn clean install -Dmaven.test.skip=true

(4)在es的plugins文件夾下建立目錄ik

(5)將編譯後生成的elasticsearch-analysis-ik-版本.zip移動到ik下,並解壓

(6)解壓後的內容移動到ik目錄下

二.在線安裝

./elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip

相關文章
相關標籤/搜索