本日、クラウドサーバ上で、ソースパッケージをダウンロードしてElasticsearchを認証設定付きでデプロイ完了した後、以下のコマンドを実行してElasticsearchのSQLを入力し、SQL文を実行しようと思います:
bin/elasticsearch-sql-cli uri=http://elastic:ESabc+2333@...2:9200/
bin/elasticsearch-sql-cli./x-pack-env: No such file or directoryしかし、実行後、ログインの使用は、エラープロンプト、不可解な、その後、スクリプトをチェックすることがわかり、内容は次のとおりです:
#!/bin/bash
# Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
source "`dirname "$0"`"/elasticsearch-env
source "`dirname "$0"`"/x-pack-env
CLI_JAR=$(ls $ES_HOME/bin/elasticsearch-sql-cli-*.jar)
exec \
"$JAVA" \
-jar "$CLI_JAR" \
"$@"
source "`dirname "$0"`"/x-pack-env有効な行の1つ、2行目の , が実行に問題があるようです。おそらく、依存関係のインポートが有効になったときにパスが見つからないためだと思われます。少しいじった後、その行を以下のコマンドに置き換えることで問題は解決しました:
# source "`dirname "$0"`"/x-pack-env
source /usr/share/elasticsearch/bin/x-pack-env
導入した依存関係のパスを記述し、x-pack-envを使用する際に実際のパスに従ってx-pack-envのパスを変更するだけです。
修正後、先ほどのコマンドで再度Elasticsearch SQLを起動すると、完璧なエンディングで正常に入力されます。
bin/elasticsearch-sql-cliさらに情報を探したところ、この問題はElasticsearch 7.4の小さなバグで、Elasticsearch 7.8のパッケージではスクリプトの内容が変更されていることがわかりました:
#!/bin/bash
# Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
source "`dirname "$0"`"/elasticsearch-env
source "$ES_HOME"/bin/x-pack-env
CLI_JAR=$(ls "$ES_HOME"/bin/elasticsearch-sql-cli-*.jar)
exec \
"$JAVA" \
"$XSHARE" \
-jar "$CLI_JAR" \
"$@"
つまり、Elasticsearch 7.8のインストール時にOS環境変数に$ES_HOMEが正しく設定されていれば、普通にElasticsearch SQLを起動することができます。これは製品スクリプトを修正するよりもはるかに標準的です。




