ElasticSearch 安装

使用Elasticsearch5.0 必须安装jdk1.8

[elsearch@vm-mysteel-dc-search01 bin]$ java -version

java version"1.8.0_112"

Java(TM) SE Runtime Environment (build1.8.0_112-b15)

Java HotSpot(TM)64-Bit Server VM (build25.112-b15, mixed mode)

[elsearch@vm-mysteel-dc-search01 bin]$

使用root账号启动es后 会遇到以下问题

[2016-11-14T10:05:29,358][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread

[main]

org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:116) ~[elasticsearch-

5.0.0.jar:5.0.0]

at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103) ~[elasticsearch-

5.0.0.jar:5.0.0]

at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-

5.0.0.jar:5.0.0]

atorg.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96) ~[elasticsearch-

5.0.0.jar:5.0.0]

atorg.elasticsearch.cli.Command.main(Command.java:62) ~[elasticsearch-5.0.0.jar:5.0.0]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-

5.0.0.jar:5.0.0]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73) ~[elasticsearch-

5.0.0.jar:5.0.0]

解决方案:

因为安全问题elasticsearch 不让用root用户直接运行,所以要创建新用户

    1.建议创建一个单独的用户用来运行ElasticSearch

    2.创建elsearch用户组及elsearch用户

groupadd elsearch

useradd elsearch-g elsearch -p elasticsearch

经用户目录权限

解决方法: chown -R 用户名:用户名  文件(目录)名

例如: chown -R abc:abc searchengine

使用elsearch启动ES后 又会遇到以下问题

ERROR: bootstrap checks failed

max file descriptors [10240]forelasticsearch process likely too low, increase to at least [65536]

max number of threads [1024]foruser [elsearch] likely too low, increase to at least [2048]

maxvirtualmemory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

[2016-11-14T10:22:17,569][INFO ][o.e.n.Node ] [mysteel-node1] stopping ...

[2016-11-14T10:22:17,615][INFO ][o.e.n.Node ] [mysteel-node1] stopped

[2016-11-14T10:22:17,615][INFO ][o.e.n.Node ] [mysteel-node1] closing ...

[2016-11-14T10:22:17,638][INFO ][o.e.n.Node ] [mysteel-node1] closed


解决方法参考 :http://www.cnblogs.com/sloveling/p/elasticsearch.html

切换到root用户

vi /etc/security/limits.conf

添加如下内容:

* soft nofile65536

* hard nofile131072

* soft nproc2048

* hard nproc4096

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

修改如下内容:

* soft nproc1024

#修改为

* soft nproc2048

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl-p

然后,重新启动elasticsearch,即可启动成功。

Elasticsearch5.0 安装问题集锦

elasticsearch 5.0 安装过程中遇到了一些问题,通过查找资料几乎都解决掉了,这里简单记录一下 ,供以后查阅参考,也希望可以帮助遇到同样问题的你。

问题一:警告提示

[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter: 

java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in

at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]

at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]

报了一大串错误,其实只是一个警告。

解决:使用心得linux版本,就不会出现此类问题了。


问题二:ERROR: bootstrap checks failed

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

max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]

解决:切换到root用户,编辑limits.conf 添加类似如下内容

vi /etc/security/limits.conf 

添加如下内容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096


问题三:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

解决:切换到root用户,进入limits.d目录下修改配置文件。

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

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 2048


问题四:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

解决:切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl -p

然后,重新启动elasticsearch,即可启动成功。

如果没有生效,请重启服务器试试。

参考:http://blog.csdn.net/u012371450/article/details/51776505

修改访问elasticsearch的IP及端口

[seven@localhostconfig]$vim /usr/java/elasticsearch/config/elasticsearch.yml

1.找到如下代码段,并取消network.host及http.port所在行的注释,修改IP及端口

# ---------------------------------- Network -----------------------------------

#

# Set the bind address to a specific IP (IPv4 or IPv6):

#

network.host:192.168.0.155

#

# 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>

直接运行bin/elasticsearch文件启动elasticsearch

[seven@localhostbin]$cd /usr/java/elasticsearch/bin/

[seven@localhostbin]$./elasticsearch

启动时发现报错了。。。

[seven@localhost bin]$ ./elasticsearch

[2016-06-2813:49:27,899][INFO][node] [Mondo] version[5.0.0-alpha3], pid[3671], build[cad959b/2016-05-26T08:25:57.564Z], OS[Linux/3.10.0-327.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM)64-BitServerVM/1.0_91/25.91-b14]

▽2016-06-2813:49:27,900][INFO][node] [Mondo] initializing ...

[2016-06-2813:49:28,941][INFO][plugins] [Mondo] modules [percolator, lang-mustache, lang-painless, ingest-grok, reindex, lang-expression, lang-groovy], plugins []

[2016-06-2813:49:28,963][INFO][env] [Mondo] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [15.7gb], net total_space [17.4gb], spins? [unknown], types [rootfs]

[2016-06-2813:49:28,963][INFO][env] [Mondo] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-06-2813:49:31,980][INFO][node] [Mondo] initialized

[2016-06-2813:49:31,980][INFO][node] [Mondo] starting ...

[2016-06-2813:49:32,115][INFO][transport] [Mondo] publish_address {192.168.0.155:9300}, bound_addresses {192.168.0.155:9300}

Exceptioninthread"main"java.lang.RuntimeException: bootstrap checks failed

