首頁  >  文章  >  系統教程  >  在 Ubuntu 16.04 上安裝 OrientDB

在 Ubuntu 16.04 上安裝 OrientDB

王林
王林轉載
2024-01-16 12:08:00660瀏覽
導讀 通常在我們提及資料庫的時候,想到的是兩個主要的分類:使用用於使用者和應用程式之間進行對接的一種被稱為結構化查詢語言(Structured Query Language ,縮寫SQL)的關聯式資料庫管理系統(Relational Data base Management System,縮寫RDBMS) 以及非關聯式資料庫管理系統(non-relational database management systems 或稱為NoSQL 資料庫)。

這兩種模型在如何處理(儲存)資料的方面存在著巨大的差異。

關係型資料庫管理系統

在關聯式模型中(如 MySQL,或其分支 MariaDB),一個資料庫是一個表格的集合,其中每個表包含一個或多個以列組織的資料分類。資料庫的每行包含一個唯一的資料實例,其分類由列定義。

舉個例子,想像一個包含客戶的表。每一行相當於一個客戶,而其中的每一列分別對應名字、地址以及其他所必須的資訊。

而另一個表格可能是包含訂單、產品、客戶、日期以及其它的種種。而這個資料庫的使用者則可以獲得一個滿足其需求的視圖,例如一個客戶在一個特定的價格範圍購買產品的報表。

非關係型資料庫管理系統

在非關係型資料庫(或稱為不僅僅是資料庫Not only SQL)管理系統中,資料庫被設計為使用不同的方式儲存數據,例如文件儲存、鍵值對儲存、圖形關係儲存以及其他方式儲存。使用此種形式實現的資料庫系統專門用於大型資料庫叢集和大型 Web 應用。現今,非關係型資料庫被用於某些大公司,如Google和亞馬遜。

文件儲存資料庫

#文檔儲存資料庫是將資料以文檔的形式儲存。這種類型的運用通常表現為 JavaScript 和 JSON,實際上,XML 和其他形式的儲存也是可以被採用的。這裡的例子就是 MongoDB。

鍵值對儲存資料庫

#這是一個由唯一的鍵key配對一個值value的簡單模型。這個系統在高速緩存方面具有高性能和高度可擴展性。這裡的例子包括 BerkeleyDB 和 MemacacheDB。

圖形關係資料庫

#如其名,這種資料庫透過使用圖graph模型儲存數據,這意味著資料透過節點和節點之間的互連進行組織。這是一個可以隨著時間的推移和使用而發展的靈活模型。這個系統應用於那些強調映射關係的地方。這裡的例子有 IBM Graphs、Neo4j 以及 OrientDB。

OrientDB

OrientDB 是一個多模式的非關係型資料庫管理系統。正如開發它的公司所說的「它是一個將圖形關係與文件、鍵值對、反應性、物件導向和地理空間模型結合在一起的可擴展的、高效能的資料庫」。

OrientDB 也支援 SQL ,經過擴充功能可以用來操作樹和圖。

內容

目標
這個教學旨在教導大家如何在執行 Ubuntu 16.04 的伺服器上下載並設定 OrientDB 社群版。

下載 OrientDB

我們可以從最新的服務端透過輸入下面的指令來下載最新版本的 OrientDB。

$ wget -O orientdb-community-2.2.22.tar.gz http://orientdb.com/download.php?file=orientdb-community-2.2.22.tar.gz&os=linux

這裡下載的是一個包含預編譯二進位的壓縮包,所以我們可以使用 tar 指令來操作解壓縮它:

$ tar -zxf orientdb-community-2.2.22.tar.gz

將從中提取出來的資料夾整體移動到 /opt:

# mv orientdb-community-2.2.22 /opt/orientdb
啟動 OrientDB 伺服器

啟動 OrientDB 伺服器需要執行 orientdb/bin/ 目錄下的 shell 腳本:

# /opt/orientdb/bin/server.sh

