virtuoso ์ผ ์‹œ์ž‘(Ubuntu ํŽธ)

11550 ๋‹จ์–ด UbunturdfSPARQLvirtuoso
SPARQL Endpoint๋ฅผ ๋กœ์ปฌ์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ๋ฅผ ์›ํ•˜๊ธฐ ๋•Œ๋ฌธ์— DBpedia์—์„œ๋„ ์‚ฌ์šฉ๋˜๋Š”(์ฝ๊ธฐ: ๋นŒํ† ์†Œ, ๋นŒํ† ์˜ค์†Œ, ๋ฒ„์ธ„์˜ค์†Œ) ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•˜๊ณ  SPARQL ์กฐํšŒ์—์„œ ๊ตฌ์ถ•๋œ SPARQL Endpoint๋ฅผ ๊ฒ€์ƒ‰, ์—…๋ฐ์ดํŠธ, ์‚ญ์ œํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.

๋ฐฐํฌ ํ™˜๊ฒฝ

  • VM
  • Ubuntu:16.04.1 LTS
  • virtuoso:6.1.6.3127
  • ํ™˜๊ฒฝ ๊ตฌ์ถ•


    ์„ค์น˜

  • ํฌ์žฅ์„ ๋‚˜๋ˆ ์คฌ๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ๊ฑธ๋กœ
  • ์†Œํ”„ํŠธ์›จ์–ด ํŒจํ‚ค์ง€๋กœ ๋ฐฐํฌ๋˜๋Š” ๋ฒ„์ „ 6
  • $ sudo apt update
    $ sudo apt install virtuoso-opensource -y
    
    ํ™”๋ฉด์—์„œ default ์‚ฌ์šฉ์ž์˜ default password๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š๋ƒ๋Š” ์งˆ๋ฌธ์— ์ด๋ฒˆ์—๋Š” ๋ณ€๊ฒฝํ•˜์ง€ ์•Š๊ณ  OK
    virtuoso
    ์„ค์น˜ ์™„๋ฃŒ
    ๋ช…๋ น์— ์ถ”๊ฐ€virtuoso-t

    virtuoso ์‹œ์ž‘

  • virtuoso.ini๊ฐ€ ์žˆ๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ๋กœ ์ด๋™
  • ํŠน๋ณ„ํ•œ ๋ฌธ์ œ๊ฐ€ ์—†์œผ๋ฉด /etc/virtuoso-opensource-6.1 ์ดํ•˜๋Š”virtuoso์ด๋‹ค.ini ์žˆ์Œ
  • ์‹œ์ž‘ ๋ช…๋ น ์‹คํ–‰
  • -f ๋Š” foreground ์—์„œ ์ˆ˜ํ–‰๋˜๋Š” ์˜ต์…˜์ž…๋‹ˆ๋‹ค.
  • -d ๋””๋ฒ„๊ทธ ์ •๋ณด๋ฅผ ํ‘œ์‹œํ•˜๋Š” ์˜ต์…˜
  • $ cd /etc/virtuoso-opensource-6.1
    $ sudo virtuoso-t -df
    

    ๋™์ž‘ ํ™•์ธ


    ๋ธŒ๋ผ์šฐ์ €์—์„œ ์•ก์„ธ์Šค

  • ํ™ˆ ํŽ˜์ด์ง€๋Š” ๋‹ค์Œ URL์„ ํ†ตํ•ด ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • http://<server_IP>:8890

  • Virtuoso Conductor ๋กœ๊ทธ์ธ

  • ํ™ˆํŽ˜์ด์ง€ ํ™”๋ฉด ์™ผ์ชฝConductor ๋งํฌ ํด๋ฆญ
  • user name ๋ฐ password ์„ ์ž…๋ ฅํ•˜๋Š” ๊ณณ์ด ์žˆ์œผ๋ฏ€๋กœ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ด๋ฆ„, ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ๋กœ๊ทธ์ธ ์™„๋ฃŒ
  • user: dba
  • password: dba

  • ๋ธŒ๋ผ์šฐ์ €์—์„œ SPARQL ์งˆ์˜ ์ œ์ถœ

  • ๋‹ค์Œ URL์—์„œ Conductor์— ๋กœ๊ทธ์ธํ•˜์ง€ ์•Š๊ณ ๋„ SPARQL ์ฟผ๋ฆฌ๋ฅผ ๋‚ด๋ณด๋ƒ…๋‹ˆ๋‹ค.
  • http://:8890/sparql

  • CUI์—์„œ SPARQL ์งˆ์˜ ์ œ์ถœ

  • isql-vt ๋ช…๋ น์œผ๋กœ SPARQL ์ฟผ๋ฆฌ๋ฅผ ์ƒํ˜ธ ์ž‘์šฉ์œผ๋กœ ๋‚ด๋ณด๋‚ผ ์ˆ˜ ์žˆ์Œ
  • ์ผ๋ฐ˜์ ์ธ SPARQL ์งˆ์˜ ์ „์— SPARQL์„ ์ž…๋ ฅํ•˜๊ณ  ์งˆ์˜๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.
  • $ isql-vt 1111 dba dba
    SQL> SPARQL SELECT * WHERE {?s ?p ?o};
    

    ๋กœ์ปฌ SPARQL Endpoint ๊ตฌ์ถ•


    ๋ธŒ๋ผ์šฐ์ €์—์„œ RDF(Turtle) ํŒŒ์ผ ๊ฐ€์ ธ์˜ค๊ธฐ

  • 1.virtuoso ํ™ˆํŽ˜์ด์ง€์—์„œ Conductor๋กœ ๋“ค์–ด๊ฐ€๊ณ dba ์‚ฌ์šฉ์ž์—์„œ ๋กœ๊ทธ์ธํ•ฉ๋‹ˆ๋‹ค.
  • 2.๋กœ๊ทธ์ธํ•œ ํ›„ ํƒญ์—์„œ "Linked Data"(์•„๋ž˜ ๊ทธ๋ฆผ์˜ ๋นจ๊ฐ„์ƒ‰์œผ๋กœ ๋‘˜๋Ÿฌ์‹ธ์ธ ๊ณณ)
  • ๋ฅผ ํด๋ฆญํ•˜์‹ญ์‹œ์˜ค.
  • 3.๋‹ค๋ฅธ ํƒญ์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์ƒˆ ํƒญ์—์„œ ๋น ๋ฅธ ์ €์žฅ ์—…๋กœ๋“œ
  • ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
  • 4.File ์„ ์„ ํƒํ•˜๊ณ  ์—…๋กœ๋“œํ•  ํŒŒ์ผ์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
  • ์ด๋•Œ ํŒŒ์ผ์˜ ๋ฌธ์ž ์ฝ”๋“œ๊ฐ€ utf-8์ธ์ง€ ํ™•์ธ
  • ๊ทธ๋ž˜ํ”„์˜ IRI๋ฅผ ๋…๋ฆฝ์‹œํ‚ค๋ ค๋ฉด Named Graph IRI
  • ํŽธ์ง‘
  • ์ด๋ฒˆ์—๋Š” http://localhost:8890/TEST/ ์ด๋ฆ„์œผ๋กœ ๊ทธ๋ž˜ํ”„ IRI
  • ๋ฅผ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • 5. ์—…๋กœ๋“œ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์—…๋กœ๋“œ ์™„๋ฃŒ!
  • ์—…๋กœ๋“œ ์—ฌ๋ถ€ ํ™•์ธ


    SPARQL ์ฟผ๋ฆฌ๋ฅผ ๋˜์ ธ ์ง€์ •ํ•œ Graph IRI๋ฅผ ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.

    ๋ธŒ๋ผ์šฐ์ €์—์„œ ์งˆ์˜ ์ œ์ถœ ์‹œ

  • Default Data Set Name์— ๋ฐฉ๊ธˆ ์„ค์ •ํ•œ Graph URI(์ด๋ฒˆ์€ http://localhost:8890/TEST/๋ฅผ ์ž…๋ ฅํ•œ ๋‹ค์Œ ์งˆ์˜๋ฅผ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค.

  • CUI์—์„œ ์งˆ์˜ ์ œ์ถœ ์‹œ

  • SELECT ๋ฌธ ๋’ค์— ์ถ”๊ฐ€FROM <Graph URI>
  • # isql-vt 1111 dba dba
    SQL> SPARQL SELECT * FROM <http://localhost:8890/DAV> WHERE {?s ?p ?o};
    

    SPARQL ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ


    SPARQL ์งˆ์˜๋ฅผ ์—…๋ฐ์ดํŠธํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •

    ํ—ˆ์šฉ ์„ค์ • ์—…๋ฐ์ดํŠธ


    ์ดˆ๊ธฐ ์ƒํƒœ๋Š” SPARQL๋กœ UPDATE, INSERT, DELETE ๊ณ„์—ด์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์—†์œผ๋ฉฐ ์‹คํ–‰ ํ›„์—๋Š” ๊ถŒํ•œ์ด ์—†๋Š” ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ๋ฉ๋‹ˆ๋‹ค.
    Virtuoso 42000 Error SR186:SECURITY: No permission to execute procedure DB.DBA.SPARQL_INSERT_DICT_CONTENT~~ไปฅไธ‹็•ฅ~~
    
    ์—…๋ฐ์ดํŠธ ์‹œ์Šคํ…œ์„ ์ฒ˜๋ฆฌํ•˜๋ ค๋ฉด ์—…๋ฐ์ดํŠธ ๊ถŒํ•œ์— ๋Œ€ํ•œ ๊ถŒํ•œ์„ ์„ค์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.์ด ์„ค์ •์€ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‰ฝ๊ฒŒ ์™„์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • 1. Virtuoso Conductor ๋กœ๊ทธ์ธ
  • 2. ์‹œ์Šคํ…œ ๊ด€๋ฆฌ ํƒญ ํด๋ฆญ
  • 3. L2 ๋ ˆ์ด๋ธ”์— ์žˆ๋Š” ์‚ฌ์šฉ์ž ๊ณ„์ • ํด๋ฆญ
  • 4.SPARQL ํ–‰์—์„œ edit
  • ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
  • 5. Account roles์˜SPARQL_UPDATE๋ฅผSelected field(์˜ค๋ฅธ์ชฝ)์œผ๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ
  • 6.[save] ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์„ค์ •์ด ์™„์„ฑ๋˜๋Š” ๊ฒƒ์„ ์žŠ์ง€ ๋งˆ์„ธ์š”
  • ์—…๋ฐ์ดํŠธ ์‹œ์Šคํ…œ ์ฒ˜๋ฆฌ๋ฅผ ์‹œ๋„ํ•ด ๋ณด์‹ญ์‹œ์˜ค.

  • ๋ฐ์ดํ„ฐ ์ž…๋ ฅ ๋ฐ DELETE ์‹œ๋„
  • SQL> sparql select distinct * FROM <http://localhost:8890/TEST/> where {?s ?p ?o .};
    s                                                                                 p                                                                                 o
    LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR
    _______________________________________________________________________________
    
    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/#green-goblin                                                  http://www.perceive.net/schemas/relationship/enemyOf                              http://example.org/#spiderman
    http://example.org/#spiderman                                                     http://www.perceive.net/schemas/relationship/enemyOf                              http://example.org/#green-goblin
    http://example.org/#green-goblin                                                  http://xmlns.com/foaf/0.1/name                                                    Green Goblin
    http://example.org/#spiderman                                                     http://xmlns.com/foaf/0.1/name                                                    Spiderman
    http://example.org/#spiderman                                                     http://xmlns.com/foaf/0.1/name                                                    โ–’Xโ–’uโ–’|โ–’โ–’โ–’rโ–’uโ–’{-โ–’โ–’โ–’pโ–’โ–’โ–’{
    SQL> SPARQL INSERT{ GRAPH <http://localhost:8890/TEST/> { <http://example.org/#spiderman> foaf:name "ๅœฐ็„ใ‹ใ‚‰ใฎไฝฟ่€…"}}
    T;
    Done. -- 5 msec.
    SQL> sparql select distinct * FROM <http://localhost:8890/TEST/> where {?s ?p ?o .};
    s                                                                                 p                                                                                 o
    LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR
    _______________________________________________________________________________
    
    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/#green-goblin                                                  http://www.perceive.net/schemas/relationship/enemyOf                              http://example.org/#spiderman
    http://example.org/#spiderman                                                     http://www.perceive.net/schemas/relationship/enemyOf                              http://example.org/#green-goblin
    http://example.org/#green-goblin                                                  http://xmlns.com/foaf/0.1/name                                                    Green Goblin
    http://example.org/#spiderman                                                     http://xmlns.com/foaf/0.1/name                                                    Spiderman
    http://example.org/#spiderman                                                     http://xmlns.com/foaf/0.1/name                                                    โ–’Xโ–’uโ–’|โ–’โ–’โ–’rโ–’uโ–’{-โ–’โ–’โ–’pโ–’โ–’โ–’{
    http://example.org/#spiderman                                                     http://xmlns.com/foaf/0.1/name                                                    ๅœฐ็„ใ‹ใ‚‰ใฎไฝฟ่€…
    
    8 Rows. -- 1 msec.
    SQL> DELETE{ GRAPH <http://localhost:8890/TEST/> { <http://example.org/#spiderman> foaf:name "ๅœฐ็„ใ‹ใ‚‰ใฎไฝฟ่€…"}};
    SQL> SPARQL DELETE{ GRAPH <http://localhost:8890/TEST/> { <http://example.org/#spiderman> foaf:name "ๅœฐ็„ใ‹ใ‚‰ใฎไฝฟ่€…"}};
    
    Done. -- 3 msec.
    SQL> sparql select distinct * FROM <http://localhost:8890/TEST/> where {?s ?p ?o .};
    s                                                                                 p                                                                                 o
    LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR
    _______________________________________________________________________________
    
    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/#green-goblin                                                  http://www.perceive.net/schemas/relationship/enemyOf                              http://example.org/#spiderman
    http://example.org/#spiderman                                                     http://www.perceive.net/schemas/relationship/enemyOf                              http://example.org/#green-goblin
    http://example.org/#green-goblin                                                  http://xmlns.com/foaf/0.1/name                                                    Green Goblin
    http://example.org/#spiderman                                                     http://xmlns.com/foaf/0.1/name                                                    Spiderman
    http://example.org/#spiderman                                                     http://xmlns.com/foaf/0.1/name                                                    โ–’Xโ–’uโ–’|โ–’โ–’โ–’rโ–’uโ–’{-โ–’โ–’โ–’pโ–’โ–’โ–’{
    
    7 Rows. -- 1 msec.
    SQL>
    
    

    ๋๋‚  ๋•Œ


    ์ด์ œvirtuoso6์—์„œ SPARQL Endpoint๋ฅผ ๋งŒ๋“ค๊ณ  SPARQL ์กฐํšŒ์—์„œ SPARQL Endpoint๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    ์‚ฌ์‹ค, ๋‚˜๋Š” CentOS์—์„œvirtuoso์˜ ๋ฒ„์ „ 7์„ ์ด๋™ํ•˜๊ณ  ์‹ถ์—ˆ์ง€๋งŒ ์ž˜ ๊ตฌ์ถ•ํ•˜์ง€ ๋ชปํ•ด์„œ ์ค‘๋„์— ํฌ๊ธฐํ–ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ๋ฐฉ๊ธˆ ํ•ด ๋ดค๋Š”๋ฐ ์ˆœ์กฐ๋กญ๊ฒŒ ์ด๋™ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ€๊นŒ์šด ์‹œ์ผ ๋‚ด์— ๊ทธ ์ ˆ์ฐจ๋ฅผ ์ •๋ฆฌํ•˜๊ณ  ์‹ถ์—ˆ๋‹ค.

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