Elasticsearch+Hadoopベースの大規模検索基盤大解剖
| 既読日 | No | 記事日付 | 内容 |
|---|---|---|---|
| 2 | 2015.07.29 | ElasticsearchとKuromojiを使った形態素解析とN-Gramによる検索の適合率と再現率の向上 | |
| 2021.10.31 | 1 | 2015.07.08 | リクルート全社検索基盤のアーキテクチャ、採用技術、開発体制はどうなっているのか |
※ 次回記事:UWPアプリ開発の最前線
学習リンク
| 既読日 | No | 記事日付 | 内容 |
|---|---|---|---|
| 2 | 2015.07.29 | ElasticsearchとKuromojiを使った形態素解析とN-Gramによる検索の適合率と再現率の向上 | |
| 2021.10.31 | 1 | 2015.07.08 | リクルート全社検索基盤のアーキテクチャ、採用技術、開発体制はどうなっているのか |
| 既読日 | No | 内容 |
|---|---|---|
| 2021.10.18 | 1 | Elasticsearchを用いた日本語検索システムの理論と設定 |
| No | 日付 | タイトル |
|---|---|---|
| 7 | 2019.11.01 | Twitterのつぶやき履歴を集めてみる 3 |
| 6 | 2019.10.14 | Twitterのつぶやき履歴を集めてみる 2 |
| 5 | 2019.10.10 | Twitterのつぶやき履歴を集めてみる 1 |
| 4 | 2019.10.10 | インストール 3 |
| 3 | 2019.10.09 | インストール 2 |
| 2 | 2019.10.09 | インストール 1 |
| 1 | 2019.10.09 | 基本 |
user@user-pc:~$ sudo systemctl start elasticsearch.service Job for elasticsearch.service failed because the control process exited with error code. See "systemctl status elasticsearch.service" and "journalctl -xe" for details.おそらく "apt upgrade -y" でシステム全更新したのが原因と思われる。
user@user-pc:~$ systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-09-04 16:39:00 JST; 2min 11s ago
Docs: https://www.elastic.co
Process: 13533 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1>
Main PID: 13533 (code=exited, status=1/FAILURE)
9月 04 16:38:59 user-pc systemd-entrypoint[13533]: at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
9月 04 16:38:59 user-pc systemd-entrypoint[13533]: at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
9月 04 16:38:59 user-pc systemd-entrypoint[13533]: at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareComman>
9月 04 16:38:59 user-pc systemd-entrypoint[13533]: at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
9月 04 16:38:59 user-pc systemd-entrypoint[13533]: at org.elasticsearch.cli.Command.main(Command.java:90)
9月 04 16:38:59 user-pc systemd-entrypoint[13533]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
9月 04 16:38:59 user-pc systemd-entrypoint[13533]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
9月 04 16:39:00 user-pc systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
9月 04 16:39:00 user-pc systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
9月 04 16:39:00 user-pc systemd[1]: Failed to start Elasticsearch.
Elasticsearchのログ(/var/log/elasticsearch/elasticsearch.log)を見てみる。[2020-09-04T16:38:59,553][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [user-pc] fatal error in thread [main], exiting java.lang.NoSuchMethodError: org.elasticsearch.index.mapper.MappedFieldType: method 'void原因不明のため、とりあえず "apt-get install elasticsearch=7.8.0" で 元々のバージョン Elasticsearch 7.8.0 にバージョンダウンしてみる。()' not found at org.codelibs.elasticsearch.minhash.index.mapper.MinHashFieldMapper$MinHashFieldType. (MinHashFieldMapper.java:144) ~[?:?] at org.codelibs.elasticsearch.minhash.index.mapper.MinHashFieldMapper$Defaults. (MinHashFieldMapper.java:62) ~[?:?] at org.codelibs.elasticsearch.minhash.index.mapper.MinHashFieldMapper$Builder. (MinHashFieldMapper.java:79) ~[?:?] at org.codelibs.elasticsearch.minhash.index.mapper.MinHashFieldMapper$TypeParser.parse(MinHashFieldMapper.java:107) ~[?:?] at org.elasticsearch.index.mapper.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:319) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.index.mapper.ObjectMapper$TypeParser.parseObjectOrDocumentTypeProperties(ObjectMapper.java:237) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.index.mapper.RootObjectMapper$TypeParser.parse(RootObjectMapper.java:141) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:108) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:88) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:421) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:377) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:355) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.cluster.metadata.MetadataIndexUpgradeService.checkMappingsCompatibility(MetadataIndexUpgradeService.java:188) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.cluster.metadata.MetadataIndexUpgradeService.upgradeIndexMetadata(MetadataIndexUpgradeService.java:92) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.gateway.GatewayMetaState.upgradeMetadata(GatewayMetaState.java:247) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.gateway.GatewayMetaState.upgradeMetadataForNode(GatewayMetaState.java:230) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.gateway.GatewayMetaState.start(GatewayMetaState.java:161) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.node.Node.start(Node.java:786) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:317) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:402) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) ~[elasticsearch-cli-7.9.1.jar:7.9.1] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.9.1.jar:7.9.1] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.9.1.jar:7.9.1] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.9.1.jar:7.9.1]
root@user-pc:/var/log/elasticsearch# apt-get install elasticsearch=7.8.0 パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 以下のパッケージが自動でインストールされましたが、もう必要とされていません: libfprint-2-tod1 libllvm9 これを削除するには 'apt autoremove' を利用してください。 以下のパッケージは「ダウングレード」されます: elasticsearch アップグレード: 0 個、新規インストール: 0 個、ダウングレード: 1 個、削除: 0 個、保留: 0 個。 319 MB 中 0 B のアーカイブを取得する必要があります。 この操作後に 111 kB のディスク容量が解放されます。 続行しますか? [Y/n] y dpkg: 警告: elasticsearch を 7.9.1 から 7.8.0 にダウングレードしています (データベースを読み込んでいます ... 現在 202389 個のファイルとディレクトリがインストールされています。) .../elasticsearch_7.8.0_amd64.deb を展開する準備をしています ... elasticsearch (7.8.0) で (7.9.1 に) 上書き展開しています ... elasticsearch (7.8.0) を設定しています ... 新バージョンの設定ファイル /etc/elasticsearch/log4j2.properties をインストールしています ... Created elasticsearch keystore in /etc/elasticsearch/elasticsearch.keystore systemd (245.4-4ubuntu3.2) のトリガを処理しています ...Elasticsearchのサービスを起動してみる。
user@user-pc:~$ sudo systemctl start elasticsearch.service
[sudo] user のパスワード:
user@user-pc:~$ systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-09-04 17:02:06 JST; 15s ago
Docs: https://www.elastic.co
Main PID: 14152 (java)
Tasks: 82 (limit: 4656)
Memory: 1.3G
CGroup: /system.slice/elasticsearch.service
├─14152 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative>
└─14356 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
9月 04 17:01:44 user-pc systemd[1]: Starting Elasticsearch...
9月 04 17:02:06 user-pc systemd[1]: Started Elasticsearch.
lines 1-13/13 (END)
Fessのサービスを起動してみる。user@user-pc:~$ sudo systemctl start fess.service
user@user-pc:~$ systemctl status fess.service
● fess.service - Fess
Loaded: loaded (/lib/systemd/system/fess.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-09-04 17:02:44 JST; 12s ago
Docs: http://fess.codelibs.org/
Main PID: 14429 (java)
Tasks: 32 (limit: 4656)
Memory: 608.4M
CGroup: /system.slice/fess.service
└─14429 /bin/java -Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m -XX:CompressedClassSpaceSize=32m -Djava.awt.headless=true -Dhttp>
9月 04 17:02:44 user-pc systemd[1]: Started Fess.
output {
stdout {
codec => rubydebug
}
elasticsearch {
hosts => "http://localhost:9200/"
}
}
Elasticsearchの起動は : 省略
{
"@version" => "1",
"path" => "d:/temp/20191011/CSV/work191010.csv",
"host" => "DESKTOP-37HDMPE",
"@timestamp" => 2019-10-31T08:13:09.688Z,
"tags" => [
[0] "csv"
],
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\""
}
filter {
csv {
}
}
この状態でlogstashを起動するとコンソールにCSVの内容が表示される : 省略
{
"tags" => [
[0] "csv"
],
"@version" => "1",
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\"",
"column1" => "1182187647629873152",
"@timestamp" => 2019-10-31T22:31:34.928Z,
"path" => "d:/temp/20191011/CSV//work191010.csv",
"host" => "DESKTOP-37HDMPE",
"column2" => "191010 155433",
"column3" => "テスト"
}
不要な項目(フィールド)を消したい場合は remove_fieldオプションを指定 "remove_field => [フィールド名,…]"filter {
csv {
remove_field => ["column1","host","path"]
}
}
出力結果{
"column2" => "191010 155433",
"@version" => "1",
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\"",
"tags" => [
[0] "csv"
],
"@timestamp" => 2019-10-31T22:42:03.559Z,
"column3" => "テスト"
}
@timestampはLogstashがデータを取り込んだ時間。filter {
csv {
convert => {
"column2" => "date_time"
}
remove_field => ["column1","host","path"]
}
date {
match => [ "column2", "YYMMdd HHmmss" ]
}
}
出力結果{
"column2" => "191010 155433",
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\"",
"@timestamp" => 2019-10-10T06:54:33.000Z,
"@version" => "1",
"column3" => "テスト",
"tags" => [
[0] "csv"
]
}
input{
file{
path => "d:/temp/20191011/csv//*.CSV"
start_position => "beginning"
tags => "csv"
}
}
output{
stdout{ codec => rubydebug }
}
そういうものか、ということで先に進む。input{
利用するプラグイン名{
設定を記載
}
}
input{
file{
path => "/フォルダのフルパス/logs/**.csv"
}
}
output{
stdout{ codec => rubydebug }
}
input{
file{
path => "d:\temp\20191011\csv\**.csv"
start_position => "beginning"
tags => "csv"
}
}
output{
stdout{ codec => rubydebug }
}
C:\Windows\system32>cd /d c:\apps\logstash-7.4.0 c:\apps\logstash-7.4.0>.\bin\logstash.bat -f .\config\logstash.conf→ コンソールにCSVデータが出力される、らしいが出ない…
[2019-10-11T17:03:53,279][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
#elasticsearch.hosts: ["http://localhost:9200"]↓
elasticsearch.hosts: ["http://localhost:9200"]
input {
stdin { }
}
output {
stdout { codec => rubydebug }
}
D:\>cd /d c:\apps\logstash-7.4.0 c:\apps\logstash-7.4.0>.\bin\logstash -f .\config\logstash.confしばらく待つと Successfully started Logstash API endpoint の表示で待機となる。
Thread.exclusive is deprecated, use Thread::Mutex
Sending Logstash logs to c:/apps/logstash-7.4.0/logs which is now configured via log4j2.properties
[2019-10-10T12:23:46,021][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2019-10-10T12:23:46,039][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.4.0"}
[2019-10-10T12:23:48,327][INFO ][org.reflections.Reflections] Reflections took 48 ms to scan 1 urls, producing 20 keys and 40 values
[2019-10-10T12:23:51,869][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge][main] A gauge metric of an unknown type (org.jruby.RubyArray) has been create for key: cluster_uuids. This may result in invalid serialization. It is recommended to log an issue to the responsible developer/development team.
[2019-10-10T12:23:51,877][INFO ][logstash.javapipeline ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>500, :thread=>"#"}
[2019-10-10T12:23:52,014][INFO ][logstash.javapipeline ][main] Pipeline started {"pipeline.id"=>"main"}
The stdin plugin is now waiting for input:
[2019-10-10T12:23:52,124][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2019-10-10T12:23:52,518][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
適当に "hello world" と入力してみるhello world
C:/apps/logstash-7.4.0/vendor/bundle/jruby/2.5.0/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
{
"message" => "hello world\r",
"@version" => "1",
"host" => "DESKTOP-37HDMPE",
"@timestamp" => 2019-10-10T03:26:16.934Z
}
とりあえず問題なし?と思われるC:\Windows\system32>java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
# Xms represents the initial size of total heap space # Xmx represents the maximum size of total heap space -Xms1g -Xmx1g
[INFO ][o.e.x.s.s.SecurityStatusChangeListener] [DESKTOP-37HDMPE] Active license is now [BASIC]; Security is disabledから動かなくなったので、おそらく起動完了
{
"name" : "DESKTOP-37HDMPE",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "2Nl7BGrzRM-qwq8P8NhAng",
"version" : {
"number" : "7.4.0",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "22e1767283e61a198cb4db791ea66e3f11ab9910",
"build_date" : "2019-09-27T08:36:48.569419Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}