Skip to content

Instantly share code, notes, and snippets.

@steveodom
Last active December 13, 2015 16:59
Show Gist options
  • Select an option

  • Save steveodom/4944559 to your computer and use it in GitHub Desktop.

Select an option

Save steveodom/4944559 to your computer and use it in GitHub Desktop.
Notes on using AWS cloudformation to bootstrap a EC2 instance with Neo4J and Redis.

Neo4J at EC2 notes

Starting Instance

https://gist.github.com/steveodom/4944432 https://gist.github.com/steveodom/4944432/raw/43605f59343c7626665176334113a27c90068f2a/cf_template.json

Logging in

ssh -i neo4j.pem ubuntu@IPADDRESS

Where neo4j.pem is the location of your public key an

If you get a 'permissions too open error' on the key, do:

chmod 400 mykey.pem

Where things are located generally

#Config files

/etc/
eg(/etc/redis/redis.conf)
/etc/neo4j/

#The actual data /var/lib/

You can find where the neo4j directory is by going to the web console/server info. Then click on kernel (the left hand column). Then under StoryDirectory, you'll see something like: /var/lib/neo4j/data/graph.db/

CFN Files and Logs

Log file: /var/logs/

Script files: /var/lib/cloud/instance/scripts/

RESTARTING

/etc/init.d/neo4j-service restart
/etc/init.d/redis-server restart

TO STOP

/etc/init.d/neo4j-service stop
/etc/init.d/redis-server restart

MANUALLY BACKING UP NEO

/etc/init.d/neo4j-service stop
cd /var/lib/neo4j/data
tar -czf /backup/neo4j/130212.tar.gz graph.db/

Then to pull it down locally: scp -i neo4j.pem ubuntu@IPADDRESS:/backup/neo4j/130212.tar.gz .

UPLOADING

upload a file locally to ec2 instance

scp -r -i neo4j.pem 130212.tar.gz ubuntu@IPaddress:

DOWNLOADING

scp -r -i neo4j.pem  ubuntu@54.235.143.6:/backup/neo4j/2013-02-14.tar.gz .

I could not upload it as root or to a different directory. perhaps I should have made a directory so it'd be like: ubuntu@IPADDRESS:/backups

Installed unzip can't remember but if you type unzip and it's not install it will tell you how to install it. (apt-get install unzip)

This unzipped the zip file to my neo data directory. (stop the db first) #zip: unzip -d /var/lib/neo4j/data/graph.db/ a79fe8fca-1360623254.zip #tar /etc/init.d/neo4j-service stop tar -xvzf 130212.tar.gz -C /var/lib/neo4j/data/ rm 130212.tar.gz

Note: I had to change the ownership of all the files after I unzipped in the graph.db direct: chown -Rv neo4j:nogroup /var/lib/neo4j/data/graph.db/

MISC

DELETE this below: n/bash LOGFILE=/backup/neo4j/backup.log message() { message_date=$(date) echo "${message_date}: $1" >> $LOGFILE }

neo_service() { service neo4j-service $1 >> $LOGFILE }

set -e message "Starting cold backup." neo_service stop tar -czf /backup/neo4j/$(date +%F).tar.gz /var/lib/neo4j/data >> $LOGFILE 2>&1 neo_service start message "Completed cold backup."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment