2016-07-30 136 views
10

我最近將我的機器從Ubuntu 14.04升級到16.04。我面臨使用elasticsearch作爲服務的問題。我installedelasticsearch使用:無法在ubuntu中啓動elasticsearch作爲服務16.04

sudo apt-get install elasticsearch 

現在sudo service elasticsearch status命令顯示了我這樣的結果:

elasticsearch.service - LSB: Starts elasticsearch 
    Loaded: loaded (/etc/init.d/elasticsearch; bad; vendor preset: enabled) 
    Active: active (exited) since Sat 2016-07-30 18:28:13 BDT; 1h 19min ago 
    Docs: man:systemd-sysv-generator(8) 
Main PID: 7988 (code=exited, status=1/FAILURE) 
    CGroup: /system.slice/elasticsearch.service 

Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found 
Jul 30 18:28:13 dimik systemd[1]: Started LSB: Starts elasticsearch. 
Jul 30 18:28:46 dimik systemd[1]: Started LSB: Starts elasticsearch. 
Jul 30 18:35:30 dimik systemd[1]: Started LSB: Starts elasticsearch. 
Jul 30 19:04:36 dimik systemd[1]: Started A search engine. 
Jul 30 19:07:48 dimik systemd[1]: Started A search engine. 
Jul 30 19:27:01 dimik systemd[1]: Started A search engine. 
Jul 30 19:27:51 dimik systemd[1]: Started A search engine. 
Jul 30 19:28:54 dimik systemd[1]: Started A search engine. 
Jul 30 19:29:18 dimik systemd[1]: Started LSB: Starts elasticsearch. 

雖然Java是安裝在我的機器,我可以使用這個命令來啓動服務器。

sudo /usr/share/elasticsearch/bin/elasticsearch 

我有點卡在這裏。任何幫助將不勝感激。

編輯

根建立JAVA_HOME錯誤後:

elasticsearch.service - LSB: Starts elasticsearch 
    Loaded: loaded (/etc/init.d/elasticsearch; bad; vendor preset: enabled) 
    Active: active (exited) since Sat 2016-07-30 18:28:13 BDT; 3h 32min ago 
    Docs: man:systemd-sysv-generator(8) 
Main PID: 7988 (code=exited, status=1/FAILURE) 
    CGroup: /system.slice/elasticsearch.service 

Jul 30 18:35:30 dimik systemd[1]: Started LSB: Starts elasticsearch. 
Jul 30 19:04:36 dimik systemd[1]: Started A search engine. 
Jul 30 19:07:48 dimik systemd[1]: Started A search engine. 
Jul 30 19:27:01 dimik systemd[1]: Started A search engine. 
Jul 30 19:27:51 dimik systemd[1]: Started A search engine. 
Jul 30 19:28:54 dimik systemd[1]: Started A search engine. 
Jul 30 19:29:18 dimik systemd[1]: Started LSB: Starts elasticsearch. 
Jul 30 20:02:07 dimik systemd[1]: Started LSB: Starts elasticsearch. 
Jul 30 20:20:21 dimik systemd[1]: Started LSB: Starts elasticsearch. 
Jul 30 21:59:21 dimik systemd[1]: Started LSB: Starts elasticsearch. 
+0

Lokks像javapath沒有爲根 – Jens

+0

Java的路徑設置設置爲我可以看到。 'echo $ JAVA_HOME'產生路徑 –

+0

另外如果你做sudo echo $ JAVA_HOME? – Jens

回答

24

我發現這個問題的解決方案。解決方案來自彈性網站上的此討論線索Can’t start elasticsearch with Ubuntu 16.04。在編輯

It seems that to get Elasticsearch to run on 16.04 you have to set START_DAEMON to true on /etc/default/elasticsearch . It comes commented out by default, and uncommenting it makes Elasticsearch start again just fine.

Be sure to use systemctl restart instead of just start because the service is started right after installation, and apparently there's some socket/pidfile/something that systemd keeps that must be released before being able to start the service again.

+0

不適用於我們。不過,我們可以用'/ usr/share/elasticsearch/bin/elasticsearch'手動運行它。嗯。 –

+0

有些東西只是關於Ubuntu軟件包。即使啓用守護進程並設置權限,它也不會通過systemd啓動。你必須去elastic.co來獲得工作包。沒有日誌文件,一個空pid文件,沒有journalctl輸出,這使得調試非常困難。 –

2
  1. 打開/etc/init.d/elasticsearch文件,下面的註釋行

    . /usr/share/java-wrappers/java-wrappers.sh 
    find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default 
    

    設置JAVA_HOME手動像這樣:

    export JAVA_HOME="/usr" 
    
  2. 服務elasticsearch啓動

+0

除了要點說明外,您還應詳細說明如何幫助解決問題。 –

+0

我已經發布了一個解決方案。你的回答沒有詳細說明或給出更好的選擇。 –

4

問題在於日誌文件,「沒有找到Java運行時。」

Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found 

這是我對問題的解決方案。

  1. 檢查elasticsearch init文件

    須藤納米/etc/init.d/elasticsearch

搜索

. /usr/share/java-wrappers/java-wrappers.sh 
find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default 
export JAVA_HOME 
  • 檢查java-wrappers.sh文件

    sudo nano/usr/share/java-wrappers/java-wrappers。SH

  • 現在你可以看到警告來自

    #Displays a warning 
    java_warning() { 
        echo "[warning] $0: [email protected]" >&2; 
    } 
    
  • 不知何故,JAVA目錄未列jvm-list.sh文件
  • 現在編輯jvm-list.sh文件

    sudo nano /usr/lib/java-wrappers/jvm-list.sh 
    

    編輯行加入你的java目錄中的文件,在我的情況下,添加/ usr/lib目錄/ JVM/java的8神諭*

    __jvm_oracle8="/usr/lib/jvm/jdk-8-oracle-* /usr/lib/jvm/jre-8-oracle-* /usr/lib/jvm/java-8-oracle*" 
    
  • 現在重新啓動該服務,並檢查elasticsearch服務

    須藤systemctl重啓elasticsearch
    須藤systemctl elasticsearch狀態
    捲曲-X GET 「http://localhost:9200

  • 希望這會有所幫助

    +0

    這有幫助。我不確定爲什麼'/ usr/lib/jvm/java-8-oracle'不在我的jvm-list.sh文件中,但這是我的問題。 –

    0

    我的問題是不同的,我以root用戶身份手動啓動elasticsearch,因此創建了一些文件,但elasticsearch用戶無法在其上編寫它。

    您可以試運行手動elasticsearch:

    sudo -u elasticsearch /usr/share/elasticsearch/bin/elasticsearch \ 
    -Des.default.config=/etc/elasticsearch/elasticsearch.yml \ 
    -Des.default.path.home=/usr/share/elasticsearch \ 
    -Des.default.path.logs=/var/log/elasticsearch \ 
    -Des.default.path.data=/var/lib/elasticsearch \ 
    -Des.default.path.work=/tmp/elasticsearch \ 
    -Des.default.path.conf=/etc/elasticsearch 
    

    要解決我的機器上我不得不這樣做:

    rm -rf /var/log/elasticsearch/* 
    rm -rf /var/lib/elasticsearch/*