在Ubuntu 14.04上安装配置OrientDB数据库
OrientDB是多模型、支持文挡数据库和图形数据库管理的NoSQL数据库。它使用Java实现的,所以可以在任何主流操作系统上运行。它完全兼容ACID。下面我们在Ubuntu 14.04上安装OrientDB。
第一步:安装Oracle Java
OrientDB是Java语言编写,所以需要Java运行环境,最低要求java版本为1.6。 建议安装Java8,我安装的就是这个版本。
添加PPA:
sudo add-apt-repository ppa:webupd8team/java
更新软件包列表:
sudo apt-get update
安装Oracle Java,使用下面特别的包安装,会把它设置为默认的JRE。在安装过程中需要接受协议:
sudo apt-get install oracle-java8-set-default
安装完,确认Java版本:
java -version
第二步:下载安装OrientDB
在这一步里,安装最新的OrientDB,目前版本为2.2.10
wget https://orientdb.com/download.php?file=orientdb-community-2.2.10.tar.gz
下载的tar包中包含编译好的OrientDB,你只需要把它解压的适当的位置即可,我把它放到/opt目录下:
sudo tar -xf download.php?file=orientdb-community-2.1.8.tar.gz -C /opt
解压后它的名称为orientdb-community-2.1.3,改为orientdb:
sudo mv /opt/orientdb-community-2.1.8 /opt/orientdb
第三步:启动orientdb服务
进入安装完成的目录:
cd /opt/orientdb
启动服务:
sudo bin/server.sh
在第一启动时需要为root用户设置密码。输出如下:
这个服务监听两个端口2424(binary连接)和2480(HTTP连接),使用如下命令查询:
sudo netstat -plunt | grep 2424
# tcp6 0 0 :::2424 :::* LISTEN 2674/java
sudo netstat -plunt | grep 2480
# tcp6 0 0 :::2480 :::* LISTEN 2674/java
第四步:连接到数据库(终端)
$ sudo /opt/orientdb/bin/console.sh
OrientDB console v.2.1.8 (build 2.1.x@r; 2015-12-17 11:51:38+0100) www.orientdb.com
Type 'help' to display all the supported commands.
Installing extensions for GREMLIN language v.2.6.0
orientdb>
登陆root用户:
orientdb> connect remote:127.0.0.1 root passwd
Connecting to remote Server instance [remote:127.0.0.1] with user 'root'...OK
orientdb {server=remote:127.0.0.1/}>
退出:
orientdb {server=remote:127.0.0.1/}> exit
现在我们已经完成了OrientDB的安装,手动启动服务并连接。这并没有问题,但是我们不想每次重启服务器都需要手动启动orientdb,我们想让它随系统自动启动,就像其他后台驻留进程一样。下面来设置OrientDB自动自动。
在终端按CTRL-C结束OrientDB服务的运行。
第五步:配置OrientDB
为OrientDB服务创建一个orientdb用户,下面这条命令也创建了一个同名的组:
sudo useradd -r orientdb -s /bin/false
改变程序的归属用户和组:
sudo chown -R orientdb:orientdb /opt/orientdb
修改/opt/orientdb/bin/orientdb.sh:
sudo vim /opt/orientdb/bin/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"
usage() {
echo "Usage: `basename $0`: <start|stop|status>"
exit 1
}
修改ORIENTDB_DIT(让这个脚本可以找到程序位置)和ORIENTDB_USER(程序以哪个用户执行):
ORIENTDB_DIR="/opt/orientdb"
ORIENTDB_USER="orientdb"
在这个脚本下面,start函数里,注释掉
#su $ORIENTDB_USER -c "cd "$ORIENTDB_DIR/bin"; /usr/bin/nohup ./server.sh 1>../log/orientdb.log 2>../log/orientdb.err &"
把下面一行粘贴到注释行的下面:
sudo -u $ORIENTDB_USER sh -c "cd "$ORIENTDB_DIR/bin"; /usr/bin/nohup ./server.sh 1>../log/orientdb.log 2>../log/orientdb.err &"
同样的,在stop函数里注释掉:
#su -c "cd "$ORIENTDB_DIR/bin"; /usr/bin/nohup ./shutdown.sh 1>>../log/orientdb.log 2>>../log/orientdb.err &" - $ORIENTDB_USER
替换为:
sudo -u $ORIENTDB_USER sh -c "cd "$ORIENTDB_DIR/bin"; /usr/bin/nohup ./shutdown.sh 1>>../log/orientdb.log 2>>../log/orientdb.err &"
关闭保存文件。
编辑/opt/orientdb/config/orientdb-server-config.xml:
sudo vim /opt/orientdb/config/orientdb-server-config.xml
我们需要修改storages,添加如下字段:
<storages>
<storage path="memory:temp" name="temp" userName="username" userPassword="password" loaded-at-startup="true" />
</storages>
username和password是你的登录认证,你可以用它登录数据库。在它的下面就是root用户。
保存退出。改变权限:
sudo chmod 640 /opt/orientdb/config/orientdb-server-config.xml
第六步:设置启动脚本
拷贝脚本:
sudo cp /opt/orientdb/bin/console.sh /usr/bin/orientdb
sudo cp /opt/orientdb/bin/orientdb.sh /etc/init.d/orientdb
cd /etc/init.d
更新启动脚本:
sudo update-rc.d orientdb defaults
设置完成,启动服务:
$ sudo service orientdb start
Starting OrientDB server daemon...
检查状态:
$ sudo service orientdb status
OrientDB server daemon is running with PID: 3077
如果服务没有启动,去/opt/orientdb/log目录查看错误信息。
第七步:连接OrientDB Studio
在浏览器输入http://server-ip-address:2480网址连接OrientDB Studio。
如果网页加载完成,你应该能看到登录界面,用root或刚才设置的用户登录:
如果网页没有加载,有可能防火墙屏蔽了2480端口。在防火墙中加入规则
-A INPUT -p tcp --dport 2480 -j ACCEPT
重新加载防火墙
Share the post "在Ubuntu 14.04上安装配置OrientDB数据库"
相关文章
转载于:https://my.oschina.net/u/2935389/blog/874001