yii2-elasticsearch(2)linux 下 安装elasticsearch

下载

 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz

安装

cd /usr
mkdir elasticsearch
cd
mv elasticsearch-5.4.0.tar.gz /usr/elasticsearch
tar -xvf elasticsearch-5.4.0.tar.gz

运行

 cd elasticsearch-5.4.0
 ./bin/elasticsearch

报错

提示不能使用root操作

[2017-05-17T16:29:29,762][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] []                                                                                                                                                              uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can no                                                                                                                                                             t run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:127                                                                                                                                                             ) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:                                                                                                                                                             114) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwar                                                                                                                                                             eCommand.java:67) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:1                                                                                                                                                             22) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5                                                                                                                                                             .4.0.jar:5.4.0]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)                                                                                                                                                              ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)                                                                                                                                                              ~[elasticsearch-5.4.0.jar:5.4.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.jav                                                                                                                                                             a:106) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:204) ~[ela                                                                                                                                                             sticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:360) ~[elas                                                                                                                                                             ticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123                                                                                                                                                             ) ~[elasticsearch-5.4.0.jar:5.4.0]
        ... 6 more

解决

创建用户elasticsearch

groupadd elasticsearch
useradd elasticsearch -g elasticsearch -p elasticsearch
cd /opt
chown -R elasticsearch:elasticsearch /usr/elasticsearch
su elasticsearch 
cd usr/elasticsearch/elasticsearch-5.4.0
./bin/elasticsearch

运行成功

[2017-05-17T16:59:32,743][INFO ][o.e.n.Node               ] [] initializing ...
[2017-05-17T16:59:32,972][INFO ][o.e.e.NodeEnvironment    ] [hnKt3LR] using [1]                                                                                                                                                              data paths, mounts [[/ (/dev/xvda1)]], net usable_space [5.1gb], net total_space                                                                                                                                                              [19.5gb], spins? [no], types [ext4]
[2017-05-17T16:59:32,973][INFO ][o.e.e.NodeEnvironment    ] [hnKt3LR] heap size                                                                                                                                                              [1.9gb], compressed ordinary object pointers [true]
[2017-05-17T16:59:32,975][INFO ][o.e.n.Node               ] node name [hnKt3LR]                                                                                                                                                              derived from node ID [hnKt3LRPQ42zIWtF-XCIkg]; set [node.name] to override
[2017-05-17T16:59:32,975][INFO ][o.e.n.Node               ] version[5.4.0], pid[                                                                                                                                                             26103], build[780f8c4/2017-04-28T17:43:27.229Z], OS[Linux/3.13.0-32-generic/amd6                                                                                                                                                             4], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_131/25.131-b1                                                                                                                                                             1]
[2017-05-17T16:59:35,295][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [aggs-matrix-stats]
[2017-05-17T16:59:35,295][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [ingest-common]
[2017-05-17T16:59:35,295][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [lang-expression]
[2017-05-17T16:59:35,296][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [lang-groovy]
[2017-05-17T16:59:35,296][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [lang-mustache]
[2017-05-17T16:59:35,296][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [lang-painless]
[2017-05-17T16:59:35,296][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [percolator]
[2017-05-17T16:59:35,296][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [reindex]
[2017-05-17T16:59:35,296][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [transport-netty3]
[2017-05-17T16:59:35,297][INFO ][o.e.p.PluginsService     ] [hnKt3LR] loaded mod                                                                                                                                                             ule [transport-netty4]
[2017-05-17T16:59:35,297][INFO ][o.e.p.PluginsService     ] [hnKt3LR] no plugins                                                                                                                                                              loaded
[2017-05-17T16:59:39,300][INFO ][o.e.d.DiscoveryModule    ] [hnKt3LR] using discovery type [zen]
[2017-05-17T16:59:40,100][INFO ][o.e.n.Node               ] initialized
[2017-05-17T16:59:40,101][INFO ][o.e.n.Node               ] [hnKt3LR] starting ...
[2017-05-17T16:59:40,676][INFO ][o.e.t.TransportService   ] [hnKt3LR] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
[2017-05-17T16:59:40,688][WARN ][o.e.b.BootstrapChecks    ] [hnKt3LR] max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2017-05-17T16:59:40,688][WARN ][o.e.b.BootstrapChecks    ] [hnKt3LR] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2017-05-17T16:59:43,841][INFO ][o.e.c.s.ClusterService   ] [hnKt3LR] new_master {hnKt3LR}{hnKt3LRPQ42zIWtF-XCIkg}{hglKkTxFSziQq4FTsQEpgA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-05-17T16:59:43,922][INFO ][o.e.h.n.Netty4HttpServerTransport] [hnKt3LR] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}
[2017-05-17T16:59:43,926][INFO ][o.e.n.Node               ] [hnKt3LR] started
[2017-05-17T16:59:43,936][INFO ][o.e.g.GatewayService     ] [hnKt3LR] recovered [0] indices into cluster_state

后台启动命令

elasticsearch@iZ25vfteqigZ:/usr/elasticsearch/elasticsearch-5.4.0$ ./bin/elasticsearch -d

访问

curl http://localhost:9200
{
  "name" : "hnKt3LR",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "FjlC6ZEaRlCUmRkrViNvlA",
  "version" : {
    "number" : "5.4.0",
    "build_hash" : "780f8c4",
    "build_date" : "2017-04-28T17:43:27.229Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.0"
  },
  "tagline" : "You Know, for Search"
}

参考文章:
https://my.oschina.net/topeag…
http://www.linuxidc.com/Linux…

    原文作者:zebrayoung
    原文地址: https://segmentfault.com/a/1190000009454835
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