1. 程式人生 > >Elasticsearch 5.6.5 安裝教程

Elasticsearch 5.6.5 安裝教程

瀏覽器 arc address set logs ats hook common bit

下載地址 https://www.elastic.co/downloads/past-releases/elasticsearch-5-6-5

安裝環境 centos6.5 , jdk1.8

一:解壓

[root@localhost programs]# tar zxvf elasticsearch-5.6.5.tar.gz

二:創建ES用戶和組(創建elsearch用戶組及elsearch用戶)

因為使用root用戶執行ES程序,將會出現錯誤;所以這裏需要創建單獨的用戶去執行ES 文件。

[root@localhost programs]# groupadd elsearch   ##添加用戶組
[root@localhost programs]# useradd elsearch -g elsearch ##添加用戶到用戶組 [root@localhost programs]# chown -R elsearch:elsearch elasticsearch-5.6.5 ##更改該文件夾下所屬的用戶組的權限

三:創建ES數據文件和日誌文件

直接在root用戶根目錄一下創建

[root@localhost data]# mkdir /data

更改權限

[root@localhost data]# chown -R elsearch:elsearch /data/

切換用戶

[root@localhost data]# su - elsearch

創建 es的data和logs目錄

[elsearch@localhost ~]$ cd /data
[elsearch@localhost ~]$ mkdir -p es/data
[elsearch@localhost ~]$ mkdir -p es/logs

四:修改ES配置文件

進入到config文件夾,編輯 elasticsearch.yml

/usr/local/programs/elasticsearch-5.6.5/config
[root@localhost config]# vi elasticsearch.yml 

修改如下(沒有配置集群,只是簡單的配置了一下):

#集群名稱
cluster.name: my-application     
#節點名稱
node.name: node-1    
#數據存儲目錄(多個路徑用逗號分隔)
path.data: /data/es/data
#日誌目錄
path.logs: /data/es/logs
# 修改一下ES的監聽地址,這樣別的機器才可以訪問
network.host: 10.10.10.5
# 監聽端口(默認的就好)  
http.port: 9200

註意,設置參數的時候“:冒號”後面要有空格

五:啟動

切換到elsearch用戶,進入到bin 目錄下執行 ./elasticsearch 命令就可以了,執行 ./elasticesrarch -d 是後臺運行

[elsearch@localhost bin]$ ./elasticsearch
[2018-01-05T10:17:09,102][INFO ][o.e.n.Node               ] [node-1] initializing ...
[2018-01-05T10:17:09,271][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/data (/dev/mapper/ol-data)]], net usable_space [737.3gb], net total_space [737.3gb], spins? [possibly], types [xfs]
[2018-01-05T10:17:09,272][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [1.9gb], compressed ordinary object pointers [true]
[2018-01-05T10:17:09,273][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [O9EeZpd5Q0yYJjRUV7bfLg]
[2018-01-05T10:17:09,273][INFO ][o.e.n.Node               ] [node-1] version[5.6.5], pid[4810], build[6a37571/2017-12-04T07:50:10.466Z], OS[Linux/3.8.13-35.3.1.el7uek.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_65/25.65-b01]
[2018-01-05T10:17:09,274][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/programs/elasticsearch-5.6.5]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-groovy]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [parent-join]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty3]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2018-01-05T10:17:11,469][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2018-01-05T10:17:14,679][INFO ][o.e.d.DiscoveryModule    ] [node-1] using discovery type [zen]
[2018-01-05T10:17:15,887][INFO ][o.e.n.Node               ] [node-1] initialized
[2018-01-05T10:17:15,888][INFO ][o.e.n.Node               ] [node-1] starting ...
[2018-01-05T10:17:16,187][INFO ][o.e.t.TransportService   ] [node-1] publish_address {10.10.10.5:9300}, bound_addresses {10.10.10.5:9300}
[2018-01-05T10:17:16,209][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] 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]
[2018-01-05T10:17:16,238][INFO ][o.e.n.Node               ] [node-1] stopping ...
[2018-01-05T10:17:16,351][INFO ][o.e.n.Node               ] [node-1] stopped
[2018-01-05T10:17:16,351][INFO ][o.e.n.Node               ] [node-1] closing ...
[2018-01-05T10:17:16,367][INFO ][o.e.n.Node               ] [node-1] closed

發現錯誤1:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

意思是說你的進程不夠用了。

解決方案: 切到root 用戶:進入到security目錄下的limits.conf;執行命令 vi /etc/security/limits.conf :

[root@localhost bin]# vi /etc/security/limits.conf

在文件的末尾添加下面的參數值:

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

發現錯誤2:

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

操作系統的vm.max_map_count參數設置太小導致的,請使用root用戶登錄系統,執行以下命令:

[root@localhost bin]# sysctl -w vm.max_map_count=655360        
vm.max_map_count = 655360
[root@localhost bin]# sysctl -a | grep "vm.max_map_count"    #查看是否修改成功
vm.max_map_count = 655360

再次切換到elsearch用戶,進入到bin 目錄下執行 ./elasticsearch 命令,啟動正常。

六:測試

外部訪問需要方法9200端口,打開防火墻端口。

在瀏覽器中訪問http://自己配置的IP地址:9200/,出現下面信息:

{
  "name" : "node-1",
  "cluster_name" : "my-application",
  "cluster_uuid" : "xS4wySq2SMKdeBvSO2nxqg",
  "version" : {
    "number" : "5.6.5",
    "build_hash" : "6a37571",
    "build_date" : "2017-12-04T07:50:10.466Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}

說明可以正常訪問。

Elasticsearch 5.6.5 安裝教程