centos 6.5 elasticsearch 5.1 安裝

添加普通用戶html

useradd tommyjava

passwd tommynode

[root@localhost home]# useradd tommy
[root@localhost home]# passwd tommy
Changing password for user tommy.
New password: 
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.

賦予root權限linux

vi /etc/sudoersbootstrap

添加 tommy ALL=(ALL) ALLbash

[root@localhost home]# chmod -w /etc/sudoers
[root@localhost home]# vi /etc/sudoers
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
tommy   ALL=(ALL)       ALL


安裝jdk服務器

 

安裝elasticsearchapp

unzip elasticsearch-5.1.1.zipless

[tommy@localhost ~]$ unzip elasticsearch-5.1.1.zip

 

配置ssh

$ vi config/elasticsearch.yml

[tommy@localhost elasticsearch-5.1.1]$ vi config/elasticsearch.yml

打開network.host設置爲當前ip

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.1.107
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#

 

啓動

cd elasticsearch-5.1.1/bin/

./elasticsearch

[tommy@localhost ~]$ cd elasticsearch-5.1.1/bin/
[tommy@localhost bin]$ ./elasticsearch

遇到以下錯誤

[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2016-12-31T10:04:16,049][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2016-12-31T10:04:16,050][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty3]
[2016-12-31T10:04:16,051][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2016-12-31T10:04:16,063][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2016-12-31T10:04:31,693][INFO ][o.e.n.Node               ] [node-1] initialized
[2016-12-31T10:04:31,696][INFO ][o.e.n.Node               ] [node-1] starting ...
[2016-12-31T10:04:33,025][INFO ][o.e.t.TransportService   ] [node-1] publish_address {192.168.1.107:9300}, bound_addresses {192.168.1.107:9300}
[2016-12-31T10:04:33,054][INFO ][o.e.b.BootstrapCheck     ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max number of threads [1024] for user [tommy] is too low, increase to at least [2048]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2016-12-31T10:04:33,157][INFO ][o.e.n.Node               ] [node-1] stopping ...
[2016-12-31T10:04:33,340][INFO ][o.e.n.Node               ] [node-1] stopped
[2016-12-31T10:04:33,340][INFO ][o.e.n.Node               ] [node-1] closing ...
[2016-12-31T10:04:33,454][INFO ][o.e.n.Node               ] [node-1] closed

設置 max file descriptors (linux可以打開的最大文件句柄數)

在 /etc/security/limits.conf 文件最後添加

* hard nofile 65536
* soft nofile 65536

[root@localhost home]# echo '* hard nofile 65536' >> /etc/security/limits.conf 
[root@localhost home]# echo '* soft nofile 65536' >> /etc/security/limits.conf

注意是 >>  千萬不要少打一個 > 

設置 max number of threads (linux容許每一個用戶的最大線程數)

修改 vi /etc/security/limits.d/90-nproc.conf

# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     2048
root       soft    nproc     unlimited

設置 vm.max_map_count (限制一個進程能夠擁有的VMA(虛擬內存區域)的數量)

echo 262144 > /proc/sys/vm/max_map_count

sysctl -p

[root@localhost home]# echo 262144 > /proc/sys/vm/max_map_count

退出再次ssh到服務器啓動elasticsearch

遇到以下錯誤

[tommy@localhost bin]$ ./elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000008a660000, 1973026816, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1973026816 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/tommy/elasticsearch-5.1.1/bin/hs_err_pid24402.log

設置elasticsearch jvm配置

vi config/jvm.options (調整jvm參數)

################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms1g
-Xmx1g

 

Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/tommy/elasticsearch-5.1.1/data/my-application]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?

在 elasticsearch-5.1.1/data/nodes/0 目錄下有一個 node.lock

rm -rf node.lock 便可 

 

以守護模式啓動

$ bin/elasticsearch -d

./bin/elasticsearch -d -p pid

查看日誌

tail -100f logs/xxx.log (節點名)

[tommy@localhost elasticsearch-5.1.1]$ tail -100f logs/elasticsearch.log

殺死進程

kill `cat pid`

測試鏈接

[tommy@localhost ~]$ curl -XGET '192.168.1.107:9200'
{
  "name" : "node-1",
  "cluster_name" : "my-application",
  "cluster_uuid" : "KMX4Y_skRByI3wYxvYCp5Q",
  "version" : {
    "number" : "5.1.1",
    "build_hash" : "5395e21",
    "build_date" : "2016-12-06T12:36:15.409Z",
    "build_snapshot" : false,
    "lucene_version" : "6.3.0"
  },
  "tagline" : "You Know, for Search"
}
相關文章
相關標籤/搜索