initial heap size [268435456]notequaltomaximum heap size [2147483648]; this can cause resize pausesandprevents mlockall from locking the entire heap

max file descriptors [4096]forelasticsearch process likely too low, increasetoat least [65536]

pleaseset[discovery.zen.minimum_master_nodes]toa majority of the number of master eligible nodesinyour cluster

max virtual memory areas vm.max_map_count [65530] likely too low, increasetoat least [262144]

at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:125)

at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:85)

at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:65)

at org.elasticsearch.bootstrap.Bootstrap$5.validateNodeBeforeAcceptingRequests(Bootstrap.java:183)

at org.elasticsearch.node.Node.start(Node.java:337)

at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:198)

at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:257)

at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)

at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)

at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)

atorg.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)

atorg.elasticsearch.cli.Command.main(Command.java:53)

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)

Refertothelogforcompleteerrordetails.

[2016-06-2813:49:32,144][INFO][node] [Mondo] stopping ...

[2016-06-2813:49:32,198][INFO][node] [Mondo] stopped

[2016-06-2813:49:32,198][INFO][node] [Mondo] closing ...

[2016-06-2813:49:32,210][INFO][node] [Mondo] closed

于是我临时提高了vm.max_map_count的大小 

*此操作需要root权限

[root@localhost~]# sysctl -w vm.max_map_count=262144

查看修改结果

[root@localhost~]# sysctl -a|grep vm.max_map_count

vm.max_map_count =262144

或者永久性修改

[root@localhost~]# cat /etc/sysctl.conf | grep -v "vm.max_map_count" > /tmp/system_sysctl.conf

[root@localhost~]# echo "vm.max_map_count=262144" >> /tmp/system_sysctl.conf

[root@localhost~]# mv /tmp/system_sysctl.conf /etc/sysctl.conf

mv:是否覆盖"/etc/sysctl.conf"? y

[root@localhost~]# cat /etc/sysctl.conf

# System default settings live in /usr/lib/sysctl.d/00-system.conf.

# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file

#

# For more information, see sysctl.conf(5) and sysctl.d(5).

vm.max_map_count=262144

[root@localhost~]# sysctl -p

vm.max_map_count =262144

上面还有一个错误是关于jvm内存分配的问题heap size [268435456] not equal to maximum heap size [2147483648],需要修改的jvm配置

[seven@localhostbin]$vim /usr/java/elasticsearch/config/jvm.options

将-Xmx2g改成-Xmx256m,也就是heap size [268435456] /1024/1024的值

又有新的错误。。。

Exceptioninthread"main"java.lang.RuntimeException: bootstrap checks failed

initial heap size [268435456]notequaltomaximum heap size [2147483648]; this can cause resize pausesandprevents mlockall from locking the entire heap

max file descriptors [4096]forelasticsearch process likely too low, increasetoat least [65536]

memory locking requestedforelasticsearch process but memoryisnotlocked

at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:125)

at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:85)

at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:65)

at org.elasticsearch.bootstrap.Bootstrap$5.validateNodeBeforeAcceptingRequests(Bootstrap.java:183)

at org.elasticsearch.node.Node.start(Node.java:337)

at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:198)

at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:257)

at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)

at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)

at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)

at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)

at org.elasticsearch.cli.Command.main(Command.java:53)

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)

Refertothelogforcompleteerrordetails.

[2016-06-2814:55:49,770][INFO ][node ] [Goldbug] stopping ...

[2016-06-2814:55:49,875][INFO ][node ] [Goldbug] stopped

[2016-06-2814:55:49,875][INFO ][node ] [Goldbug] closing ...

[2016-06-2814:55:49,887][INFO ][node ] [Goldbug] closed

这个问题折腾了我一下午,最后还是找到了解决方案,同样回到config/elasticsearch.yml文件,找到如下配置,开放discovery.zen.ping.unicast.hosts及discovery.zen.minimum_master_nodes

# --------------------------------- Discovery ----------------------------------

#

# Pass an initial list of hosts to perform discovery when new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

#

discovery.zen.ping.unicast.hosts: ["192.168.0.155"]

#

# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):

#

discovery.zen.minimum_master_nodes:3

#

# For more information, see the documentation at:

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>

然后修改max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]这个错误(切换到root操作)

[root@localhost~]# cp /etc/security/limits.conf /etc/security/limits.conf.bak

[root@localhost~]# cat /etc/security/limits.conf | grep -v "seven" > /tmp/system_limits.conf

[root@localhost~]# echo "seven hard nofile 65536" >> /tmp/system_limits.conf

[root@localhost~]# echo "seven soft nofile 65536" >> /tmp/system_limits.conf

[root@localhost~]# mv /tmp/system_limits.conf /etc/security/limits.conf

修改后重新登录seven用户,使用如下命令查看是否修改成功

[seven@localhost~]$ulimit -Hn

65536

接下来就可以启动elasticsearch了,启动完成使用浏览器访问http://192.168.0.155:9200

{

"name":"Vampire by Night",

"cluster_name":"elasticsearch",

"version":{

"number":"5.0.0-alpha3",

"build_hash":"cad959b",

"build_date":"2016-05-26T08:25:57.564Z",

"build_snapshot":false,

"lucene_version":"6.0.0"

},

"tagline":"You Know, for Search"

}

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,793评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,567评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,342评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,825评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,814评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,680评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,033评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,687评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,175评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,668评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,775评论 1 332
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,419评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,020评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,978评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,206评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,092评论 2 351
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,510评论 2 343