1 of 46

Oracle Cloud で無料の SPARQL エンドポイント構築

LOD Challenge 2022

2 of 46

無料環境のご案内(ステップ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

3 of 46

無料環境のご案内(ステップ2:サインアップ)

メールにて事前申し込みいただいた後、メールアドレスが弊社社内システムに登録されると、クレジットカード情報登録なしで無料環境にサインアップできるようになります。

こちらからサインアップにお進みください。

既に Oracle Cloud のアカウントをお持ちの場合には、利用できる無料環境は同じものなので、その環境を用いて本資料の内容をお試しいただくことも可能です。

Copyright © 2022, Oracle and/or its affiliates

3

4 of 46

本資料の内容

無償で使えるAlways Free環境を利用して、

Oracleが提供するRDFグラフのSPARQLエンドポイントからデータロード&クエリ実行を行います。

Copyright © 2022, Oracle and/or its affiliates

4

5 of 46

構成イメージ

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)

> 12.3.2.2 Tomcatサーバーでのユーザーとロールの管理

> 12.3.3.1.1.2 TomcatでのJDBCデータ・ソースの作成

6 of 46

作業の流れ

  1. Autonomous Databaseの作成
  2. ネットワークリソースの作成 ※Compute作成のために必要なリソース
  3. マーケットプライスを使ったRDFグラフ・サーバー構築済Computeの作成
  4. 接続事前準備
  5. RDFグラフ・サーバーセットアップ
  6. RDFデータロード

Copyright © 2022, Oracle and/or its affiliates

6

今回デモを行う部分

7 of 46

(必要に応じて)言語設定

Copyright © 2022, Oracle and/or its affiliates

7

8 of 46

Autonomous Database(トリプルストア)の作成①

Copyright © 2022, Oracle and/or its affiliates

8

9 of 46

Autonomous Database(トリプルストア)の作成②

Copyright © 2022, Oracle and/or its affiliates

9

10 of 46

Autonomous Database(トリプルストア)の作成③

Copyright © 2022, Oracle and/or its affiliates

10

任意の名前(本資料ではTRLSTOREとする)

11 of 46

Autonomous Database(トリプルストア)の作成④

Copyright © 2022, Oracle and/or its affiliates

11

DBのパスワード

※後程利用するため、メモしておく

12 of 46

Autonomous Database(トリプルストア)の作成⑤

Copyright © 2022, Oracle and/or its affiliates

12

数分程度で作成完了

13 of 46

ネットワークリソースの作成①

Copyright © 2022, Oracle and/or its affiliates

13

14 of 46

ネットワークリソースの作成②

Copyright © 2022, Oracle and/or its affiliates

14

15 of 46

ネットワークリソースの作成③

Copyright © 2022, Oracle and/or its affiliates

15

16 of 46

ネットワークリソースの作成④

Copyright © 2022, Oracle and/or its affiliates

16

17 of 46

事前に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

18 of 46

RDFグラフ・サーバー構築済Computeの作成①

Copyright © 2022, Oracle and/or its affiliates

18

19 of 46

RDFグラフ・サーバー構築済Computeの作成②

Copyright © 2022, Oracle and/or its affiliates

19

「Oracle RDF Graph Server and Query UI」で検索

20 of 46

RDFグラフ・サーバー構築済Computeの作成③

Copyright © 2022, Oracle and/or its affiliates

20

21 of 46

RDFグラフ・サーバー構築済Computeの作成④

Copyright © 2022, Oracle and/or its affiliates

21

任意の名前(本資料では「RDFServer」とする)

22 of 46

RDFグラフ・サーバー構築済Computeの作成⑤

Copyright © 2022, Oracle and/or its affiliates

22

事前に作成しておいた

SSHキー・ペアのPublic Keyを選択

23 of 46

RDFグラフ・サーバー構築済Computeの作成⑥

Copyright © 2022, Oracle and/or its affiliates

23

「ネットワークリソースの作成」で

作成したVCNを選択

Public Subnetを選択

WeblogicのAdmin Passwordを指定

※後程利用するため、メモしておく

WeblogicのAdmin ユーザ名を指定

※後程利用するため、メモしておく

24 of 46

RDFグラフ・サーバー構築済Computeの作成⑦

Copyright © 2022, Oracle and/or its affiliates

24

15分程度で作成完了

25 of 46

作成された環境(Compute)の確認①

Copyright © 2022, Oracle and/or its affiliates

25

26 of 46

作成された環境(Compute)の確認②

Copyright © 2022, Oracle and/or its affiliates

26

アクセス時に使用する

パブリックIPアドレスをメモしておく

27 of 46

ネットワークセキュリティリストの編集①

デフォルトでは22番ポートでのアクセスしか許可されていないため、�RDFグラフ・サーバー用のポート(8001)へのアクセスを許可するようにセキュリティリストを更新します。

> 前ページのComputeインスタンス名をクリック

Copyright © 2022, Oracle and/or its affiliates

27

