OrientDB - 安裝



OrientDB 安裝檔案提供兩個版本:

  • 社群版 - OrientDB 社群版由 Apache 根據 0.2 許可證釋出,是一個開源軟體。

  • 企業版 - OrientDB 企業版作為專有軟體釋出,構建在社群版的基礎上。它是社群版的擴充套件。

本章介紹 OrientDB 社群版的安裝過程,因為它是一個開源軟體。

先決條件

社群版和企業版都可以在任何實現了 Java 虛擬機器 (JVM) 的作業系統上執行。OrientDB 需要 Java 1.7 或更高版本。

使用以下步驟將 OrientDB 下載並安裝到您的系統中。

步驟 1 - 下載 OrientDB 二進位制安裝檔案

OrientDB 自帶安裝檔案,用於在您的系統上安裝資料庫。它為不同的作業系統提供了不同的預編譯二進位制包(打包或壓縮包)。您可以從 下載 OrientDB 連結下載 OrientDB 檔案。

以下螢幕截圖顯示了 OrientDB 的下載頁面。您可以透過點選合適的作業系統圖示來下載壓縮或打包的檔案。

Download Page of OrientDB

下載後,您將在 下載 資料夾中獲得二進位制包。

步驟 2 - 解壓並安裝 OrientDB

以下是針對不同作業系統的解壓和安裝 OrientDB 的步驟。

在 Linux 中

下載後,您將在 下載 資料夾中獲得 orientdb-community-2.1.9.tar.gz 檔案。您可以使用以下命令解壓該檔案。

$ tar –zxvf orientdb-community-2.1.9.tar.gz 

您可以使用以下命令將所有 OrientDB 庫檔案從 orientdbcommunity-2.1.9 移動到 /opt/orientdb/ 目錄。這裡我們使用超級使用者命令 (sudo),因此您需要提供超級使用者密碼才能執行以下命令。

$ sudo mv orientdb-community-2.1.9 /opt/orientdb

您可以使用以下命令註冊 orientdb 命令和 Orient 伺服器。

$ export ORIENTDB_HoME = /opt/orientdb 
$ export PATH = $PATH:$ORIENTDB_HOME/bin

在 Windows 中

  • 下載後,您將在 下載 資料夾中獲得 orientdb-community-2.1.9.zip 檔案。使用 zip 解壓縮工具解壓該 zip 檔案。

  • 將解壓後的資料夾移動到 C:\ 目錄。

  • 建立兩個環境變數 ORIENTDB_HOME 和 PATH 變數,並使用以下給定值。

ORIENT_HOME = C:\orientdb-community-2.1.9 
PATH = C:\orientdb-community-2.1.9\bin

步驟 3 - 將 OrientDB 伺服器配置為服務

透過以上步驟,您可以使用 OrientDB 的桌面版本。您可以使用以下步驟將 OrientDB 資料庫伺服器作為服務啟動。具體步驟因作業系統而異。

在 Linux 中

OrientDB 提供了一個名為 orientdb.sh 的指令碼檔案,用於以守護程序的方式執行資料庫。您可以在 OrientDB 安裝目錄的 bin/ 目錄中找到它,即 $ORIENTDB_HOME/bin/orientdb.sh。

在執行指令碼檔案之前,您需要編輯 orientdb.sh 檔案以定義兩個變數。一個是 ORIENTDB_DIR,它定義了安裝目錄的路徑(/opt/orientdb),另一個是 ORIENTDB_USER,它定義了您希望 OrientDB 以哪個使用者身份執行,如下所示。

ORIENTDB_DIR = "/opt/orientdb" 
ORIENTDB_USER = "<username you want to run OrientDB>" 

使用以下命令將 orientdb.sh 檔案複製到 /etc/init.d/ 目錄,以初始化和執行指令碼。這裡我們使用超級使用者命令 (sudo),因此您需要提供超級使用者密碼才能執行以下命令。

$ sudo cp $ORIENTDB_HOME/bin/orientdb.sh /etc/init.d/orientdb

使用以下命令將 console.sh 檔案從 OrientDB 安裝目錄(即 $ORIENTDB_HOME/bin)複製到系統 bin 目錄(即 /usr/bin),以便訪問 Orient DB 的控制檯。

$ sudo cp $ ORIENTDB_HOME/bin/console.sh /usr/bin/orientdb

使用以下命令啟動 ORIENTDB 資料庫伺服器作為服務。這裡您需要提供在 orientdb.sh 檔案中指定的相應使用者的密碼才能啟動伺服器。

