elasticsearch 7.6 安裝部署

操作系統版本:centos 7.6  

版本:elasticsearch 7.6.1

jdk版本 11.0.6


服務器列表:

192.168.0.31

192.168.0.32

192.168.0.33


1、安裝jdk 11

具體的步驟省略

2、安裝elasticsearch

官網下載elasticsearch-7.6.1-x86_64 rpm安裝包

rpm -ivh elasticsearch-7.6.1-x86_64.rpm 


修改配置文件

#cat /etc/elasticsearch/elasticsearch.yml |grep -v "^#"

cluster.name: Hnbd#集羣名稱

node.name: Es-31#集羣節點名稱

path.data: /var/lib/elasticsearch#數據文件路徑

path.logs: /var/log/elasticsearch#日誌文件路徑

bootstrap.memory_lock: true#鎖定物理內存地址,防止elasticsearch內存被交換出去,也就是避免es使用swap交換分區

network.host: 0.0.0.0#ip地址

http.port: 9200#開放端口號

discovery.seed_hosts: ["192.168.0.31","192.168.0.32", "192.168.0.33"]#設置集羣節點地址

cluster.initial_master_nodes: ["Es-31"]#指定主節點列表

http.cors.enabled: true#打開跨域訪問,head 插件需要這打開這兩個配置

http.cors.allow-origin: "*"


添加開機服務啓動

systemctl enable elasticsearch.service


設置JVM堆內存大小,根據服務器內存大小進行設置,最好不要超過總內存的一半

#cat /etc/elasticsearch/jvm.options 

## JVM configuration

# Xms represents the initial size of total heap space

# Xmx represents the maximum size of total heap space

-Xms2g

-Xmx2g


設置elasticsearch的JAVA_HOME

#cat /etc/sysconfig/elasticsearch |grep "JAVA_HOME"

JAVA_HOME=/usr/java/jdk-11.0.6/


centos7需要修改systemd配置,否則啓動會報錯

/etc/systemd/system.conf

DefaultLimitNOFILE=65536

DefaultLimitNPROC=32000

DefaultLimitMEMLOCK=infinity


ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked

官網說明:

elasticsearch官網建議生產環境需要設置bootstrap.memory_lock: true

官網的解釋 

是:發生系統swapping的時候ES節點的性能會非常差,也會影響節點的穩定性。所以要不惜一切代價來避免swapping。swapping會導致Java GC的週期延遲從毫秒級惡化到分鐘,更嚴重的是會引起節點響應延遲甚至脫離集羣。所以最好限制住elasticsearch佔用的內存情況,可選少用swap

centos7需要修改systemd配置,centos6方式不一樣


3、安裝elasticsearch-head插件

elasticsearch 7.6是需要單獨安裝這個插件的,之前的老版本自帶插件

安裝依賴包

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2X gcc-c++ autoconf bzip2 -y

cd /usr/local/src/

使用git獲取源碼包

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


安裝nodejs

curl -sL https://rpm.nodesource.com/setup_10.x | bash -

yum install -y nodejs

#node -v

v10.19.0

#npm -v

6.13.4


安裝grunt客戶端程序來控制head插件

npm install -g grunt --registry=https://registry.npm.taobao.org

npm install -g grunt-cli --registry=https://registry.npm.taobao.org

npm install grunt-contrib-clean --registry=https://registry.npm.taobao.org

npm install grunt-contrib-concat --registry=https://registry.npm.taobao.org

npm install grunt-contrib-watch --registry=https://registry.npm.taobao.org

npm install grunt-contrib-connect --registry=https://registry.npm.taobao.org

npm install grunt-contrib-copy --registry=https://registry.npm.taobao.org

npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org


修改Gruntfile.js配置文件,添加hostname字段

                connect: {

                        server: {

                                options: {

                                        port: 9100,

                                        hostname: "*",

                                        base: '.',

                                        keepalive: true

                                }

                        }

                }

修改/usr/local/elasticsearch-head/_site/app.js默認端口號把9200改爲9100,此端口是head對外提供的http端口,把localhost改爲本機對外訪問的地址

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.0.31:9100";


注:前邊的elasticsearch.yml配置文件一定要打開跨域訪問配置文件(http.cors.enabled: true   http.cors.allow-origin: "*")


啓動elasticsearch-head 

#cd /usr/local/elasticsearch-head

#nohup grunt server &


瀏覽器打開elasticsearch-head   

http://192.168.0.31:9100/


QQ圖片20200324161813.png

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