Oracle Cloud で無料の SPARQL エンドポイント構築
LOD Challenge 2022
無料環境のご案内(ステップ1:メールで事前申し込み)
この度は「Oracle Cloud で無料の SPARQL エンドポイント構築」にご参加いただき、ありがとうございます。本セミナーに参加いただいた方には Oracle Cloud のイベント用のアカウントをご提供しております。通常のアカウント登録でも同様の無料環境は使えますが、今回はクレジットカード情報を登録することなく無料環境を継続的にご利用いただけます。ご希望の方は下記の宛先までメールにてご連絡ください。ご提供いただきました個人情報は、このアカウントを利用できるにするための弊社システムへの登録のために利用させていただきます。
�宛先: yusuke.matsui@oracle.com(こちらのリンクに下記件名を含んでいます)�件名: Oracle Cloud で無料の SPARQL エンドポイント構築�本文: お名前/ご所属/メールアドレスをご記載ください
�*日本オラクル株式会社 個人情報の取り扱いについて� https://www.oracle.com/jp/legal/information-protection/basic-policy/public-notice.html
�日本オラクル株式会社�公共営業統括クラウド営業本部第一営業部�松井雄介
Copyright © 2022, Oracle and/or its affiliates
2
無料環境のご案内(ステップ2:サインアップ)
メールにて事前申し込みいただいた後、メールアドレスが弊社社内システムに登録されると、クレジットカード情報登録なしで無料環境にサインアップできるようになります。
こちらからサインアップにお進みください。
既に Oracle Cloud のアカウントをお持ちの場合には、利用できる無料環境は同じものなので、その環境を用いて本資料の内容をお試しいただくことも可能です。
Copyright © 2022, Oracle and/or its affiliates
3
本資料の内容
無償で使えるAlways Free環境を利用して、
Oracleが提供するRDFグラフのSPARQLエンドポイントからデータロード&クエリ実行を行います。
Copyright © 2022, Oracle and/or its affiliates
4
構成イメージ
Copyright © 2022, Oracle and/or its affiliates
5
トリプルストア
(Autonomous Database)
Compute
RDFグラフ・サーバー
on Weblogic(※)
参照
Oracle Databaseを
トリプルストアとして
利用可能
Oracleが提供する
RDFグラフのSPARQLエンドポイント
RDFグラフ・サーバーが構成されたComputeのイメージが
マーケットプレイスで提供されているため、今回はそれを利用する
※Weblogicの他、Apache Tomcatへのデプロイも可能です。
【参考】Oracle® Database RDFグラフのグラフ開発者ガイド 21c F37759-04(原本部品番号:F31379-11)
作業の流れ
Copyright © 2022, Oracle and/or its affiliates
6
今回デモを行う部分
(必要に応じて)言語設定
Copyright © 2022, Oracle and/or its affiliates
7
Autonomous Database(トリプルストア)の作成①
Copyright © 2022, Oracle and/or its affiliates
8
Autonomous Database(トリプルストア)の作成②
Copyright © 2022, Oracle and/or its affiliates
9
Autonomous Database(トリプルストア)の作成③
Copyright © 2022, Oracle and/or its affiliates
10
任意の名前(本資料ではTRLSTOREとする)
Autonomous Database(トリプルストア)の作成④
Copyright © 2022, Oracle and/or its affiliates
11
DBのパスワード
※後程利用するため、メモしておく
Autonomous Database(トリプルストア)の作成⑤
Copyright © 2022, Oracle and/or its affiliates
12
数分程度で作成完了
ネットワークリソースの作成①
Copyright © 2022, Oracle and/or its affiliates
13
ネットワークリソースの作成②
Copyright © 2022, Oracle and/or its affiliates
14
ネットワークリソースの作成③
Copyright © 2022, Oracle and/or its affiliates
15
ネットワークリソースの作成④
Copyright © 2022, Oracle and/or its affiliates
16
事前にSSHキー・ペアを作成する
以下のドキュメントを参考に、Compute作成時に必要となるSSHキー・ペアを作成しておきます。�
Oracle Cloud Infrastructureドキュメント >キー・ペアの作成�https://docs.oracle.com/ja-jp/iaas/Content/GSG/Tasks/creatingkeys.htm
Copyright © 2022, Oracle and/or its affiliates
17
RDFグラフ・サーバー構築済Computeの作成①
Copyright © 2022, Oracle and/or its affiliates
18
RDFグラフ・サーバー構築済Computeの作成②
Copyright © 2022, Oracle and/or its affiliates
19
「Oracle RDF Graph Server and Query UI」で検索
RDFグラフ・サーバー構築済Computeの作成③
Copyright © 2022, Oracle and/or its affiliates
20
RDFグラフ・サーバー構築済Computeの作成④
Copyright © 2022, Oracle and/or its affiliates
21
任意の名前(本資料では「RDFServer」とする)
RDFグラフ・サーバー構築済Computeの作成⑤
Copyright © 2022, Oracle and/or its affiliates
22
事前に作成しておいた
SSHキー・ペアのPublic Keyを選択
RDFグラフ・サーバー構築済Computeの作成⑥
Copyright © 2022, Oracle and/or its affiliates
23
「ネットワークリソースの作成」で
作成したVCNを選択
Public Subnetを選択
WeblogicのAdmin Passwordを指定
※後程利用するため、メモしておく
WeblogicのAdmin ユーザ名を指定
※後程利用するため、メモしておく
RDFグラフ・サーバー構築済Computeの作成⑦
Copyright © 2022, Oracle and/or its affiliates
24
15分程度で作成完了
作成された環境(Compute)の確認①
Copyright © 2022, Oracle and/or its affiliates
25
作成された環境(Compute)の確認②
Copyright © 2022, Oracle and/or its affiliates
26
アクセス時に使用する
パブリックIPアドレスをメモしておく
ネットワークセキュリティリストの編集①
デフォルトでは22番ポートでのアクセスしか許可されていないため、�RDFグラフ・サーバー用のポート(8001)へのアクセスを許可するようにセキュリティリストを更新します。
> 前ページのComputeインスタンス名をクリック
Copyright © 2022, Oracle and/or its affiliates
27
ネットワークセキュリティリストの編集②
Copyright © 2022, Oracle and/or its affiliates
28
ネットワークセキュリティリストの編集③
Copyright © 2022, Oracle and/or its affiliates
29
Autonomous DatabaseのWalletダウンロード
Copyright © 2022, Oracle and/or its affiliates
30
Walletのパスワードを入力
※後程利用するため、メモしておく
Computeへアクセス(Teratermを使用する場合の例)
Copyright © 2022, Oracle and/or its affiliates
31
「作成された環境(Compute)の確認②」
で確認したComputeのPublic IPアドレス
Compute作成時に指定した
SSHキー・ペアのPrivate Keyファイルを指定
RDFグラフ・サーバーとDBの接続で利用するWalletファイルの編集
Copyright © 2022, Oracle and/or its affiliates
32
-- SCPやTeraterm等のファイル転送機能を利用してファイルをComputeに転送
-- 今回の例では「/tmp」配下に配置
[opc@orardf-server-instance ~]$ ls -l /tmp/Wallet_<DB名>.zip
--データベース・ログイン資格証明を追加したWalletファイルの作成
[opc@orardf-server-instance ~]$ mkdir ~/wallet
[opc@orardf-server-instance ~]$ cd ~/wallet/
[opc@orardf-server-instance wallet]$ unzip /tmp/Wallet_TRLSTORE.zip
[opc@orardf-server-instance wallet]$ export JAVA_HOME=/usr/local/java/jdk1.8.0_221
[opc@orardf-server-instance wallet]$ /u01/app/oracle/middleware/wls12214/oracle_common/bin/mkstore
-wrl /home/opc/wallet -createCredential <DB名>_high ADMIN <DBのパスワード>
> Enter wallet password: <Walletのパスワード>
[opc@orardf-server-instance wallet]$ zip ../wallet_with_cred.zip *
[opc@orardf-server-instance wallet]$ ls -l ../
total 28
drwxrwx---. 6 opc opc 64 Aug 3 17:52 oraInventory
drwxrwxr-x. 2 opc opc 4096 Oct 26 10:33 wallet
-rw-rw-r--. 1 opc opc 22983 Oct 26 10:45 wallet_with_cred.zip
本資料の場合の例。紙面の都合上改行しているが、
実際には一行で入力する
/u01/app/oracle/middleware/wls12214/oracle_common/bin/mkstore
-wrl /home/opc/wallet -createCredential trlstore_high ADMIN passwd01
本資料では「Wallet_TRLSTORE.zip」
本ファイルをダウンロードしておく
RDFグラフ・サーバー起動確認
Copyright © 2022, Oracle and/or its affiliates
33
[opc@orardf-server-instance ~]$ sudo systemctl status wls_orardf
● wls_orardf.service - RDF Domain WebLogic Servers startup
Loaded: loaded (/etc/systemd/system/wls_orardf.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-10-26 11:13:50 GMT; 16s ago
Process: 11699 ExecStart=/u01/app/oracle/domains/orardfDomain/startRdfServerDomain.sh (code=exited, status=0/SUCCESS)
Memory: 259.0M
CGroup: /system.slice/wls_orardf.service
├─11700 /bin/sh /u01/app/oracle/domains/orardfDomain/bin/startNodeManager.sh
├─11701 /bin/sh /u01/app/oracle/domains/orardfDomain/bin/startWebLogic.sh
├─11702 /bin/sh /u01/app/oracle/domains/orardfDomain/bin/startManagedWebLogic.sh ms_1
├─11703 /bin/sh /u01/app/oracle/domains/orardfDomain/bin/startWebLogic.sh nodebug noderby
├─11704 /bin/sh /u01/app/oracle/middleware/wls12214/wlserver/server/bin/startNodeManager.sh
├─11843 /usr/local/java/jdk1.8.0_221/bin/java -server -Xms256m -Xmx512m -cp /u01/app/oracle/middleware/wls12214/wlserver/server/lib/weblogic-launc...
├─11849 /usr/local/java/jdk1.8.0_221/bin/java -Djava.security.manager -Djava.security.policy=/u01/app/oracle/middleware/wls12214/wlserver/common/d...
├─11850 /usr/local/java/jdk1.8.0_221/bin/java -server -Xms32m -Xmx200m -Djdk.tls.ephemeralDHKeySize=2048 -Dcoherence.home=/u01/app/oracle/middlewa...
└─11851 /usr/local/java/jdk1.8.0_221/bin/java -server -Xms256m -Xmx512m -cp /u01/app/oracle/middleware/wls12214/wlserver/server/lib/weblogic-launc...
Oct 26 11:13:50 orardf-server-instance systemd[1]: Starting RDF Domain WebLogic Servers startup...
Oct 26 11:13:50 orardf-server-instance systemd[1]: Started RDF Domain WebLogic Servers startup.
-- 起動していない場合は以下の通り再起動する
[opc@orardf-server-instance ~]$ sudo systemctl stop wls_orardf
[opc@orardf-server-instance ~]$ sudo systemctl start wls_orardf
起動していることを確認する
RDFグラフ・サーバーへアクセス
https://<「作成された環境(Compute)の確認②」で確認したComputeのPublic IPアドレス>:8001/orardf
Copyright © 2022, Oracle and/or its affiliates
34
「RDFグラフ・サーバー構築済Computeの作成⑥」で指定した、
weblogicのAdmin ユーザ名とパスワードを指定
Autonomous Databaseへアクセスするためのデータソース設定
Copyright © 2022, Oracle and/or its affiliates
35
「RDFグラフ・サーバーとDBの接続で利用するWalletファイルの編集」で
作成したWalletファイル「wallet_with_cred.zip」を選択
RDFデータロードの流れ
Copyright © 2022, Oracle and/or its affiliates
36
トリプルストア
(Autonomous Database)
Semantic Network:
SEMNET01
Semantic Network:
SEMNET02
MODEL: EXAMPLE1
MODEL: EXAMPLE2
MODEL: EXAMPLE3
1. Semantic Networkの作成
Copyright © 2022, Oracle and/or its affiliates
37
「Autonomous Databaseへアクセスするためのデータソース設定」で
作成したデータソースを指定
2. Modelの作成
Copyright © 2022, Oracle and/or its affiliates
38
作成したSemantic Networkを指定
3. ファイルをステージング表にアップロード
Copyright © 2022, Oracle and/or its affiliates
39
任意の名前を指定
RDFデータファイルを
選択
【参考】今回ロードしたTurtleファイル
以下のドキュメントに例示されていたTurtleファイルをロードしています。
> W3c RDF 1.1 Turtle: https://www.w3.org/TR/turtle/
Copyright © 2022, Oracle and/or its affiliates
40
@base <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rel: <http://www.perceive.net/schemas/relationship/> .
<#green-goblin>
rel:enemyOf <#spiderman> ;
a foaf:Person ; # in the context of the Marvel universe
foaf:name "Green Goblin" .
<#spiderman>
rel:enemyOf <#green-goblin> ;
a foaf:Person ;
foaf:name "Spiderman", "Человек-паук"@ru .
EXAMPLE1.ttl
4.バルクロードでRDFデータとして取り込み
Copyright © 2022, Oracle and/or its affiliates
41
RDFデータに
4000byte以上の文字列が
含まれる場合は
「<ステージング表>_CLOB」も
同様の手順でバルクロードする必要がある
先ほど作成したModelを指定
5. クエリ実行
Copyright © 2022, Oracle and/or its affiliates
42
可視化も可能
【参考】Oracle RDFモデルの公開
SPARQL問合せのパブリックRESTエンドポイントを介して、�資格証明を入力せずにRDFデータセットがアプリケーションで直接使用できます。
43
【参考】Oracle® Database RDFグラフのグラフ開発者ガイド 21c F37759-04(原本部品番号:F31379-11)
利用イメージ
$ curl -k "https://XXX.XXX.XXX.XXX:8001/orardf/api/v1/datasets/query/published/PUB_EXAMPLE1?query=select+%3Fs+%3Fp+%
3Fo+where+%7B%3Fs+%3Fp+%3Fo%7D+limit+3&format=csv"
S,P,O
http://example.org/#green-goblin,http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://xmlns.com/foaf/0.1/Person
http://example.org/#spiderman,http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://xmlns.com/foaf/0.1/Person
http://example.org/#spiderman,http://www.perceive.net/schemas/relationship/enemyOf,http://example.org/#green-goblin
以下の通り、URLにパラメータを指定して実行可能
※指定可能なパラメータはマニュアル参照のこと
query:URLエンコードしたSPARQL
format:出力形式(json、xml、csv、tsv、 n-triples)
【参考】Oracle RDFモデルの公開
セットアップ:パブリック・エンドポイント公開許可設定
44
【参考】Oracle RDFモデルの公開
モデルの公開
45
任意のデータセット名
パラメータを指定しなかったときに
実行されるデフォルトSPARQL文
パブリック・エンドポイントのURL
参考資料
Copyright © 2022, Oracle and/or its affiliates
46