如果你是第一次開啟 OrientDB 伺服器,安裝程式也會顯示一些提示訊息,以及提醒你設定 OrientDB 的 root 使用者密碼:

+---------------------------------------------------------------+
| WARNING: FIRST RUN CONFIGURATION |
+---------------------------------------------------------------+
| This is the first time the server is running. Please type a |
| password of your choice for the 'root' user or leave it blank |
| to auto-generate it. |
| |
| To avoid this message set the environment variable or JVM |
| setting ORIENTDB_ROOT_PASSWORD to the root password to use. |
+---------------------------------------------------------------+
Root password [BLANK=auto generate it]: ********
Please confirm the root password: ********

在完成這些後,OrientDB 資料庫伺服器將成功啟動:

INFO OrientDB Server is active v2.2.22 (build fb2b7d321ea8a5a5b18a82237049804aace9e3de). [OServer]

從現在開始,我們需要用第二個終端機來與 OrientDB 伺服器互動。

若要強制停止 OrientDB 執行 Ctrl C 即可。

配置守護程式

此時,我們可以認為 OrientDB 只是一串 shell 腳本,可以用編輯器開啟 /opt/orientdb/bin/orientdb.sh:

# $EDITOR /opt/orientdb/bin/orientdb.sh

在它的首段,我們可以看到:

#!/bin/sh
# OrientDB service script
#
# Copyright (c) OrientDB LTD (http://orientdb.com/)
# chkconfig: 2345 20 80
# description: OrientDb init script
# processname: orientdb.sh
# You have to SET the OrientDB installation directory here
ORIENTDB_DIR="YOUR_ORIENTDB_INSTALLATION_PATH"
ORIENTDB_USER="USER_YOU_WANT_ORIENTDB_RUN_WITH"

我們需要設定ORIENTDB_DIR 以及 ORIENTDB_USER.

然後建立一個用戶,例如我們建立一個名為 orientdb 的用戶,我們需要輸入下面的指令:

# useradd -r orientdb -s /sbin/nologin

orientdb 就是我們在 ORIENTDB_USER 處輸入的使用者。

再更改 /opt/orientdb 目錄的所有權:

# chown -R orientdb:orientdb /opt/orientdb

改變伺服器設定檔的權限:

# chmod 640 /opt/orientdb/config/orientdb-server-config.xml
下載系統守護程式服務

OrientDB 的壓縮套件包含一個服務檔案 /opt/orientdb/bin/orientdb.service。我們將其複製到 /etc/systemd/system 資料夾下:

# cp /opt/orientdb/bin/orientdb.service /etc/systemd/system

編輯該服務文件:

# $EDITOR /etc/systemd/system/orientdb.service

其中 [service] 内容块看起来应该是这样的:

[Service]
User=ORIENTDB_USER
Group=ORIENTDB_GROUP
ExecStart=$ORIENTDB_HOME/bin/server.sh

将其改成如下样式:

[Service]
User=orientdb
Group=orientdb
ExecStart=/opt/orientdb/bin/server.sh

保存并退出。

重新加载系统守护进程:

# systemctl daemon-reload

启动 OrientDB 并使其开机自启动:

# systemctl start orientdb
# systemctl enable orientdb

确认 OrientDB 的状态:

# systemctl status orientdb

上述指令应该会输出:

● orientdb.service - OrientDB Server
Loaded: loaded (/etc/systemd/system/orientdb.service; disabled; vendor preset: enabled)
Active: active (running) ...

流程就是这样了!OrientDB 社区版成功安装并且正确运行在我们的服务器上了。

总结

在这个指导中,我们看到了一些关系型数据库管理系统(RDBMS)以及非关系型数据库管理系统(NoSQL DBMS)的简单对照。我们也安装 OrientDB 社区版的服务器端并完成了其基础的配置。

这是我们部署完全的 OrientDB 基础设施的第一步,也是我们用于管理大型系统数据的起步。


以上是在 Ubuntu 16.04 上安裝 OrientDB的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:linuxprobe.com。如有侵權,請聯絡admin@php.cn刪除