7.13.0をインストールしてほったらかしにしてあったElasticsearchと、Kibana、Logstashをアップグレードする。
Elasticsearchの新しいバージョンにアップグレードするときは、ElasticStack内の各製品をアップグレードする必要がある。Kibanaは、Elasticsearchとバージョンを合わせる必要がある。BeatsとLogstash6.7は、Elasticsearch7.14.0と互換性があり、アップグレードのスケジュールを柔軟に設定できる。
マイナーバージョン間のアップグレードなので、Elasticsearchはローリングアップグレードできるのでサービはスの停止が不要。Kibanaはローリングアップグレードをサポートしていないので、複数のKibanaインスタンスを実行している場合は、アップグレードする前にすべてのインスタンスを停止する必要がある。
参考にしたページ
Elasticsearchのローリングアップグレード
- ローリングアップグレードでは、Elasticsearchクラスターを一度に1ノードずつアップグレードできるため、アップグレードによってサービスが中断されない
- アップグレードされたノードから古いバージョンを実行しているノードにシャードを複製できないため、アップグレードの期間を超えて同じクラスターでElasticsearchの複数のバージョンを実行することはサポートされていない
- ローリングアップグレードは、マイナーバージョン間、5.6から6.8、6.8から7.14.0まででサポートされている
- 6.7以前から7.14.0に直接アップグレードするには、クラスターを完全に再起動する必要がある
Elasticsearchのアップグレード
- 単一ノードなので、Elasticsearchを停止して、新しいバージョンのRPMパッケージをインストールする。(すべてのファイルはオペレーティングシステムの適切な場所にインストールされ、Elasticsearchの設定ファイルは上書きされない)
$ sudo systemctl stop elasticsearch.service
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.0-x86_64.rpm
$wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.0-x86_64.rpm.sha512
$ shasum -a 512 -c elasticsearch-7.14.0-x86_64.rpm.sha512
$ sudo rpm --upgrade elasticsearch-7.14.0-x86_64.rpm
インストールが終わると、以下のメッセージが表示された。
Created elasticsearch keystore in /etc/elasticsearch/elasticsearch.keystore
[/usr/lib/tmpfiles.d/elasticsearch.conf:1] Line references path below legacy directory /var/run/, updating /var/run/elasticsearch → /run/elasticsearch; please update the tmpfiles.d/ drop-in file accordingly.
言われたとおりに、/usr/lib/tmpfiles.d/elasticsearch.confを更新する。
$ sudo systemctl start elasticsearch.service
$ curl -X GET "localhost:9200/?pretty"
{
"name" : "hyakushiki",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "JOihVTGCTwarfpDON6J-Sw",
"version" : {
"number" : "7.14.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1",
"build_date" : "2021-07-29T20:49:32.864135063Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Kibanaのアップグレード
- 単一のインスタンスしか起動していないので、Kibanaを停止して、新しいバージョンのRPMパッケージをインストールする。
$ sudo systemctl stop kibana.service
$ wget https://artifacts.elastic.co/downloads/kibana/kibana-7.14.0-x86_64.rpm
$ shasum -a 512 kibana-7.14.0-x86_64.rpm
$ sudo rpm --upgrade kibana-7.14.0-x86_64.rpm
$ sudo systemctl start kibana.service
Weブラウザで、Kibanaを実行しているマシンの5601番ポートへアクセスする。たとえば、http://localhost:5601またはhttp://HOSTNAME:5601、http://127.0.0.1:5601
Logstashのアップグレード
- マイナーバージョン間のアップグレードは、新しいリリースをインストールしてLogstashを再起動するだけでできる。Logstashは通常、構成設定とエクスポートされたフィールドの下位互換性を維持する
- RPMパッケージをダウンロードしてインストールする。
$ curl -L -0 https://artifacts.elastic.co/downloads/logstash/logstash-7.14.0-x86_64.rpm --output ./logstash-7.14.0-x86_64.rpm
$ sudo rpm -Uvh logstash-7.14.0-x86_64.rpm
$ sudo /usr/share/logstash/bin/logstash -e 'input { stdin { } } output { stdout {} }'
Using bundled JDK: /usr/share/logstash/jdk
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/bundler-1.17.3/lib/bundler/rubygems_integration.rb:200: warning: constant Gem::ConfigMap is deprecated
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
[INFO ] 2021-08-15 21:29:11.492 [main] runner - Starting Logstash {"logstash.version"=>"7.14.0", "jruby.version"=>"jruby 9.2.19.0 (2.5.8) 2021-06-15 55810c552b OpenJDK 64-Bit Server VM 11.0.11+9 on 11.0.11+9 +indy +jit [linux-x86_64]"}
[WARN ] 2021-08-15 21:29:12.050 [LogStash::Runner] multilocal - Ignoring the 'pipelines.yml' file because modules or command line options are specified
[INFO ] 2021-08-15 21:29:13.922 [Api Webserver] agent - Successfully started Logstash API endpoint {:port=>9600}
[INFO ] 2021-08-15 21:29:14.590 [Converge PipelineAction::Create] Reflections - Reflections took 106 ms to scan 1 urls, producing 120 keys and 417 values
[WARN ] 2021-08-15 21:29:15.507 [Converge PipelineAction::Create] stdin - Relying on default value of `pipeline.ecs_compatibility`, which may change in a future major release of Logstash. To avoid unexpected changes when upgrading Logstash, please explicitly declare your desired ECS Compatibility mode.
[INFO ] 2021-08-15 21:29:16.034 [[main]-pipeline-manager] javapipeline - Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>2, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50,
"pipeline.max_inflight"=>250, "pipeline.sources"=>["config string"], :thread=>"#"}
[INFO ] 2021-08-15 21:29:17.195 [[main]-pipeline-manager] javapipeline - Pipeline Java execution initialization time {"seconds"=>1.16}
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jrubystdinchannel.StdinChannelLibrary$Reader (file:/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/jruby-stdin-channel-0.2.0-java/lib/jruby_stdin_channel/jruby_stdin_channel.jar) to field java.io.FilterInputStream.in
WARNING: Please consider reporting this to the maintainers of com.jrubystdinchannel.StdinChannelLibrary$Reader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO ] 2021-08-15 21:29:18.316 [[main]-pipeline-manager] javapipeline - Pipeline started {"pipeline.id"=>"main"}
The stdin plugin is now waiting for input:
[INFO ] 2021-08-15 21:29:18.407 [Agent thread] agent - Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
Logstashを開始した後、コマンドプロンプトで hello world と入力する
hello world
{
"@version" => "1",
"host" => "hyakushiki",
"message" => "hello world",
"@timestamp" => 2021-08-15T12:33:04.901Z
}
ctrl+DでLogstashを終了する
[INFO ] 2021-08-15 21:34:34.304 [[main]-pipeline-manager] javapipeline - Pipeline terminated {"pipeline.id"=>"main"}
[INFO ] 2021-08-15 21:34:34.394 [Converge PipelineAction::Delete<main>] pipelinesregistry - Removed pipeline from registry successfully {:pipeline_id=>:main}
[INFO ] 2021-08-15 21:34:34.465 [LogStash::Runner] runner - Logstash shut down.