$ service orientdb start

使用以下命令檢視 OrientDB 伺服器守護程序正在執行的 PID。

$ service orientdb status

使用以下命令停止 OrientDB 伺服器守護程序。這裡您需要提供在 orientdb.sh 檔案中指定的相應使用者的密碼才能停止伺服器。

$ service orientdb stop

在 Windows 中

OrientDB 是一個伺服器應用程式,因此在啟動和關閉 Java 虛擬機器程序之前,它需要執行一些任務。如果您想手動關閉 OrientDB 伺服器,則需要執行 shutdown.bat 檔案。但是,當系統突然關閉而沒有執行上述指令碼時,伺服器例項不會正確停止。在 Windows 中,由作業系統透過一組指定的訊號控制的程式稱為服務

我們需要使用 Apache Common Daemon,它允許 Windows 使用者將 Java 應用程式包裝為 Windows 服務。以下是下載和註冊 Apache common daemon 的步驟。

  • 點選以下連結獲取 適用於 Windows 的 Apache Common Daemons

  • 點選 common-daemon-1.0.15-bin-windows 下載。

  • 解壓 common-daemon-1.0.15-bin-windows 目錄。解壓後,您將在目錄中找到 prunsrv.exeprunmgr.exe 檔案。其中:

    • prunsrv.exe 檔案是一個服務應用程式,用於將應用程式作為服務執行。

    • prunmgr.exe 檔案是一個用於監視和配置 Windows 服務的應用程式。

  • 轉到 OrientDB 安裝資料夾 -> 建立一個新目錄並將其命名為 service。

  • 複製 prunsrv.exeprunmgr .exe 並貼上到 service 目錄中。

  • 為了將 OrientDB 配置為 Windows 服務,您需要執行一個簡短的指令碼,該指令碼使用 prusrv.exe 作為 Windows 服務。

  • 在定義 Windows 服務之前,您需要根據服務名稱重新命名 prunsrv 和 prunmgr。例如,分別重新命名為 OrientDBGraph 和 OrientDBGraphw。這裡 OrientDBGraph 是服務名稱。

  • 將以下指令碼複製到名為 installService.bat 的檔案中,並將其放置到 %ORIENTDB_HOME%\service\ 目錄中。

:: OrientDB Windows Service Installation 
@echo off 
rem Remove surrounding quotes from the first parameter 
set str=%~1 
rem Check JVM DLL location parameter 
if "%str%" == "" goto missingJVM 
set JVM_DLL=%str% 
rem Remove surrounding quotes from the second parameter 
set str=%~2 
rem Check OrientDB Home location parameter 
if "%str%" == "" goto missingOrientDBHome 
set ORIENTDB_HOME=%str%  


set CONFIG_FILE=%ORIENTDB_HOME%/config/orientdb-server-config.xml 
set LOG_FILE = %ORIENTDB_HOME%/config/orientdb-server-log.properties 
set LOG_CONSOLE_LEVEL = info 
set LOG_FILE_LEVEL = fine 
set WWW_PATH = %ORIENTDB_HOME%/www 
set ORIENTDB_ENCODING = UTF8 
set ORIENTDB_SETTINGS = -Dprofiler.enabled = true 
-Dcache.level1.enabled = false Dcache.level2.strategy = 1 
set JAVA_OPTS_SCRIPT = -XX:+HeapDumpOnOutOfMemoryError

  
rem Install service 
OrientDBGraphX.X.X.exe //IS --DisplayName="OrientDB GraphEd X.X.X" ^ 
--Description = "OrientDB Graph Edition, aka GraphEd, contains OrientDB server
integrated with the latest release of the TinkerPop Open Source technology 
stack supporting property graph data model." ^ 

--StartClass = com.orientechnologies.orient.server.OServerMain 
-StopClass = com.orientechnologies.orient.server.OServerShutdownMain ^
 
--Classpath = "%ORIENTDB_HOME%\lib\*" --JvmOptions 
"Dfile.Encoding = %ORIENTDB_ENCODING%; Djava.util.logging.config.file = "%LOG_FILE%";
Dorientdb.config.file = "%CONFIG_FILE%"; -Dorientdb.www.path = "%WWW_PATH%";
Dlog.console.level = %LOG_CONSOLE_LEVEL%; -Dlog.file.level = %LOG_FILE_LEVEL%;
Dorientdb.build.number = "@BUILD@"; -DORIENTDB_HOME = %ORIENTDB_HOME%" ^ 

