OrientDB – Quick Guide ”; Previous Next OrientDB – Overview OrientDB is an Open Source NoSQL Database Management System. NoSQL Database provides a mechanism for storing and retrieving NO-relation or NON-relational data that refers to data other than tabular data such as document data or graph data. NoSQL databases are increasingly used in Big Data and real-time web applications. NoSQL systems are also sometimes called “Not Only SQL” to emphasize that they may support SQL-like query languages. OrientDB also belongs to the NoSQL family. OrientDB is a second generation Distributed Graph Database with the flexibility of Documents in one product with an open source of Apache 2 license. There were several NoSQL databases in the market before OrientDB, one of them being MongoDB. MongoDB vs OrientDB MongoDB and OrientDB contains many common features but the engines are fundamentally different. MongoDB is pure Document database and OrientDB is a hybrid Document with graph engine. Features MongoDB OrientDB Relationships Uses the RDBMS JOINS to create relationship between entities. It has high runtime cost and does not scale when database scale increases. Embeds and connects documents like relational database. It uses direct, super-fast links taken from graph database world. Fetch Plan Costly JOIN operations. Easily returns complete graph with interconnected documents. Transactions Doesn’t support ACID transactions, but it supports atomic operations. Supports ACID transactions as well as atomic operations. Query language Has its own language based on JSON. Query language is built on SQL. Indexes Uses the B-Tree algorithm for all indexes. Supports three different indexing algorithms so that the user can achieve best performance. Storage engine Uses memory mapping technique. Uses the storage engine name LOCAL and PLOCAL. OrientDB is the first Multi-Model open source NoSQL DBMS that brings together the power of graphs and flexibility of documents into a scalable high-performance operational database. OrientDB – Installation OrientDB installation file is available in two editions − Community Edition − OrientDB community edition is released by Apache under 0.2 license as an open source 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. This chapter explains the installation procedure of OrientDB community edition because it is open source. Prerequisites 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. Use the following steps to download and install OrientDB into your system. Step 1 − Download OrientDB Binary Setup File 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. The following screenshot shows the download page of OrientDB. You can download the zipped or tarred file by clicking the suitable operating system icon. On downloading, you will get the binary package in your Downloads folder. Step 2 − Extract and Install OrientDB Following is the procedure to extract and install OrientDB for different operating systems. In Linux 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 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 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 After download you will get orientdb-community-2.1.9.zip file in your Downloads folder. Extract the zip file using the zip extractor. Move the extracted folder into the C: directory. 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.9bin Step 3 − Configuring OrientDB Server as a Service 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 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. 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>” 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 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 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 Use the following command to know on which PID the OrientDB server daemon is running. $ service orientdb status 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 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
Category: orientdb
OrientDB – Rollback Database
OrientDB – Rollback Database ”; Previous Next In this chapter, you will learn how to roll back the un-committed transaction through the OrientDB command line interface. The following statement is the basic syntax of the Rollback database command. ROLLBACK Note − You can use this command only after connecting to a particular database and after beginning the transaction. Example In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will see the operation of rollback transaction and store a record using transactions. First, start the transaction using the following BEGIN command. orientdb {db = demo}> BEGIN Then, insert a record into an employee table with the values id = 12 and name = satish.P using the following command. orientdb> INSERT INTO employee (id, name) VALUES (12, ”satish.P”) You can use the following command to retrieve the records from the Employee table. orientdb> SELECT FROM employee WHERE name LIKE ”%.P” If this command is executed successfully, you will get the following output. —+——-+——————– # | ID | name —+——-+——————– 0 | 12 | satish.P —+——-+——————– 1 item(s) found. Query executed in 0.076 sec(s). You can now use the following command to Rollback this transaction. orientdb> ROLLBACK Check the select query again to retrieve the same record from the employee table. orientdb> SELECT FROM employee WHERE name LIKE ”%.P” If the rollback is executed successfully, you will get 0 records found in the output. 0 item(s) found. Query executed in 0.037 sec(s). Print Page Previous Next Advertisements ”;
OrientDB – Home
OrientDB Tutorial PDF Version Quick Guide Resources Job Search Discussion OrientDB is an Open Source NoSQL Database Management System, which contains the features of traditional DBMS along with the new features of both Document and Graph DBMS. It is written in Java and is amazingly fast. It can store 220,000 records per second on commodity hardware. In the following chapters of this tutorial, we will look closely at OrientDB, one of the best open-source, multi-model, next generation NoSQL product. Audience This tutorial is designed for software professionals who are willing to learn NoSQL Database in simple and easy steps. This tutorial will give a great understanding on OrientDB concepts. Prerequisites OrientDB is NoSQL Database technologies which deals with the Documents, Graphs and traditional database components, like Schema and relation. Thus it is better to have knowledge of SQL. Familiarity with NoSQL is an added advantage. Print Page Previous Next Advertisements ”;
OrientDB – Import Database
OrientDB – Import Database ”; Previous Next Whenever you want to import the database, you must use the JSON format exported file, which is generated by export command. In this chapter you can learn how to import the database from the OrientDB command line. The following statement is the basic syntax of the Import database command. IMPORT DATABASE <input file> Note − You can use this command only after connecting to a particular database. Example In this example, we will use the same database named ‘demo’ that we created in the previous chapter. You can use the following command to import the database to a file named ‘export-demo.gz’. orientdb {db = demo}> IMPORT DATABASE ./export-demo.export.gz If it is successfully executed, you will get the following output along with the successful notification. Database import completed in 11612ms Print Page Previous Next Advertisements ”;
OrientDB – Commit Database
OrientDB – Commit Database ”; Previous Next Similar to RDBMS, OrientDB also provides transaction concepts like Commit and Rollback. Commit refers to closing the transaction by saving all changes to the database. Rollback refers to recovering the database state to the point where you opened the transaction. The following statement is the basic syntax of the Commit database command. COMMIT Note − You can use this command only after connecting to a particular database and after beginning the transaction. Example In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will see the operation of commit transaction and store a record using transactions. First, start the transaction using the following BEGIN command. orientdb {db = demo}> BEGIN Then, insert a record into an employee table with the values id = 12 and name = satish.P using the following command. orientdb> INSERT INTO employee (id, name) VALUES (12, ”satish.P”) You can use the following command to commit the transaction. orientdb> commit If this transaction is successfully committed, you will get the following output. Transaction 2 has been committed in 4ms Print Page Previous Next Advertisements ”;
OrientDB – Info Database
OrientDB – Info Database ”; Previous Next This chapter explains how to get information of a particular database from the OrientDB command line. The following statement is the basic syntax of the Info command. info Note − You can use this command only after connecting to a particular database and it will retrieve the information of only the currently running database. Example In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will retrieve the basic information from demo database. You can use the following command to disconnect the database. orientdb {db = demo}> info If it is successfully disconnected, you will get the following output. Current database: demo (url = plocal:/opt/orientdb/databases/demo) DATABASE PROPERTIES ——————————–+———————————————+ NAME | VALUE | ——————————–+———————————————+ Name | null | Version | 14 | Conflict Strategy | version | Date format | yyyy-MM-dd | Datetime format | yyyy-MM-dd HH:mm:ss | Timezone | Asia/Kolkata | Locale Country | IN | Locale Language | en | Charset | UTF-8 | Schema RID | #0:1 | Index Manager RID | #0:2 | Dictionary RID | null | ——————————–+———————————————+ DATABASE CUSTOM PROPERTIES: +——————————-+——————————————–+ | NAME | VALUE | +——————————-+——————————————–+ | strictSql | true | +——————————-+——————————————–+ CLUSTERS (collections) ———————————+——-+——————-+—————-+ NAME | ID | CONFLICT STRATEGY | RECORDS | ———————————+——-+——————-+—————-+ Print Page Previous Next Advertisements ”;
OrientDB – Overview
OrientDB – Overview ”; Previous Next OrientDB is an Open Source NoSQL Database Management System. NoSQL Database provides a mechanism for storing and retrieving NO-relation or NON-relational data that refers to data other than tabular data such as document data or graph data. NoSQL databases are increasingly used in Big Data and real-time web applications. NoSQL systems are also sometimes called “Not Only SQL” to emphasize that they may support SQL-like query languages. OrientDB also belongs to the NoSQL family. OrientDB is a second generation Distributed Graph Database with the flexibility of Documents in one product with an open source of Apache 2 license. There were several NoSQL databases in the market before OrientDB, one of them being MongoDB. MongoDB vs OrientDB MongoDB and OrientDB contains many common features but the engines are fundamentally different. MongoDB is pure Document database and OrientDB is a hybrid Document with graph engine. Features MongoDB OrientDB Relationships Uses the RDBMS JOINS to create relationship between entities. It has high runtime cost and does not scale when database scale increases. Embeds and connects documents like relational database. It uses direct, super-fast links taken from graph database world. Fetch Plan Costly JOIN operations. Easily returns complete graph with interconnected documents. Transactions Doesn’t support ACID transactions, but it supports atomic operations. Supports ACID transactions as well as atomic operations. Query language Has its own language based on JSON. Query language is built on SQL. Indexes Uses the B-Tree algorithm for all indexes. Supports three different indexing algorithms so that the user can achieve best performance. Storage engine Uses memory mapping technique. Uses the storage engine name LOCAL and PLOCAL. OrientDB is the first Multi-Model open source NoSQL DBMS that brings together the power of graphs and flexibility of documents into a scalable high-performance operational database. Print Page Previous Next Advertisements ”;
OrientDB – Config Database
OrientDB – Config Database ”; Previous Next In this chapter, you can learn how to display the configuration of a particular database through OrientDB command line. This command is applicable for both local and remote databases. Configuration information contains default cache either enabled or not, the size of that cache, the load factor value, max memory for map, node page size, pool minimum and maximum size, etc. The following statement is the basic syntax of the config database command. CONFIG Note − You can use this command only after connecting to a particular database. Example In this example, we will use the same database named ‘demo’ that we created in the previous chapter. You can use the following command to display the configuration of demo database. Orientdb {db = demo}> CONFIG If it is successfully executed, you will get the following output. LOCAL SERVER CONFIGURATION: +—————————————+————————-+ | NAME | VALUE | +—————————————+————————-+ | environment.dumpCfgAtStartup | false | | environment.concurrent | true | | environment.allowJVMShutdown | true | | script.pool.maxSize | 20 | | memory.useUnsafe | true | | memory.directMemory.safeMode | true | | memory.directMemory.trackMode | false | |……………………………….. | | | storage.lowestFreeListBound | 16 | | network.binary.debug | false | | network.http.maxLength | 1000000 | | network.http.charset | utf-8 | | network.http.jsonResponseError | true | | network.http.json | false | | tx.log.fileType | classic | | tx.log.synch | false | | tx.autoRetry | 1 | | client.channel.minPool | 1 | | storage.keepOpen | true | | cache.local.enabled | true | +—————————————+————————-+ orientdb {db = demo}> In the above list of configuration parameters, if you want to change any of the parameter value then you can do it from the command line easily using config set and get command. Config Set You can update the configuration variable value by using the CONFIG SET command. The following statement is the basic syntax of the config set command. CONFIG SET <config-variable> <config-value> Note − You can use this command only after connecting to a particular database. Example In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will modify the ‘tx.autoRetry’ variable value to 5. You can use the following command to set the configuration of demo database. orientdb {db = demo}> CONFIG SET tx.autoRetry 5 If it is successfully executed, you will get the following output. Local configuration value changed correctly Config Get You can display the configuration variable value by using the CONFIG GET command. The following statement is the basic syntax of the config get command. CONFIG GET <config-variable> Note − You can use this command only after connecting to a particular database. Example In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will try to retrieve the ‘tx.autoRetry’ variable value. You can use the following command to display the configuration of demo database. orientdb {db = demo}> CONFIG GET tx.autoRetry If it is successfully executed, you will get the following output. Local configuration: tx.autoRetry = 5 Print Page Previous Next Advertisements ”;
OrientDB – Connect Database
OrientDB – Connect Database ”; Previous Next This chapter explains how to connect to a particular database from the OrientDB command line. It opens a database. The following statement is the basic syntax of the Connect command. CONNECT <database-url> <user> <password> Following are the details about the options in the above syntax. <database-url> − Defines the URL of the database. URL contains two parts one is <mode> and the second one is <path>. <mode> − Defines the mode, i.e. local mode or remote mode. <path> − Defines the path to the database. <user> − Defines the user you want to connect to the database. <password> − Defines the password for connecting to the database. Example We have already created a database named ‘demo’ in the previous chapters. In this example, we will connect to that using the user admin. You can use the following command to connect to demo database. orientdb> CONNECT PLOCAL:/opt/orientdb/databases/demo admin admin If it is successfully connected, you will get the following output − Connecting to database [plocal:/opt/orientdb/databases/demo] with user ”admin”…OK Orientdb {db = demo}> Print Page Previous Next Advertisements ”;
OrientDB – Installation
OrientDB – Installation ”; Previous Next OrientDB installation file is available in two editions − Community Edition − OrientDB community edition is released by Apache under 0.2 license as an open source 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. This chapter explains the installation procedure of OrientDB community edition because it is open source. Prerequisites 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. Use the following steps to download and install OrientDB into your system. Step 1 − Download OrientDB Binary Setup File 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. The following screenshot shows the download page of OrientDB. You can download the zipped or tarred file by clicking the suitable operating system icon. On downloading, you will get the binary package in your Downloads folder. Step 2 − Extract and Install OrientDB Following is the procedure to extract and install OrientDB for different operating systems. In Linux 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 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 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 After download you will get orientdb-community-2.1.9.zip file in your Downloads folder. Extract the zip file using the zip extractor. Move the extracted folder into the C: directory. 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.9bin Step 3 − Configuring OrientDB Server as a Service 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 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. 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>” 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 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 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 Use the following command to know on which PID the OrientDB server daemon is running. $ service orientdb status 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 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. 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. Click the following link for Apache Common Daemons for windows. Click on common-daemon-1.0.15-bin-windows to download. 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. Go to OrientDB installation folder → create a new directory and name it service. Copy the prunsrv.exe and prunmgr .exe paste it into to the service directory. In order to configure OrientDB as Windows service, you have to execute a short script that uses the prusrv.exe as a Windows service. 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. 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 =