OrientDB是一个免费开源的NoSQL数据库管理系统。与以关系表格形式存储数据的关系数据库管理系统不同,NoSQL以表格形式以外的形式存储数据,表格形式可以是文档形式或图形形式。OrientDB附带了一个集成的基于web的图形用户界面,可以通过web浏览器轻松管理数据库。它支持ACID事务以及原子操作,并轻松返回具有相互连接文档的完整图。它的查询语言基于SQL构建,支持三种不同的索引算法,以提高性能。
先决条件
最小的CentOS 7服务器。
Root权限。本指南以root用户身份编写,如果您以sudo用户身份登录,请运行sudo-i。
更新基础系统
在安装任何软件包之前,建议您使用以下命令更新软件包和存储库。
yum -y update
系统更新后,您可以继续安装OrientDB所需的依赖项。
安装JAVA
OrientDB支持OpenJDK和Oracle JAVA,在本教程中,我们将把最新版本的Oracle JAVA安装到服务器中。运行以下命令下载RPM包。
wget --no-cookies --no-check-certificate --header "Cookie:oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm"
如果没有安装wget,可以运行yum-y install wget来安装wget。现在使用以下命令安装下载的RPM。
yum -y localinstall jdk-8u144-linux-x64.rpm
现在,您可以使用以下命令检查Java版本。
java -version
您将得到以下输出。
[root@liptan-pc ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
您还需要检查是否设置了JAVA_HOME环境变量。运行以下命令。
echo $JAVA_HOME
如果得到null或空白输出,则需要手动设置JAVA_HOME变量。使用您最喜欢的编辑器编辑.bash_profile文件。在本教程中,我们将使用nano编辑器。运行以下命令,使用nano编辑.bash_profile。
nano ~/.bash_profile
现在在文件末尾添加以下行。
export JAVA_HOME=/usr/java/jdk1.8.0_144/
export JRE_HOME=/usr/java/jdk1.8.0_144/jre
现在使用以下命令获取文件。
source ~/.bash_profile
现在,您可以再次运行echo$JAVA_HOME命令来检查是否设置了环境变量。
[root@pc ~]# echo $JAVA_HOME
/usr/java/jdk1.8.0_144/
安装OrientDB
建议以自己的用户身份运行OrientDB,为进程创建一个隔离的环境。运行以下命令为OrientDB创建用户。
adduser orientdb -d /opt/orientdb
上面的命令将创建用户orientedb,并将其主目录设置为/opt/orientedb。
现在,您可以通过运行以下命令下载OrientDB二进制存档。
cd/opt/orientedb/
wget https://orientdb.com/download.php?file=orientdb-community-importers-2.2.25.tar.gz -O orientdb.tar.gz
您始终可以通过访问OrientDB下载页面来查找文件最新版本的链接。
现在,通过运行以下命令提取存档。
tar -xf orientdb.tar.gz
上述命令将把存档解压缩到orientedb-community-importers-2.2.25目录中。通过运行以下命令将所有文件移动到根目录。
mv orientdb-community-importers*/* .
通过运行清理安装目录和存档。
rm -rf orientdb-community-importers*/ orientdb.tar.gz
现在,通过运行以下命令为OrientDB用户提供适当的权限。
chown -R orientdb:orientdb /opt/orientdb
OrientDB现在已安装在您的服务器上。
启动服务器
OrientDB为您提供了一个启动服务器的安装程序脚本。切换到OrientDB用户。
su - orientdb
现在,通过运行以下命令启动服务器。
bin/server.sh
系统将要求您设置OrientDB根用户的密码。请确保使用强密码。
+---------------------------------------------------------------+
| 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: ***********
如果服务器成功启动,您应该得到以下输出。
2017-08-05 12:48:04:444 INFO OrientDB Studio available at http://108.61.201.197:2480/studio/index.html [OServer]
2017-08-05 12:48:04:445 INFO OrientDB Server is active v2.2.25 (build 72a35a4bb42c4ca33272e7a59ad4c7a1d3ee859d). [OServer]
要停止执行,您可以同时按下ctrl+C按钮。通过运行Exit命令退出到root用户。
配置OrientDB系统服务
虽然OrientDB可以使用启动脚本启动和管理,但为了确保服务器在故障和启动时自动启动,您需要配置Systemd服务。通过运行以下命令创建新的systemd服务。
nano /etc/systemd/system/orientdb.service
现在用以下内容填充文件。
[Unit]
Description=OrientDB service
After=network.target
[Service]
Type=simple
ExecStart=/opt/orientdb/bin/server.sh
User=orientdb
Group=orientdb
Restart=always
RestartSec=9
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=orientdb
[Install]
WantedBy=multi-user.target
现在,您可以使用以下命令启动OrientDB:
systemctl start orientdb
要将OrientDB配置为在启动时自动启动,请使用。
systemctl enable orientdb
要检查OrientDB服务是否正确启动,可以运行以下命令来检查OrientDB的状态。
systemctl status orientdb
您应该得到类似于下图所示的输出。
[root@liptan-pc ~]# systemctl status orientdb
? orientdb.service - OrientDB service
Loaded: loaded (/etc/systemd/system/orientdb.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2017-08-05 17:34:40 UTC; 15s ago
Main PID: 6939 (java)
CGroup: /system.slice/orientdb.service
??6939 /bin/java -d64 -server -Xms2G -Xmx2G -Djna.nosys=true -XX:+HeapDumpOnOutOfMemoryError -XX:MaxDirectMe...
Aug 05 17:34:43 liptan-pc orientdb[6939]: 2017-08-05 17:34:43:477 INFO Installing dynamic plugin 'orientdb-telepo...ager]
Aug 05 17:34:43 liptan-pc orientdb[6939]: 2017-08-05 17:34:43:504 INFO [OVariableParser.resolveVariables] Error o...gies]
Aug 05 17:34:43 liptan-pc orientdb[6939]: 2017-08-05 17:34:43:573 WARNI Authenticated clients can execute any kind...eter]
Aug 05 17:34:43 liptan-pc orientdb[6939]: 2017-08-05 17:34:43:578 INFO OrientDB Studio available at http://108.61...rver]
Hint: Some lines were ellipsized, use -l to show in full.
此外,我们还将创建一个指向OrientDB脚本的软链接,该脚本将启动OrientDB的控制台。这将使我们能够轻松切换到OrientDB控制台。运行以下命令。
ln -s /opt/orientdb/bin/console.sh /usr/bin/orientdb
现在,您可以通过运行以下命令连接到OrientDB控制台。
orientdb
您的终端应该更改为orientedb,您应该得到以下输出:
[root@liptan-pc ~]# orientdb
OrientDB console v.2.2.25 (build 72a35a4bb42c4ca33272e7a59ad4c7a1d3ee859d) https://www.orientdb.com
Type 'help' to display all the supported commands.
Installing extensions for GREMLIN language v.2.6.0
orientdb>
您可以通过运行以下命令退出OrientDB提示符:
exit
Access OrientDB工作室
OrientDB Studio是一个基于web的GUI工具,便于管理员轻松安装OrientDB。它与OrientDB包一起发货。启动OrientDB服务器后,Studio也会随之启动。
要访问OrientDB Studio,请在您最喜欢的浏览器中打开以下网址。
http://your-server-IP:2480
如果您遇到任何错误,则可能是防火墙正在运行,您需要允许端口2480通过防火墙。运行以下命令为端口2480添加例外,然后重新加载防火墙以应用更改。
firewall-cmd --zone=public --permanent --add-port=2480/tcp
firewall-cmd --reload
您将看到以下网页。
![图片[1]_如何在CentOS 7上安装OrientDB NoSQL数据库_马特资源网](http://www.iamlz.com/wp-content/uploads/2025/03/1742609082696.png)
要创建新数据库,请单击new DB按钮,您将看到以下界面。
![图片[2]_如何在CentOS 7上安装OrientDB NoSQL数据库_马特资源网](http://www.iamlz.com/wp-content/uploads/2025/03/1742609102059.png)
提供数据库和root的名称作为服务器用户,并提供您在初始运行期间设置的root用户的密码。单击CREATE DATABASE以创建新数据库。
数据库将自动创建,您将被带到仪表板来管理数据库。
![图片[3]_如何在CentOS 7上安装OrientDB NoSQL数据库_马特资源网](http://www.iamlz.com/wp-content/uploads/2025/03/1742609118899.png)
在“浏览”选项卡中,您可以在数据库上运行查询并获取结果。
![图片[4]_如何在CentOS 7上安装OrientDB NoSQL数据库_马特资源网](http://www.iamlz.com/wp-content/uploads/2025/03/1742609136388.png)
在“模式”选项卡中,您可以添加和编辑数据库的表模式。
![图片[5]_如何在CentOS 7上安装OrientDB NoSQL数据库_马特资源网](http://www.iamlz.com/wp-content/uploads/2025/03/1742609150089.png)
在“安全”选项卡中,您可以向数据库添加或删除用户。
结论
在本教程中,我们在CentOS 7服务器上安装了OrientDB。您可以使用此数据库以NoSQL格式存储数据。要了解更多关于OrientDB的信息,您可以访问OrientDB网站。
暂无评论内容