1. 程式人生 > >CENTOS 安裝 ElasticSearch

CENTOS 安裝 ElasticSearch

如果是用root啟動,需要繼續下面步驟
  • 如果是用root賬號啟動,會報以下錯誤

    Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root. at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285
    ) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Refer to the log for complete error details.
  • 這是出於系統安全考慮設定的條件。由於ElasticSearch可以接收使用者輸入的指令碼並且執行,為了系統安全考慮, 
    建議建立一個單獨的使用者用來執行ElasticSearch

  • 建立elsearch使用者組及elsearch使用者

    groupadd elsearch
    useradd elsearch -g elsearch -p elasticsearch
  • 更改elasticsearch資料夾及內部檔案的所屬使用者及組為elsearch:elsearch

    cd /opt
    chown -R elsearch:elsearch  elasticsearch
  • 切換到elsearch使用者再啟動

    su elsearch cd elasticsearch/bin
    ./elasticsearch
  • 啟動後列印資訊如下

    [2015-12-3010:15:44,876][WARN ][bootstrap                ] unable to install syscall filter: prctl(PR_GET_NO_NEW_PRIVS): Invalid argument
    [2015
    -12-3010:15:45,175][INFO ][node ] [Grim Hunter] version[2.1.1], pid[26383], build[40e2c53/2015-12-15T13:05:55Z] [2015-12-3010:15:45,176][INFO ][node ] [Grim Hunter] initializing ... [2015-12-3010:15:45,243][INFO ][plugins ] [Grim Hunter] loaded [], sites [] [2015-12-3010:15:45,272][INFO ][env ] [Grim Hunter] using [1] data paths, mounts [[/ (/dev/mapper/vg_yong-lv_root)]], net usable_space [33.3gb], net total_space [49gb], spins? [no], types [ext4] [2015-12-3010:15:47,318][INFO ][node ] [Grim Hunter] initialized [2015-12-3010:15:47,318][INFO ][node ] [Grim Hunter] starting ... [2015-12-3010:15:47,388][INFO ][discovery ] [Grim Hunter] elasticsearch/fnXUCLOQQBiC1aR7hhB82Q [2015-12-3010:15:50,442][INFO ][cluster.service ] [Grim Hunter] new_master {Grim Hunter}{fnXUCLOQQBiC1aR7hhB82Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received) [2015-12-3010:15:50,491][INFO ][node ] [Grim Hunter] started [2015-12-3010:15:50,526][INFO ][gateway ] [Grim Hunter] recovered [0] indices into cluster_state