0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GCP上のUbuntu14.04環境でElasticsearchが動くまで

Posted at

#GCP上のUbuntu環境を確認
何を目的で作ったのかは覚えてないけど、GCP上の環境を使いまわすことにした。
バージョンは14.04とのこと。

user1@ubuntu-trusty-1:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

#Javaをインストール
まずJavaをインストールしてバージョンを確認

user1@ubuntu-trusty-1:~$ curl -O https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz
$gzip -d *.tar.gz
$tar xvf *.tar

user1@ubuntu-trusty-1:~$ java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

環境変数PATH, JAVA_HOMEを設定。ここを参照

user1@ubuntu-trusty-1:~$ echo $JAVA_HOME
/opt/jdk-11.0.2
user1@ubuntu-trusty-1:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/jdk-11.0.2/bin:/opt/jdk-11.0.2/bin

#Elasticsearchをインストール
やりたいことを実現するにはKibana、Logstashも必要だけど、まずはElasticsearchだけでも動くのが確認できてから。
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
こちらの手順どおりにインストール。

#Elasticsearchを起動。
サービスからの起動を試みる。
https://www.elastic.co/guide/en/elasticsearch/reference/7.0/deb.html
ここの手順に従うが、動かん…。

user1@ubuntu-trusty-1:~$ sudo -i service elasticsearch start
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

user1@ubuntu-trusty-1:~$ su -
Password: 

root@ubuntu-trusty-1:~# echo $JAVA_HOME
/opt/jdk-11.0.2

root@ubuntu-trusty-1:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jdk-11.0.2/bin

root@ubuntu-trusty-1:~# java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

root@ubuntu-trusty-1:~# which java
/opt/jdk-11.0.2/bin/java

良くわからなかったんだけどserviceコマンドに引き継がれる環境変数は、LANGとTERMだけなんだと。

#以下man serviceの結果抜粋
ENVIRONMENT
       LANG, TERM
              The only environment variables passed to the init scripts.

/etc/init.d/elsaticsearchの中にも、以下のように$PATHが定義されている。

PATH=/bin:/usr/bin:/sbin:/usr/sbin

###これで解決するかな。
tarをダウンロードするのでなく、openJDKもaptでインストールする。

user1@ubuntu-trusty-1:~$ sudo apt install openjdk-11-jdk

#途中省略

user1@ubuntu-trusty-1:~$ which java
/usr/bin/java
user1@ubuntu-trusty-1:~$ java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-3ubuntu114.04ppa1)
OpenJDK 64-Bit Server VM (build 11.0.1+13-Ubuntu-3ubuntu114.04ppa1, mixed mode, sharing)

/usr/binのJavaが読まれるようになった。

user1@ubuntu-trusty-1:~$ sudo -i service elasticsearch start

#途中省略

user1@ubuntu-trusty-1:~$ curl http://localhost:9200/
{
  "name" : "ubuntu-trusty-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "DrHFfTLZQqacs6qOqblyag",
  "version" : {
    "number" : "7.0.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "b7e28a7",
    "build_date" : "2019-04-05T22:55:32.697037Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.7.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

解決。動いた…。時間かかった…。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?