--StartMode = jvm --StartPath = "%ORIENTDB_HOME%\bin" --StopMode = jvm 
-StopPath = "%ORIENTDB_HOME%\bin" --Jvm = "%JVM_DLL%" 
-LogPath = "%ORIENTDB_HOME%\log" --Startup = auto  

EXIT /B  

:missingJVM 
echo Insert the JVM DLL location 
goto printUsage 
 
:missingOrientDBHome 
echo Insert the OrientDB Home
goto printUsage 
 
:printUsage 
echo usage: 
echo     installService JVM_DLL_location OrientDB_Home 
EXIT /B 

該指令碼需要兩個引數:

  • jvm.dll 的位置,例如 C:\ProgramFiles\java\jdk1.8.0_66\jre\bin\server\jvm.dll

  • OrientDB 安裝的位置,例如 C:\orientdb-community-2.1.9

  • 當您執行 OrientDBGraph.exe 檔案(原始 prunsrv)並雙擊它時,將安裝服務。

  • 使用以下命令將服務安裝到 Windows 中。

> Cd %ORIENTDB_HOME%\service 
> installService.bat "C:\Program Files\Java\jdk1.8.0_66\jre\bin\server
   \jvm.dll" C:\orientdb-community-2.1.9 

開啟任務管理器服務,您將看到以下螢幕截圖,其中包含已註冊的服務名稱。

Task Manager

步驟 4 - 驗證 OrientDB 安裝

此步驟使用以下步驟驗證 OrientDB 資料庫伺服器安裝。

  • 執行伺服器。
  • 執行控制檯。
  • 執行 studio。

這對於不同的作業系統來說是唯一的。

在 Linux 中

按照給定的步驟在 Linux 中驗證 OrientDB 安裝。

執行伺服器 - 您可以使用以下命令啟動伺服器。

$ cd $ORIENTDB_HOME/bin 
$ ./server.sh 

或者,您可以使用以下命令將 OrientDB 伺服器作為 UNIX 守護程序啟動。

$ service orientdb start 

如果安裝成功,您將收到以下輸出。

          .                                           
          .`        `                                  
          ,      `:.                                   
         `,`    ,:`                                    
         .,.   :,,                                     
         .,,  ,,,                                      
    .    .,.:::::  ````                                 :::::::::     :::::::::    
    ,`   .::,,,,::.,,,,,,`;;                      .:    ::::::::::    :::    :::   
    `,.  ::,,,,,,,:.,,.`  `                       .:    :::      :::  :::     :::  
     ,,:,:,,,,,,,,::.   `        `         ``     .:    :::      :::  :::     :::  
      ,,:.,,,,,,,,,: `::, ,,   ::,::`   : :,::`  ::::   :::      :::  :::    :::   
       ,:,,,,,,,,,,::,:   ,,  :.    :   ::    :   .:    :::      :::  :::::::      
        :,,,,,,,,,,:,::   ,,  :      :  :     :   .:    :::      :::  :::::::::    
  `     :,,,,,,,,,,:,::,  ,, .::::::::  :     :   .:    :::      :::  :::     :::  
  `,...,,:,,,,,,,,,: .:,. ,, ,,         :     :   .:    :::      :::  :::     ::: 
    .,,,,::,,,,,,,:  `: , ,,  :     `   :     :   .:    :::      :::  :::     :::  
      ...,::,,,,::.. `:  .,,  :,    :   :     :   .:    :::::::::::   :::     :::  
           ,::::,,,. `:   ,,   :::::    :     :   .:    :::::::::     ::::::::::   
           ,,:` `,,.                                   
          ,,,    .,`                                   
         ,,.     `,                                          GRAPH DATABASE   
       ``        `.                                                           
                 ``                                          orientdb.com 
                 `    
				 
2016-01-20 19:17:21:547 INFO  OrientDB auto-config DISKCACHE = 1, 
   649MB (heap = 494MB os = 4, 192MB disk = 199, 595MB) [orientechnologies] 
2016-01-20 19:17:21:816 INFO  Loading configuration from:
   /opt/orientdb/config/orientdb-server-config.xml... [OServerConfigurationLoaderXml] 
2016-01-20 19:17:22:213 INFO  OrientDB Server v2.1.9-SNAPSHOT 
   (build 2.1.x@r; 2016-01-07 10:51:24+0000) is starting up... [OServer] 
2016-01-20 19:17:22:220 INFO  Databases directory: /opt/orientdb/databases [OServer] 
2016-01-20 19:17:22:361 INFO  Port 0.0.0.0:2424 busy, 
   trying the next available... [OServerNetworkListener] 
