elasticsearch簡介
ElasticSearch是一個基于Lucene的搜索服務器。它提供了一個分布式多用戶能力的全文檢索引擎,基于RESTful web接口。Elasticsearch是用Java開發(fā)的,并作為Apache許可條款下的開放源碼發(fā)布,是當前流行的企業(yè)級搜索引擎。設計用于云計算中,能夠達到實時搜索,穩(wěn)定,可靠,快速,安裝使用方便。
實驗部署
1、實驗所需組件及環(huán)境
1)JDK8以上環(huán)境
2)CentOS7.3,IP地址:192.168.144.112
3)elasticsearch6.3.2
- es最新軟件軟件包可在官方網站下載:https://www.elastic.co/downloads/elasticsearch
2、安裝jdk8以上版本
yum install java -y
java -version 查看java版本
3、部署elasticsearch6.3.2
-
首先在官網當中下載es的軟件包,本文采用壓縮包解壓縮安裝方式啟動服務。
- 值得注意的是,在es5.0版本后不支持與logstash和kibana2.x版本的混用,且安全級別的提升,使得es在后續(xù)的版本中不允許使用root用戶啟動,因此我們需要創(chuàng)建另外獨立賬戶專供es使用。并且需要在root權限下將該特定環(huán)境準備好。
tar zxvf elasticsearch-6.3.2.tar.gz -C /opt/
- 創(chuàng)建獨立用戶與組(root用戶下創(chuàng)建設定)
groupadd ela 創(chuàng)建ela組
useradd -g ela ela 創(chuàng)建ela用戶,并且加入ela組
passwd ela 為ela用戶設定登錄密碼
visudo(或者vim /etc/sudoers)
- 為了讓ela用戶擁有對elasticsearch執(zhí)行權限,在root用戶權限下解壓后,需要將軟件包更改屬主屬組。
chown -R ela.ela /opt/elasticsearch-6.3.2/
ls -l /opt/elasticsearch-6.3.2/
- 切換到ela用戶,編輯配置文件,準備啟動es
su ela
[ela@localhost ~]$ cd /opt/elasticsearch-6.3.2/config/
[ela@localhost config]$ sudo vim elasticsearch.yml
# ———————————- Cluster ———————————–
#
# Use a descriptive name for your cluster:
#
cluster.name: abner //打開設定es群集名稱
#
# ———————————— Node ————————————
#
# Use a descriptive name for the node:
#
node.name: node-1 //es當前節(jié)點名稱,用于區(qū)分不同節(jié)點
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ———————————– Paths ————————————
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /data/es-data //修改數(shù)據目錄,此目錄為自定義,需要在root用戶下創(chuàng)建,且屬主屬組更改為ela
#
# Path to log files:
#
path.logs: /var/log/elasticsearch //日志目錄位置,需自己創(chuàng)建,方式同上
//yum安裝則系統(tǒng)自定義,在軟件版本或者系統(tǒng)升級時會被刪除,所以建議修改
#
# ———————————– Memory ———————————–
#
# Lock the memory on startup:
#
bootstrap.memory_lock: true //elasticsearch官網建議生產環(huán)境需要設置bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ———————————- Network ———————————–
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0 //監(jiān)聽訪問地址為任意網段
#
# Set a custom port for HTTP:
#
http.port: 9200 //服務監(jiān)聽端口
#
編輯完成配置文件后,數(shù)據目錄以及日志文件目錄需要創(chuàng)建
sudo mkdir -p /data/es-data
sudo mkdir -p /var/log/elasticsearch
sudo chown -R ela.ela /data/
sudo chown -R ela.ela /var/log/elasticsearch
- 準備工作完成,啟動es
[ela@localhost /]$ cd /opt/elasticsearch-6.3.2/bin/
[ela@localhost bin]$ ./elasticsearch 后面可以跟上-d后臺執(zhí)行
4、啟動發(fā)現(xiàn)異常情況以及處理方式
-當發(fā)現(xiàn)如上圖無法分配內存錯誤等,可執(zhí)行如下操作。(需要在root用戶權限下)
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
ela soft memlock unlimited
ela hard memlock unlimited
- 當發(fā)現(xiàn)ERROR: [1] bootstrap checks failed錯誤時,解決方式如下(root用戶狀態(tài)下)
vim /etc/sysctl.conf
vm.max_map_count = 655360 //添加
sysctl -p
- 切換到ela用戶,執(zhí)行啟動程序
[ela@localhost abc]$ cd /opt/elasticsearch-6.3.2/bin/
[ela@localhost bin]$ ./elasticsearch
- 新建終端,以root用戶查看9200端口是否開啟
netstat -ntap | grep 9200
tcp6 0 0 :::9200 :::* LISTEN 2095/java
- 打開瀏覽器訪問驗證,出現(xiàn)如下界面即安裝成功,訪問時記得關閉防火墻?。?!
Elasticsearch 教程系列文章:
Linux上安裝部署ElasticSearch全程記錄 http://www.sfodin.cn/Linux/2015-09/123241.htm
Linux下Elasticsearch 1.7.0安裝配置 http://www.sfodin.cn/Linux/2017-05/144215.htm
在Ubuntu 16.04 中安裝 Elasticsearch 5.4分析引擎 http://www.sfodin.cn/Linux/2017-07/145588.htm
Elasticsearch1.7升級到2.3實踐總結 http://www.sfodin.cn/Linux/2016-11/137282.htm
Ubuntu 14.04中Elasticsearch集群配置 http://www.sfodin.cn/Linux/2017-01/139460.htm
Elasticsearch-5.0.0移植到Ubuntu 16.04 http://www.sfodin.cn/Linux/2017-01/139505.htm
ElasticSearch 5.2.2 集群環(huán)境的搭建 http://www.sfodin.cn/Linux/2017-04/143136.htm
Linux下安裝搜索引擎Elasticsearch http://www.sfodin.cn/Linux/2017-05/144105.htm
CentOS上安裝 ElasticSearch 詳解 http://www.sfodin.cn/Linux/2017-05/143766.htm
Elasticsearch5.3安裝插件head http://www.sfodin.cn/Linux/2017-09/147008.htm
Linux上安裝Elasticsearch http://www.sfodin.cn/Linux/2018-08/153391.htm