elasticsearch安装,以及安装过程遇到的问题以及解决方案

安装elasticsearch

  • 下载
    官方下载地址
    或者使用如下命令
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz
  • 解压
unzip 
  • 运行

进入到bin目录下

cd bin
./elasticsearch
  • 第一问题,用户,切换用户
    如果你的当前登录用户的权限是root权限,会抛出如下异常
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.2.2.jar:6.2.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.2.2.jar:6.2.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.2.2.jar:6.2.2]
        ... 6 more

解决方案:(切换用户,并将elasticsearch目录变成该用户所有)

adduser 用户名
chown -R 用户名:用户名 目录路径
  • 在次执行启动命令,日志如下
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
        at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:341) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:616) ~[elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:258) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:110) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.2.2.jar:6.2.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-6.2.2.jar:6.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) [elasticsearch-6.2.2.jar:6.2.2]
[2018-02-26T14:26:36,863][INFO ][o.e.n.Node               ] [] initializing ...
[2018-02-26T14:26:37,036][INFO ][o.e.e.NodeEnvironment    ] [m-8I2c_] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [12.5gb], net total_space [19.3gb], types [rootfs]
[2018-02-26T14:26:37,037][INFO ][o.e.e.NodeEnvironment    ] [m-8I2c_] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-02-26T14:26:37,039][INFO ][o.e.n.Node               ] node name [m-8I2c_] derived from node ID [m-8I2c_DTIiB97anKbIv_Q]; set [node.name] to override
[2018-02-26T14:26:37,040][INFO ][o.e.n.Node               ] version[6.2.2], pid[24109], build[10b1edd/2018-02-16T19:01:30.685723Z], OS[Linux/2.6.32-573.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_66/25.66-b17]
[2018-02-26T14:26:37,040][INFO ][o.e.n.Node               ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.cgCZRyoe, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/root/elasticsearch/elasticsearch/elasticsearch-6.2.2, -Des.path.conf=/root/elasticsearch/elasticsearch/elasticsearch-6.2.2/config]
[2018-02-26T14:26:37,948][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [aggs-matrix-stats]
[2018-02-26T14:26:37,949][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [analysis-common]
[2018-02-26T14:26:37,949][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [ingest-common]
[2018-02-26T14:26:37,949][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [lang-expression]
[2018-02-26T14:26:37,949][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [lang-mustache]
[2018-02-26T14:26:37,949][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [lang-painless]
[2018-02-26T14:26:37,950][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [mapper-extras]
[2018-02-26T14:26:37,950][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [parent-join]
[2018-02-26T14:26:37,950][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [percolator]
[2018-02-26T14:26:37,950][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [rank-eval]
[2018-02-26T14:26:37,950][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [reindex]
[2018-02-26T14:26:37,951][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [repository-url]
[2018-02-26T14:26:37,951][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [transport-netty4]
[2018-02-26T14:26:37,951][INFO ][o.e.p.PluginsService     ] [m-8I2c_] loaded module [tribe]
[2018-02-26T14:26:37,951][INFO ][o.e.p.PluginsService     ] [m-8I2c_] no plugins loaded
[2018-02-26T14:26:41,625][INFO ][o.e.d.DiscoveryModule    ] [m-8I2c_] using discovery type [zen]
[2018-02-26T14:26:42,385][INFO ][o.e.n.Node               ] initialized
[2018-02-26T14:26:42,387][INFO ][o.e.n.Node               ] [m-8I2c_] starting ...
[2018-02-26T14:26:42,592][INFO ][o.e.t.TransportService   ] [m-8I2c_] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-02-26T14:26:42,610][WARN ][o.e.b.BootstrapChecks    ] [m-8I2c_] system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[2018-02-26T14:26:45,695][INFO ][o.e.c.s.MasterService    ] [m-8I2c_] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {m-8I2c_}{m-8I2c_DTIiB97anKbIv_Q}{YqhL20IDTtaWQ_EL3bd-0w}{127.0.0.1}{127.0.0.1:9300}
[2018-02-26T14:26:45,703][INFO ][o.e.c.s.ClusterApplierService] [m-8I2c_] new_master {m-8I2c_}{m-8I2c_DTIiB97anKbIv_Q}{YqhL20IDTtaWQ_EL3bd-0w}{127.0.0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {m-8I2c_}{m-8I2c_DTIiB97anKbIv_Q}{YqhL20IDTtaWQ_EL3bd-0w}{127.0.0.1}{127.0.0.1:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-02-26T14:26:45,738][INFO ][o.e.h.n.Netty4HttpServerTransport] [m-8I2c_] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018-02-26T14:26:45,739][INFO ][o.e.n.Node               ] [m-8I2c_] started
[2018-02-26T14:26:45,807][INFO ][o.e.g.GatewayService     ] [m-8I2c_] recovered [0] indices into cluster_state

在日志我们看到有一个异常,这个问题就是问题二了,下边说一下解决方案

  • 问题二解决方案
    进入到config目录下,修改elasticsearch.yml配置文件,找到如下的代码,并释放且修改值
# 这个可以在配置文件中找到
bootstrap.memory_lock: false
# 这个找不到,复制粘贴就好
bootstrap.system_call_filter: false

在次启动,问题二也就解决了

  • 测试一下访问
    集群健康监控
    执行命令
curl -XGET http://localhost:9200/_cat/health?v&pretty

响应结果

epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1519627010 14:36:50  elasticsearch green           1         1      0   0    0    0        0             0                  -                100.0%

通过上述的一系列问题解决,我们会发现如下问题,本机可以访问.但是局域网外的其他机器无法方法,问题三

  • 问题三解决方案
    修改elasticsearch.yml配置文件,
network.host: 0.0.0.0

参考博客:
http://blog.csdn.net/hololens/article/details/78932628
http://blog.csdn.net/u010189918/article/details/54632143
http://blog.csdn.net/kongxx/article/details/52993057
http://blog.csdn.net/qq_21387171/article/details/53577115
http://blog.csdn.net/qq942477618/article/details/53414983
http://blog.csdn.net/u012371450/article/details/51776505

你可能感兴趣的:(elasticsearch)