Elasticsearch簡介
Elasticsearch 是一個開源的分布式 RESTful 搜索和分析引擎,能夠解決越來越多不同的應用場景
官網地址:https://www.elastic.co/cn/elasticsearch/
官網介紹地址:https://www.elastic.co/cn/what-is/elasticsearch
中文文檔:https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html
Elasticsearch安裝
環境:Linux(CentOS 7.4)
jdk(1.8)
elasticsearch版本:7.6.1
1、下載,官網下載地址:https://www.elastic.co/cn/downloads/elasticsearch
2、解壓到安裝目錄,命令:tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz -C /data/soft/
3、進入解壓目錄,命令:cd /data/soft/elasticsearch-7.6.1
config/elasticsearch.yml ---elasticsearch配置文件
config/jvm.options ---java jvm參數配置
config/log4j2.properties ---日志相關配置
修改elasticsearch.yml配置文件,elasticsearch綁定地址0.0.0.0,即可遠程訪問
1 network.host: 0.0.0.0
4、修改啟動參數(可以不修改)
說明:在Elasticsearch中如果,network.host不是localhost或127.0.0.1的話就會認為是生產環境,會對環境要求比較高,
測試環境不一定滿足
1)修改jvm啟動參數
命令:vim config/jvm.options
1 -Xms128m 2 -Xmx128m
5、啟動elasticsearch程序
前台啟動命令:./bin/elasticsearch
后台啟動命令:./bin/elasticsearch -d
關閉命令:kill 進程ID (不推薦kill -9)
查看java進程:jps
a、錯誤:java.lang.RuntimeException:can not run elasticsearch as root
解決方案:
1)添加es用戶,命令:useradd es
2)給es用戶授文件夾權限,命令:chown -R es:es /data/soft/elasticsearch-7.6.1
3)切換es用戶,命令:su es
4)執行啟動,命令:./bin/elasticsearch
b、錯誤:
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: max number of threads [3895] for user [es] is too low, increase to at least [4096]
解決方案:
1)最大文件描述符太少了,至少要65536,修改/etc/security/limits.conf文件
命令:vim /etc/security/limits.conf
內容修改為:* hard nofile 65536
2)一個進程可以擁有的VMA(虛擬內存區域)的數量太少了,至少要262144,修改文件
命令:vim /etc/sysctl.conf
增加內容為:vm.max_map_count=262144
3)最大線程太少了,至少要4096,修改/etc/security/limits.conf文件
命令:vim /etc/security/limits.conf
增加內容為:* hard nproc 65536
4) 是修改配置生效,重啟服務器
c、錯誤
#配置以下三者,最少其一
#[discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes]
解決方案:
修改es配置文件,命令:vim config/elasticsearch.yml,內容如下:
1 node.name: node-1 2 3 cluster.initial_master_nodes: ["node-1"]
6、使用瀏覽器進行訪問,地址:http://ip:9200。默認端口就是9200,可以在配置文件中修改