Book Image

Neo4j High Performance

By : Sonal Raj
Book Image

Neo4j High Performance

By: Sonal Raj

Overview of this book

Table of Contents (15 chapters)
Neo4j High Performance
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Configure Neo4j for Amazon clusters


The most popular thing among the cloud deployment platforms has been Amazon Web Services (AWS), particularly on their EC2 cluster-computing systems. These services are not only easy to set up but offer a wide range of services and support that make the life of admins a lot easier in the long run.

Neo4j, like a lot of other databases, is quite easy to configure and set up on an AWS server. In this section, we outline the deployment process for a Neo4j instance on Amazon EC2 (short for Elastic Compute Cloud). This process requires you to have a valid AWS account and be familiar with launching instances. If you feel you need to level up your experience with AWS, I would recommend that you follow the official guide of Amazon so that you are able to connect with your instance with SSH; the official guide is available at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html.

You will also need a copy of the latest stable version of Neo4j for Unix Systems. The community edition will suffice for developmental purposes. The latest downloads can be found at http://www.neo4j.org/download. You can then perform the following steps:

  1. You need to open the AWS management console and select Ubuntu Server 12.04.1 LTS 64-bit or start a basic 32-bit Linux instance. You could start an Ubuntu AMI but it does not include a Java installation, which is a key dependency of Neo4j, so you've got to install it manually.

  2. In the Instance Details section, select m1.large as the type and make sure that Availability Zone is set to any of the us-east regions. A new security group needs to be created or you can use the default one and configure a new security rule for the port to be used by the Neo4j server.

  3. When the instance is launched, a TCP rule is created on the 7474 port used by Neo4j with 0.0.0.0/0 as the source address. What we did was open the 7474 port for all external access (with 0.0.0.0 being the universal identifier). If you intend to use the Neo4j REST API by remote calls from another server, then for security reasons you can change the source field to that of the external server. The 22 port also needs to be open for SSH.

Now, it's time to install Neo4J into the system; let's do this by performing the following steps:

  1. Open a terminal on your local system where we downloaded Neo4j. We now copy or transfer the archive to the AWS server using the scp command:

    scp -i filename.pem neo4j-community-2.1.2-unix.tar.gz ec2-user@PUBLIC_DNS_OF_INSTANCE:/home/ec2-user
    
  2. You will need to provide the absolute path to your pem key file, which is typically found in ~/.ssh, the filename of the Neo4j server, and the public DNS of your EC2 instance (ec2-user by default). Next, we establish a connection with our EC2 instance using SSH:

    ssh -i filename.pem ec2-user@PUBLIC_DNS_OF_INSTANCE
    
  3. Extract the archive contents for the Neo4j server:

    tar xvfz neo4j-community-2.1.2-unix.tar.gz
    
  4. You need to move the content into /usr/local and change the folder name to neo4j:

    sudo mv neo4j-community-2.1.2-unix.tar.gz /usr/local/neo4j
    
  5. You now need to enable external access to the Neo4j server by editing the Neo4j configurations file. You need to open neo4j-server.properties under the conf directory of the master folder and append the following line:

    org.neo4j.server.webserver.address = 0.0.0.0
    

    This creates an open connection for anyone to access the Neo4j server. For restricted access, you can specify the IP of the machine, which will act as the source.

  6. Finally, the server is started from the installation directory using the following command:

    sudo ./bin/neo4j start
    

A startup script can be created to automate the server initiation. To check whether the deployment succeeded, you need to pop up a browser on your local machine and key in http://PUBLIC_DNS_OF_INSTANCE:7474.

This should direct you to the Monitoring and Management console of Neo4j on your AWS server. Voilà! We're done.