Elasticsearch基礎1(安裝)

Elasticsearch介紹
全文搜索屬於最常見的需求, elasticsearch是目前全文搜索引擎的首選。
Elasticsearch是一個基於 Lucene的搜索服務器。它提供了一個分佈式多用戶能力的全文搜索引孳,基於 RESTful web接口。
Elasticsearch是用Java開發的,並作爲 Apache許可條款下的開放源碼發佈。設計用於雲計算中,能夠達到實時搜索,穩定,可靠,快速,安裝使用方便.
它可以快速地儲存、搜索和分析海量數據。維基百科、 Stack Overflow、ihub等知名網站都採用了它。

Kibana 是爲 Elasticsearch設計的開源分析和可視化平臺。你可以使用 Kibana 來搜索,查看存儲在 Elasticsearch 索引中的數據並與之交互。你可以很容易實現高級的數據分析和可視化,以圖標的形式展現出來。

Elasticsearch官網:https://www.elastic.co/cn/products/elasticsearch/

安裝前需有Java環境

1.安裝JDK

yum install -y java

查看是否安裝成功

java -version

2. 安裝es  (端口默認9200)

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.1-x86_64.rpm
rpm -ivh elasticsearch

啓動:

[root@es7 ~]# systemctl start elasticsearch.service
[root@es7 ~]# systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.
[root@es7 ~]# systemctl is-enabled elasticsearch.service
enabled
[root@es7 ~]#

驗證是否開啓

curl localhost:9200

查看端口是否啓動:

netstat -apn | grep 9200

啓動失敗提示錯誤:
錯誤1:
Native memory allocation(mmap) failed to map 107286953984 bytes for committing reserved memory.
解決方案:/etc/elasticsearch/jvm.options
修改jvm.opains文件中關於內存的配置(根據服務器實際內存大小調整)

vi /etc/elasticsearch/jvm.options
-Xms256m
-Xmx256m

錯誤2:
configure the number of parallel GC threads appropriately using-XX:ParalleIGCThreads=N
解決方案:添加配置到jvm.options

vi /etc/elasticsearch/jvm.options
###在最後一行添加
-XX:-AssumeMP 

允許外部訪問9200:
修改配置文件:(參考地址:ElasticSearch7 設置外網訪問失敗)

vi /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["127.0.0.1", "[::1]"]

保存重啓
將9200端口加入防火牆:

firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload
systemctl restart firewalld

2. 安裝kibana(端口默認5601

wget https://artifacts.elastic.co/downloads/kibana/kibana-7.5.1-x86_64.rpm
rpm -ivh kibana

配置:

vi /etc/kibana/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana"
elasticsearch.hosts: ["http://localhost:9200"]

查看更改的相關配置

cat /etc/kibana/kibana.yml | grep -v '#' | grep -v '^$'

將5601端口加入防火牆

firewall-cmd --zone=public --add-port=5601/tcp --permanent
firewall-cmd --reload
systemctl restart firewalld

啓動kibana:

/usr/share/kibana/bin/kibana

若出現報錯:Kibana should not be run as root.  Use --allow-root to continue.
解決:kibana不建議以root用戶啓動,如果用root啓動,需要加--allow-root

/usr/share/kibana/bin/kibana --allow-root

啓動時間有點長,稍等一會....

後臺運行:

nohup /usr/share/kibana/bin/kibana --allow-root &

訪問:
127.0.0.1:5601
 

 

發佈了104 篇原創文章 · 獲贊 52 · 訪問量 30萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章