Orientdb 简明教程

OrientDB - Installation

OrientDB安装文件有两种版本可用−

OrientDB installation file is available in two editions −

  1. Community Edition − OrientDB community edition is released by Apache under 0.2 license as an open source

  2. Enterprise Edition − OrientDB enterprise edition is released as a proprietary software, which is built on community edition. It serves as an extension of the community edition.

本章解释OrientDB社区版的安装过程,因为它开源。

This chapter explains the installation procedure of OrientDB community edition because it is open source.

Prerequisites

社区版和企业版均可在实现Java虚拟机(JVM)的任何操作系统上运行。OrientDB需要Java 1.7或更高版本。

Both community and Enterprise editions can run on any Operating system that implements the Java Virtual Machine (JVM). OrientDB requires Java with 1.7 or later version.

使用以下步骤将OrientDB下载并安装到您的系统中。

Use the following steps to download and install OrientDB into your system.

Step 1 − Download OrientDB Binary Setup File

OrientDB带有内置设置文件,可在您的系统上安装数据库。它为不同的操作系统提供了不同的预编译二进制包(焦油包或ZIP包)。您可以从 Download OrientDB 链接中下载OrientDB文件。

OrientDB comes with built-in setup file to install the database on your system. It provides different pre-compiled binary packages (tarred or zipped packages) for different operating systems. You can download OrientDB files from Download OrientDB link.

以下屏幕截图显示了OrientDB的下载页面。您可以通过单击合适的操作系统图标来下载ZIP或焦油文件。

The following screenshot shows the download page of OrientDB. You can download the zipped or tarred file by clicking the suitable operating system icon.

download page orientdb

下载后,您将在 Downloads 文件夹中获取二进制包。

On downloading, you will get the binary package in your Downloads folder.

Step 2 − Extract and Install OrientDB

以下是为不同的操作系统提取和安装OrientDB的过程。

Following is the procedure to extract and install OrientDB for different operating systems.

In Linux

下载后,您将在 Downloads 文件夹中获取 orientdb-community-2.1.9.tar.gz 文件。您可以使用以下命令来提取焦油文件。

After download you will get orientdb-community-2.1.9.tar.gz file in your Downloads folder. You can use the following command to extract the tarred file.

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

您可以使用以下命令从 orientdbcommunity-2.1.9 to /opt/orientdb/ 目录移动所有OrientDB库文件。在此,我们使用超级用户命令(sudo),因此您必须提供超级用户密码以执行以下命令。

You can use the following command to move all the OrientDB library files from orientdbcommunity-2.1.9 to /opt/orientdb/ directory. Here we are using super user command (sudo) therefore you have to provide super user password to execute the following command.

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

你可以使用以下命令注册 orientdb 命令和 Orient 服务器。

You can use the following commands to register the orientdb command and the Orient server.

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

In Windows

  1. After download you will get orientdb-community-2.1.9.zip file in your Downloads folder. Extract the zip file using the zip extractor.

  2. Move the extracted folder into the C:\ directory.

  3. Create two environmental variables ORIENTDB_HOME and PATH variables with following given values.

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

Step 3 − Configuring OrientDB Server as a Service

按照上述步骤,你可以使用 OrientDB 的桌面版本。你可以使用以下步骤以服务形式启动 OrientDB 数据库服务器。该程序根据你的操作系统而不同。

By following the above steps you can use the Desktop version of OrientDB. You can start OrientDB database server as a service by using the following steps. The procedure is different, depending on your operating system.

In Linux

OrientDB 提供了一个名为 orientdb.sh 的脚本文件,用以将数据库作为守护进程运行。你可以在 OrientDB 安装目录的 bin/directory 中找到它,即 $ORIENTDB_HOME/bin/orientdb.sh。

OrientDB provides a script file named orientdb.sh to run the database as a daemon. You can find it in the bin/directory of your OrientDB installation directory that is $ORIENTDB_HOME/bin/orientdb.sh.

在运行脚本文件之前,你必须编辑 orientdb.sh 文件以定义两个变量。一个是 ORIENTDB_DIR ,它定义了安装目录的路径 ( /opt/orientdb ),第二个是 ORIENTDB_USER ,它定义了你希望运行 OrientDB 的用户名,如下所示。

Before running the script file, you have to edit orientdb.sh file for defining two variables. One is ORIENTDB_DIR which defines the path to the installation directory (/opt/orientdb) and the second is ORIENTDB_USER which defines the username you want run OrientDB for as follows.

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

使用以下命令将 orientdb.sh 文件复制到 /etc/init.d/ 目录中以初始化和运行脚本。此处我们使用超级用户命令 (sudo),因此你必须提供超级用户密码才能执行以下命令。