2016-01-20 19:17:22:362 INFO  Listening binary connections on 0.0.0.0:2425 
   (protocol v.32, socket = default) [OServerNetworkListener] 
... 
2016-01-20 19:17:22:614 INFO  Installing Script interpreter. WARN:
   authenticated clients can execute any kind of code into the server 
   by using the following allowed languages: 
   [sql] [OServerSideScriptInterpreter] 
2016-01-20 19:17:22:615 INFO  OrientDB Server v2.1.9-SNAPSHOT 
   (build 2.1.x@r; 2016-01-07 10:51:24+0000) is active. [OServer] 

執行控制檯 - 您可以使用以下命令在控制檯下執行 OrientDB。

$ orientdb

如果安裝成功,您將收到以下輸出。

OrientDB console v.2.1.9-SNAPSHOT (build 2.1.x@r; 2016-01-07 10:51:24+0000) www.orientdb.com 
Type 'help' to display all the supported commands. 
Installing extensions for GREMLIN language v.2.6.0 
 
orientdb>

執行 Studio - 啟動伺服器後,您可以在瀏覽器上使用以下 URL(https://:2480/)。您將看到以下螢幕截圖。

Running the Studio

在 Windows 中

按照給定的步驟在 Windows 中驗證 OrientDB 安裝。

執行伺服器 - 您可以使用以下命令啟動伺服器。

> cd %ORIENTDB_HOME%\bin 
> ./server.bat

如果安裝成功,您將收到以下輸出。

          .                                           
          .`        `                                  
          ,      `:.                                   
         `,`    ,:`                                    
         .,.   :,,    
		 .,,  ,,,                                      
    .    .,.:::::  ````                                 :::::::::     :::::::::    
    ,`   .::,,,,::.,,,,,,`;;                      .:    ::::::::::    :::    :::   
    `,.  ::,,,,,,,:.,,.`  `                       .:    :::      :::  :::     :::  
     ,,:,:,,,,,,,,::.   `        `         ``     .:    :::      :::  :::     :::  
      ,,:.,,,,,,,,,: `::, ,,   ::,::`   : :,::`  ::::   :::      :::  :::    :::   
       ,:,,,,,,,,,,::,:   ,,  :.    :   ::    :   .:    :::      :::  :::::::      
        :,,,,,,,,,,:,::   ,,  :      :  :     :   .:    :::      :::  :::::::::    
  `     :,,,,,,,,,,:,::,  ,, .::::::::  :     :   .:    :::      :::  :::     :::  
  `,...,,:,,,,,,,,,: .:,. ,, ,,         :     :   .:    :::      :::  :::     :::  
    .,,,,::,,,,,,,:  `: , ,,  :     `   :     :   .:    :::      :::  :::     :::  
      ...,::,,,,::.. `:  .,,  :,    :   :     :   .:    :::::::::::   :::     :::  
           ,::::,,,. `:   ,,   :::::    :     :   .:    :::::::::     ::::::::::   
           ,,:` `,,.                                   
          ,,,    .,`                                   
         ,,.     `,                                          GRAPH DATABASE   
       ``        `.                                                           
                 ``                                          orientdb.com 
                 `            
				 
2016-01-20 19:17:21:547 INFO  OrientDB auto-config DISKCACHE = 1,649MB 
   (heap = 494MB os = 4, 192MB disk = 199, 595MB) [orientechnologies] 
2016-01-20 19:17:21:816 INFO  Loading configuration from: 
   /opt/orientdb/config/orientdb-server-config.xml... 
   [OServerConfigurationLoaderXml] 
... 
2016-01-20 19:17:22:615 INFO  OrientDB Server v2.1.9-SNAPSHOT 
   (build 2.1.x@r; 2016-01-07 10:51:24+0000) is active. [OServer] 

執行控制檯 - 您可以使用以下命令在控制檯下執行 OrientDB。

> %ORIENTDB_HOME%\bin\console.bat 

如果安裝成功,您將收到以下輸出。

OrientDB console v.2.1.9-SNAPSHOT (build 2.1.x@r; 2016-01-07 10:51:24+0000) www.orientdb.com 
Type 'help' to display all the supported commands. 
Installing extensions for GREMLIN language v.2.6.0 
 
orientdb\>

執行 Studio - 啟動伺服器後,您可以在瀏覽器上使用以下 URL(https://:2480/)。您將看到以下螢幕截圖。

Running the Studio
廣告