CentOS7下安裝Elasticsearch-7.3.2和Elasticsearch-head

下載Elasticsearch-7.3.2-linux-x86_64.tar.gz
Elasticsearch下載地址:
https://www.elastic.co/cn/downloads/elasticsearch
Elasticsearch-head+node+grunt下載地址:
https://download.csdn.net/download/zhengzaifeidelushang/11851790
在這裏插入圖片描述

#解壓縮
tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz

#實現遠程訪問需要對config/elasticsearch.yml進行配置
network.host: 10.177.33.47   #本地IP地址
http.port: 9200

#配置elasticsearch允許跨域訪問
#打開elasticsearch的配置文件elasticsearch.yml,在文件末尾追加下面
http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true

#啓動elasticsearch
cd /opt/elasticsearch/bin
./elasticsearch

#出現如下錯誤
Caused by: java.lang.RuntimeException: can not run elasticsearch as root

Elasticsearch可以接收用戶輸入的腳本並且執行,root下執行Elasticsearch會報錯,爲了系統安全考慮,創建一個單獨的用戶來運行Elasticsearch

解決方法如下:

#創建elsearch用戶組及elsearch用戶:
groupadd elsearch
useradd elsearch -g elsearch -p  es@123


#更改elasticsearch文件夾及內部文件的所屬用戶及組爲elsearch:elsearch
chown -R elsearch:elsearch  elasticsearch

#切換到elsearch用戶再啓動
su elsearch 
cd /opt/elasticsearch/bin
./elasticsearch

#查看es狀態
curl 10.177.33.47:9200
#或者通過瀏覽器查看
firefox
localhost:9200

#出現如下錯誤按照處理方法更改配置文件
ERROR: [2] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
#處理第一個錯誤方法:
#配置內存
vim /etc/sysctl.conf
vm.max_map_count=655360
#保存後執行命令生效:
sysctl -p
#重新啓動後成功

[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
#處理第二個錯誤方法:
#修改config目錄下的 elasticsearch.yml文件
vim elasticsearch.yml
cluster.initial_master_nodes: ["node-1"]

#如還出現下面報錯,按照處理方法解決
[3]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
#處理第三個錯誤方法:
vim /etc/security/limits.conf
#修改文件最大打開數
elsearch soft nofile 65536
elsearch hard nofile 65536
elsearch soft nproc 4096
elsearch hard nproc 4096

[4] max num of threads [3790] for user [elsticsearch] is too low, increase to at least [4096] 
#處理第四個錯誤方法:
vim /etc/security/limits.d/20-nproc.conf
elsearch   soft   nproc   4096
 
 #重新啓動
 ./elasticsearch
#windows客戶端網頁輸入ip和端口即可登陸linux上的Elasticsearch
 10.177.33.47:9200

#需要可關閉防火牆:systemctl stop firewalld.service

安裝elasticsearch-head

# 1. 解壓
 unzip elasticsearch-head-master.zip
# 2.下載nodejs 
 tar -xvf node-v12.11.1-linux-x64.tar.xz
#設置node環境變量
#node,NODE_HOME是node絕對安裝路徑
vim /etc/profile
export NODE_HOME=/moudle/node
export PATH=$PATH:$NODE_HOME/bin
#查看node版本號
node -v 

#3.安裝grunt
#grunt離線安裝包grunt.tar,可以安裝在任意位置
tar -zxvf grunt.tar 
#添加grunt-cli環境變量
vim ~/.bash_profile

# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/moudle/node/bin:/moudle/grunt/bin
export PATH

#查看版本號
grunt-cli v1.3.2
grunt v1.0.4

#修改Gruntfile.js 允許所有IP都可以訪問
connect: {
            server: {
                  options: {
                          hostname:'*',
                          port: 9100,
                          base: '.',
                          keepalive: true
                            }
                     }
         }

#防火牆開啓9100端口
#firewall-cmd --zone=public --add-port=9100/tcp --permanent
#重啓防火牆
#firewall-cmd --reload

#啓動elasticsearch,進入elasticsearch-head安裝目錄
grunt server
#運行成功顯示
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

#在瀏覽器中輸入10.177.33.47:9100打開elasticsearch-head
Elasticsearch連接地址爲:http://10.177.33.47:9200/

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章