centos 下安装 elastic search 启动的问题

正常步骤html

1Download and unzip Elasticsearchjava

2 Run bin/elasticsearch node

3 Run curl http://localhost:9200/vim

 

异常信息:app

root 帐户启动报错,Exception in thread "main" Java.lang.RuntimeException: don't run elasticsearch as root.curl

解决办法:jvm

 

 

解决方法1:elasticsearch

在执行elasticSearch时加上参数-Des.insecure.allow.root=true,完整命令以下ide

[plain] view plain copyui

 在CODE上查看代码片派生到个人代码片

  1. ./elasticsearch -Des.insecure.allow.root=true  

解决办法2:

 

用vi打开elasicsearch执行文件,在变量ES_JAVA_OPTS使用前添加如下命令

[plain] view plain copy

 在CODE上查看代码片派生到个人代码片

  1. ES_JAVA_OPTS="-Des.insecure.allow.root=true"  

 

解决办法3:

添加新用户组和用户,让非root 用户组用户启动:

groupadd elsearch

useradd es -g elsearch -p 123456

 

而后把咱们的es 所在文件夹的 用户指定为 elsearch 

chown -R elsearch:elsearch elasticsearch

 

启动成功以后 会有日志:

[2016-12-20T18:40:28,270][INFO ][o.e.g.GatewayService     ] [MUQhN6Y] recovered [0] indices into cluster_state
[2016-12-20T18:40:28,276][INFO ][o.e.h.HttpServer         ] [MUQhN6Y] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2016-12-20T18:40:28,276][INFO ][o.e.n.Node               ] [MUQhN6Y] started

 

 

访问url 成功会有结果:

{
  "name" : "MUQhN6Y",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "GQd_A6XCRFKMnzswmckmuA",
  "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"
}

 

 

如今本机访问能够访问了,可是在其余机器上访问仍是有问题,提示链接拒绝,为何呢?

由于这个端口只是监听127.0.0.1 的回环地址,不监听其余地址,而127 的地址只能本机访问,因此其余机器没法访问这台机器。

那该怎么办呢?

es 提供了解决办法:

/usr/local/share/elasticsearch-5.1.1/config 目录下有一个 文件elasticsearch.yml

若是想监听本机全部ip ,则配置:network.host: 0.0.0.0

若是想监听指定ip,多个ip逗号隔开 则:network.host: 127.0.0.1,192.168.12.18

 

而后从新启动,爆出异常:

 

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

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

 

第一个问题:解决方案:

一样回到config/elasticsearch.yml文件,找到以下配置,开放discovery.zen.ping.unicast.hosts及discovery.zen.minimum_master_nodes

 

 
  1. # --------------------------------- Discovery ----------------------------------

  2. #

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

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

  5. #

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

  7. #

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

  9. #

  10. discovery.zen.minimum_master_nodes: 3

  11. #

  12. # For more information, see the documentation at:

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

 

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

 

切换到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

以上serven 名称为 本身的非root 用户名。

 

 

修改后从新登陆seven用户,使用以下命令查看是否修改为功

 
  1. [seven@localhost ~]$ ulimit -Hn

  2. 65536

 

 

第2个问题:解决方案:

 

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

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

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

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

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

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

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

  8. #

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

  10. vm.max_map_count=262144

  11. [root@localhost ~]# sysctl -p

  12. vm.max_map_count = 262144

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

 

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

[seven@localhost bin]$ vim /usr/java/elasticsearch/config/jvm.options
  • 1

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

 

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

解决方案:

 

 

# 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     1024
root       soft    nproc     unlimited

 

 

修改1024 为2048 。

 

最后终于启动成功,而且其余机器也能够访问了。

相关文章
相关标签/搜索