opensearch/openseach dashboards を fedora にインストールする。証明書には Let’s Encrypt を利用する。
Opensearch の利用目的であるが、parsedmarc 経由で DMARC レポートを Opensearch に取り込み grafana で可視化を行うことである。
ここでは、Dashboards にログインできるところまで。
ドキュメント
以下の公式ページを参照のこと。
- https://opensearch.org/docs/latest/install-and-configure/install-opensearch/rpm/
- https://opensearch.org/downloads.html
リポジトリ設定
以下のコマンドを実行してリポジトリを設定する。
# cd /etc/yum.repos.d/
# wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/opensearch-2.x.repo
# wget https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.x/opensearch-dashboards-2.x.repo
つづいて以下のコマンドを実行して正しく設定されていることを確認しておく。
dnf clean all
dnf repolist
dnf list opensearch --showduplicates
Opensearch のインストール
インストール
以下のシェルを作成し実行する。
#!/bin/sh
OPENSEARCH_INITIAL_ADMIN_PASSWORD=l5YklcBDGj
export OPENSEARCH_INITIAL_ADMIN_PASSWORD
dnf -y install opensearch
あとで admin のパスワードは変更するので、上記の環境変数は不要かもしれない。
Let’s Encrypt サーバ証明書のコピーと秘密鍵の変換
Let’s Encrypt のサーバ証明書を /etc/opensearch にコピーする。
# cd /etc/opensearch
# \rm -rf isrgrootx1.pem
# \rm -rf privkey-pkcs8.pem
# cp /etc/letsencrypt/live/example.com/fullchain.pem .
# openssl pkcs8 -topk8 -nocrypt -in /etc/letsencrypt/live/example.com/privkey.pem \
-out ./privkey-pkcs8.pem
# curl -SL https://letsencrypt.org/certs/isrgrootx1.pem > isrgrootx1.pem
# chown opensearch:opensearch *.pem
Opensearch の設定
/etc/opensearch/opensearch.yml の設定
network.host: 0.0.0.0
discovery.type: single-node
plugins.security.disabled: false
plugins.security.ssl.transport.pemcert_filepath: fullchain.pem
plugins.security.ssl.transport.pemkey_filepath: privkey-pkcs8.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: isrgrootx1.pem
plugins.security.ssl.http.pemcert_filepath: fullchain.pem
plugins.security.ssl.http.pemkey_filepath: privkey-pkcs8.pem
plugins.security.ssl.http.pemtrustedcas_filepath: isrgrootx1.pem
plugins.security.authcz.admin_dn: ['CN=example.com']
plugins.security.nodes_dn: ['CN=example.com']
/etc/opensearch/jvm.options の設定
#-Xms1g
#-Xmx1g
-Xms4g
-Xmx4g
ユーザ登録
ユーザは、/etc/opensearch/opensearch-security/internal_users.yml に登録する。
設定するパスワードの生成。以下のスクリプトを実行する。
#!/bin/sh
OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk
export OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk
sh /usr/share/opensearch/plugins/opensearch-security/tools/hash.sh -p password
表示されたハッシュ値を internal_users.yml に設定する。
admin:
hash: "上記で生成したハッシュ値"
admin 以外のデモ ID を削除する。
また、opensearch dashboards の接続に利用する参照用のユーザを登録しておく。(パスワードは上記の hash.sh コマンドで作成する。
internal_user.yml のシステムへの反映
internal_user.yml を変更した場合は、システムへの反映を行う必要がある。以下のシェルスクリプトを実行する。なお、以下のコマンドを実行した場合、GUI で登録したユーザはなくなるようなので注意。
#!/bin/sh
OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk
export OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk
cd /usr/share/opensearch/plugins/opensearch-security/tools
./securityadmin.sh -cd /etc/opensearch/opensearch-security/ \
-cacert /etc/opensearch/isrgrootx1.pem \
-cert /etc/opensearch/fullchain.pem \
-key /etc/opensearch/privkey-pkcs8.pem \
-icl -nhnv -t internalusers \
-icl -nhnv -cacert /etc/opensearch/isrgrootx1.pem \
-cert /etc/opensearch/fullchain.pem \
-key /etc/opensearch/privkey-pkcs8.pem
firewalldの設定
tcp の 9200 番ポートをとおしておく。
自動起動設定
# systemctl daemon-reload
# systemctl status opensearch
# systemctl enable opensearch
# systemctl start opensearch
# systemctl status opensearch
接続テスト
opensearch.example.com という名前が解決できるようにしておく。
以下のコマンドを実行して、情報が表示されることを確認する。
curl -XGET https://localhost:9200 -u 'admin:password' --insecure
curl -XGET "https://localhost:9200/_cat/plugins?v" -u 'admin:password' --insecure
curl -XGET "https://opensearch.example.com:9200/_cat/plugins?v" -u 'admin:password' --insecure
curl -XGET "https://opensearch.example.com:9200/_cat/plugins?v" -u 'admin:password'
以下のコマンドではエラーになることを確認する。
curl -XGET https://localhost:9200 -u 'admin:password'
curl -XGET "https://localhost:9200/_cat/plugins?v" -u 'admin:password'
Opensearch Dashboards のインストール
インストール
以下のコマンドを実行する。
# dnf -y install opensearch-dashboards
Opensearch Dashboards の設定
/etc/opensearch-dashboards/opensearch_dashboards.yml の設定
server.port: 5601
server.host: opensearch.example.com
server.ssl.enabled: true
server.ssl.certificate: /etc/opensearch-dashboards/fullchain.pem
server.ssl.key: /etc/opensearch-dashboards/privkey-pkcs8.pem
opensearch.hosts: [https://opensearch.example.com:9200]
opensearch.ssl.verificationMode: full
opensearch.username: opensearch-ds
opensearch.password: "password"
証明書のコピーおよびアクセス権設定
# cp /etc/opensearch/fullchain.pem /etc/opensearch-dashboards
# cp /etc/opensearch/privkey-pkcs8.pem /etc/opensearch-dashboards
# chown opensearch-dashboards:opensearch-dashboards /etc/opensearch-dashboards/*.pem
# chmod 660 /etc/opensearch-dashboards/*.pem
自動起動の設定
# systemctl daemon-reload
# systemctl status opensearch-dashboards
# systemctl enable opensearch-dashboards
# systemctl start opensearch-dashboards
# systemctl status opensearch-dashboards
firewalld の設定
firewalld で tcp のポート番号 5601 をとおしておく。
ブラウザでの接続
ブラウザで以下の URL にアクセスする。
http://ip-address:5601/
ユーザは admin、パスワードは先ほど設定したものでログインする。
2024/04/18 ログインできるところまで。
コメント