Use the following command to copy orientdb.sh file into /etc/init.d/ directory for initializing and running the script. Here we are using super user command (sudo) therefore you have to provide super user password to execute the following command.

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

使用以下命令将 control.sh 文件从 OrientDB 安装目录 $ORIENTDB_HOME/bin 复制到系统 bin 目录 /usr/bin ,以访问 Orient DB 的控制台。

Use the following command to copy the console.sh file from OrientDB installation directory that is $ORIENTDB_HOME/bin to the system bin directory that is /usr/bin for accessing the Orient DB’s console.

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

使用以下命令以服务形式启动 ORIENTDB 数据库服务器。此处你必须提供你在 orientdb.sh 文件中提到的相应用户的密码来启动服务器。

Use the following command to start the ORIENTDB database server as service. Here you have to provide the respective user’s password which you mention in the orientdb.sh file to start the server.

$ service orientdb start

使用以下命令了解 OrientDB 服务器守护进程正在运行哪个 PID 上。

Use the following command to know on which PID the OrientDB server daemon is running.

$ service orientdb status

使用以下命令停止 OrinetDB 服务器守护进程。此处你必须提供你在 orientdb.sh 文件中提到的相应用户的密码来停止服务器。

Use the following command to stop the OrientDB server daemon. Here you have to provide the respective user’s password, which you mention in the orientdb.sh file to stop the server.

$ service orientdb stop

In Windows

OrientDB 是一个服务器应用程序,因此它必须在启动关闭 Java 虚拟机进程之前执行多项任务。如果你想手动关闭 OrientDB 服务器,则必须执行 shutdown.bat 文件。但是,如果系统在不执行上述脚本的情况下突然关闭,则服务器实例不会正确停止。Windows 中操作系统使用一组特定信号控制的程序称为 services

OrientDB is a server application therefore it has to perform several tasks before starting shutting down the Java virtual machine process. If you want to shutdown OrientDB server manually then you have to execute shutdown.bat file. But the server instances do not stop correctly, when the system shuts down suddenly without executing the above script. The programs which are controlled by the operating system with a set of specified signals are called services in Windows.

我们必须使用 Apache Common Daemon ,它允许 Windows 用户将 Java 应用程序包装为 Windows 服务。以下是下载和注册 Apache common daemon 的过程。

We have to use Apache Common Daemon which allow Windows users to wrap Java applications as Windows service. Following is the procedure to download and register Apache common daemon.

  1. Click the following link for Apache Common Daemons for windows.

  2. Click on common-daemon-1.0.15-bin-windows to download.

  3. Unzip the common-daemon-1.0.15-bin-windows directory. After extracting you will find prunsrv.exe and prunmgr.exe files inside the directory. In those − prunsrv.exe file is a service application for running applications as services. prunmgr.exe file is an application used for monitoring and configuring windows services.

  4. Go to OrientDB installation folder → create a new directory and name it service.

  5. Copy the prunsrv.exe and prunmgr .exe paste it into to the service directory.

  6. In order to configure OrientDB as Windows service, you have to execute a short script that uses the prusrv.exe as a Windows service.

  7. Before defining the Windows Services, you have to rename prunsrv and prunmgr according to the name of the service. For e.g. OrientDBGraph and OrientDBGraphw respectively. Here OrientDBGraph is the name of the service.

  8. Copy the following script into the file named installService.bat and place it into %ORIENTDB_HOME%\service\ directory.

:: 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

该脚本需要两个参数 -

The script requires two parameters −

  1. The location of jvm.dll, for e.g. C:\ProgramFiles\java\jdk1.8.0_66\jre\bin\server\jvm.dll

  2. The location of OrientDB installation for e.g. C:\orientdb-community-2.1.9

  3. The service is installed when you execute the OrientDBGraph.exe file (Original prunsrv) and double-click on it.

  4. Use the following command to install services into 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

打开任务管理器服务,您将看到其中有已注册服务名称的以下屏幕截图。

Open the Task Manager services, you will find the following screenshot with the registered service name is in it.

task manager

Step 4 − Verifying OrientDB Installation

此步骤将通过以下步骤验证 OrientDB 数据库服务器安装。

This step verifies the OrientDB database server installation using the following steps.

  1. Run the server.

  2. Run the console.

  3. Run the studio.

这根据操作系统而异。

This is unique according to the operating system.

In Linux

按照给定的步骤验证 Linux 中的 OrientDB 安装。

Follow the given procedure for verifying OrientDB installation in Linux.

Running the server − 您可以使用以下命令启动服务器。

Running the server − You can use the following command to start the server.

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