28 of 46

ネットワークセキュリティリストの編集②

Copyright © 2022, Oracle and/or its affiliates

28

29 of 46

ネットワークセキュリティリストの編集③

Copyright © 2022, Oracle and/or its affiliates

29

30 of 46

Autonomous DatabaseのWalletダウンロード

Copyright © 2022, Oracle and/or its affiliates

30

Walletのパスワードを入力

※後程利用するため、メモしておく

31 of 46

Computeへアクセス(Teratermを使用する場合の例)

Copyright © 2022, Oracle and/or its affiliates

31

「作成された環境(Compute)の確認②」

で確認したComputeのPublic IPアドレス

Compute作成時に指定した

SSHキー・ペアのPrivate Keyファイルを指定

32 of 46

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」

本ファイルをダウンロードしておく

33 of 46

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

起動していることを確認する

34 of 46

RDFグラフ・サーバーへアクセス

https://<「作成された環境(Compute)の確認②」で確認したComputeのPublic IPアドレス>:8001/orardf

Copyright © 2022, Oracle and/or its affiliates

34

「RDFグラフ・サーバー構築済Computeの作成⑥」で指定した、

weblogicのAdmin ユーザ名とパスワードを指定

35 of 46

Autonomous Databaseへアクセスするためのデータソース設定

Copyright © 2022, Oracle and/or its affiliates

35

「RDFグラフ・サーバーとDBの接続で利用するWalletファイルの編集」で

作成したWalletファイル「wallet_with_cred.zip」を選択

36 of 46

RDFデータロードの流れ

  1. Semantic Network(RDF network)の作成
    • Semantic Network:�RDFデータ管理のために必要な表やビューのセット
  2. Modelの作成
    • Model:Oracle Database特有のトリプルの管理単位
  3. ファイルをステージング表にアップロード
  4. バルクロードでRDFデータとして取り込み
  5. クエリ実行

Copyright © 2022, Oracle and/or its affiliates

36

トリプルストア

(Autonomous Database)

Semantic Network:

SEMNET01

Semantic Network:

SEMNET02

MODEL: EXAMPLE1

MODEL: EXAMPLE2

MODEL: EXAMPLE3

37 of 46

1. Semantic Networkの作成

Copyright © 2022, Oracle and/or its affiliates

37

「Autonomous Databaseへアクセスするためのデータソース設定」で

作成したデータソースを指定

38 of 46

2. Modelの作成

Copyright © 2022, Oracle and/or its affiliates

38

作成したSemantic Networkを指定

39 of 46

3. ファイルをステージング表にアップロード

Copyright © 2022, Oracle and/or its affiliates

39

任意の名前を指定

RDFデータファイルを

選択

40 of 46

【参考】今回ロードした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

41 of 46

4.バルクロードでRDFデータとして取り込み

Copyright © 2022, Oracle and/or its affiliates

41

RDFデータに

4000byte以上の文字列が

含まれる場合は

「<ステージング表>_CLOB」も

同様の手順でバルクロードする必要がある

先ほど作成したModelを指定

42 of 46

5. クエリ実行

Copyright © 2022, Oracle and/or its affiliates

42

可視化も可能

43 of 46

【参考】Oracle RDFモデルの公開

SPARQL問合せのパブリックRESTエンドポイントを介して、�資格証明を入力せずにRDFデータセットがアプリケーションで直接使用できます。

  • パブリック・エンドポイントでは�SPARQL更新、SPARQL SERVICEおよびSPARQLユーザー定義関数はおこなえません。

43

【参考】Oracle® Database RDFグラフのグラフ開発者ガイド 21c F37759-04(原本部品番号:F31379-11)

> 12.3.3.2.8 Oracle RDFモデルの公開

利用イメージ

$ 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)

44 of 46

【参考】Oracle RDFモデルの公開

セットアップ:パブリック・エンドポイント公開許可設定

44

45 of 46

【参考】Oracle RDFモデルの公開

モデルの公開

45

任意のデータセット名

パラメータを指定しなかったときに

実行されるデフォルトSPARQL文

パブリック・エンドポイントのURL

46 of 46

参考資料

  • Setup RDF Graph Server with Autonomous Database
  • Oracle® Database RDFグラフのグラフ開発者ガイド 21c F37759-02(原本部品番号:F31379-06)�> 第II部 RDFグラフ・サーバーおよび問合せUI
  • Oracle® Spatial and Graph RDFナレッジ・グラフ開発者ガイド 19c F16099-06(原本部品番号:E94798-10)�> 1.6.2 グラフ・パターン: 中カッコの構文とOPTIONAL、FILTER、UNIONおよびGRAPHキーワードのサポート�> 表1-14 Oracle固有の問合せ関数
    • https://docs.oracle.com/cd/F19136_01/rdfrm/rdf-semantic-graph-overview.html#GUID-55180C4B-7B8B-4F45-A948-A46D227935FA

Copyright © 2022, Oracle and/or its affiliates

46