或者,您可以使用以下命令将 OrientDB 服务器启动为 UNIX 守护程序。

Or you can use the following command to start the OrientDB server as UNIX daemon.

$ service orientdb start

如果安装成功,您将收到以下输出。

If it is installed successfully, you will receive the following output.

          .
          .`        `
          ,      `:.
         `,`    ,:`
         .,.   :,,
         .,,  ,,,
    .    .,.:::::  ````                                 :::::::::     :::::::::
    ,`   .::,,,,::.,,,,,,`;;                      .:    ::::::::::    :::    :::
    `,.  ::,,,,,,,:.,,.`  `                       .:    :::      :::  :::     :::
     ,,:,:,,,,,,,,::.   `        `         ``     .:    :::      :::  :::     :::
      ,,:.,,,,,,,,,: `::, ,,   ::,::`   : :,::`  ::::   :::      :::  :::    :::
       ,:,,,,,,,,,,::,:   ,,  :.    :   ::    :   .:    :::      :::  :::::::
        :,,,,,,,,,,:,::   ,,  :      :  :     :   .:    :::      :::  :::::::::
  `     :,,,,,,,,,,:,::,  ,, .::::::::  :     :   .:    :::      :::  :::     :::
  `,...,,:,,,,,,,,,: .:,. ,, ,,         :     :   .:    :::      :::  :::     :::
    .,,,,::,,,,,,,:  `: , ,,  :     `   :     :   .:    :::      :::  :::     :::
      ...,::,,,,::.. `:  .,,  :,    :   :     :   .:    :::::::::::   :::     :::
           ,::::,,,. `:   ,,   :::::    :     :   .:    :::::::::     ::::::::::
           ,,:` `,,.
          ,,,    .,`
         ,,.     `,                                          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]

Running the console − 您可以使用以下命令在控制台下运行 OrientDB。

Running the console − You can use the following command to run the OrientDB under console.

$ orientdb

如果安装成功,您将收到以下输出。

If it is installed successfully, you will receive the following output.

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>

Running the Studio − 启动服务器后,您可以在浏览器中使用以下 URL ( http://localhost:2480/ )。您将看到以下屏幕截图。

Running the Studio − After starting the server you can use the following URL (http://localhost:2480/) on your browser. You will get the following screenshot.

running studio

In Windows

按照给定的步骤验证 Windows 中的 OrientDB 安装。

Follow the given procedure for verifying OrientDB installation in Windows.

Running the server − 您可以使用以下命令启动服务器。

Running the server − You can use the following command to start the server.

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

如果安装成功,您将收到以下输出。

If it is installed successfully, you will receive the following output.

          .
          .`        `
          ,      `:.
         `,`    ,:`
         .,.   :,,
		 .,,  ,,,
    .    .,.:::::  ````                                 :::::::::     :::::::::
    ,`   .::,,,,::.,,,,,,`;;                      .:    ::::::::::    :::    :::
    `,.  ::,,,,,,,:.,,.`  `                       .:    :::      :::  :::     :::
     ,,:,:,,,,,,,,::.   `        `         ``     .:    :::      :::  :::     :::
      ,,:.,,,,,,,,,: `::, ,,   ::,::`   : :,::`  ::::   :::      :::  :::    :::
       ,:,,,,,,,,,,::,:   ,,  :.    :   ::    :   .:    :::      :::  :::::::
        :,,,,,,,,,,:,::   ,,  :      :  :     :   .:    :::      :::  :::::::::
  `     :,,,,,,,,,,:,::,  ,, .::::::::  :     :   .:    :::      :::  :::     :::
  `,...,,:,,,,,,,,,: .:,. ,, ,,         :     :   .:    :::      :::  :::     :::
    .,,,,::,,,,,,,:  `: , ,,  :     `   :     :   .:    :::      :::  :::     :::
      ...,::,,,,::.. `:  .,,  :,    :   :     :   .:    :::::::::::   :::     :::
           ,::::,,,. `:   ,,   :::::    :     :   .:    :::::::::     ::::::::::
           ,,:` `,,.
          ,,,    .,`
         ,,.     `,                                          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]

Running the console − 您可以使用以下命令在控制台下运行 OrientDB。

Running the console − You can use the following command to run OrientDB under console.

> %ORIENTDB_HOME%\bin\console.bat

如果安装成功,您将收到以下输出。

If it is installed successfully, you will receive the following output.

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\>

Running the Studio − 启动服务器后,您可以在浏览器中使用以下 URL ( http://localhost:2480/ )。您将看到以下屏幕截图。

Running the Studio − After starting the server you can use the following URL (http://localhost:2480/) on your browser. You will get the following screenshot.

running studio