2025-08-18 - Migrate Neo4j Database To New Version
(Redirected from 2025-08-03 - Graoh Use Case : Relationship)
Jump to navigation
Jump to search
Overview
- Backup old data
- Stop the old Neo4j server.
- Download file .dump backup data
- Install the new version of Neo4j.
- Upload file.dump back to new sever on EC2
- Start the new Neo4j server.
How To Move Neo4j Graph Database to new version
- For Upgrade version Neo4j (eg. 4.x → 5.x) by using same database:
Preparation and Backup
- Backup Instance neo4j ver.4
- EC2 page >> instances >> click "instances graph want to backup” >> Action >> Image and template >> create image (AMI)
- After create image (AMI) will be create Snapshot and Volumes link with that (AMI)
- Connect your database
Note!: can connect your old database for download file.dump then connect new database for install new version
- Example:
* ssh -i GraphHandler-ver-05.pem -L 7687:<Private IPv4 address>:7687 ec2-user@<Public IPv4 address>
------- or ------
* ssh -i /home/proudx/yourPath/GraphHandler-ver-04.pem ec2-user@<Public IPv4 address>
—------------- Using Command for run on neo4j ver.4 —-------------
cd ls // for check path cd neo4j // or //cd /usr/share/neo4j
- Check your current Neo4j version
./bin/neo4j --version
- Stop neo4j old version
./bin/neo4j stop —----or Back to: —----- [ec2-user@<Private Ip> /]$ export NEO4J_CONF=/etc/neo4j sudo systemctl stop neo4j // sudo service neo4j stop
- Create folder for backup
cd share sudo mkdir backup // create folder cd backup
- Backup your database:
./bin/neo4j-admin dump --database=neo4j --to=/path/to/backup/
— or –
/home/ec2-user/neo4j/bin/neo4j-admin database dump neo4j --to-path=/home/ec2-user/backup
- Download file.dump
scp -i ~/GraphHandler-ver-05.pem ec2-user@3.150.38.73:/home/ec2-user/backup/neo4j.dump ~/Downloads/
—- or —
proudx@proudx:~/JangProgramer$ scp -i /home/proudx/JangProgramer/<key pair>ec2-user@<public ip address>/home/ec2-user/backup/neo4j.dump ~/Downloads/
—------------- Using Command for run on neo4j ver.5 —-------------
Connect Database Neo4j Version5
ssh -i /home/proudx/JangProgramer/GraphHandler-ver-05.pem ec2-user@<Public IPv4 address>
Install Neo4j Version5 on EC2 - Note!: can install before this
wget https://dist.neo4j.org/neo4j-community-5.23.0-unix.tar.gz tar -xvzf neo4j-community-5.23.0-unix.tar.gz mv neo4j-community-5.23.0 neo4j5
- install java- version
sudo yum install java-17-amazon-corretto -y
- Upload file to ec2
scp -i /home/proudx/JangProgramer/<key pair>/home/proudx/Downloads/neo4j.dump ec2-user@<public key>/home/ec2-user/
./bin/neo4j-admin database load neo4j --from-path=../backup --overwrite-destination
- Upgrade the store format
./bin/neo4j-admin database migrate neo4j
Start and Verify
./bin/neo4j start
- Set password if not set
./bin/cypher-shell -u neo4j -p <password> "MATCH (n) RETURN count(n);"
Deploy Update Instance
- Note!: when dump data to neo4j ver.5 completed
In resource
- sls remove : resource
- if error on stack , because can not delete subnet
- comment section VPC subnet in app > file function.yml before
- Deploy app
In serverless config.yml
- Edit AMI section > iz_ImageId: ami-xxx // new AMI that backup from version5 (test)
- Deploy : resource // deploy back to service EC2
On EC2 Page : Will create new instance the old instance will be terminated
- Copy information from new instance to change
- iz_neo4jPort: Private IP // eg. bolt://172.16.10.60:7687
- iz_securityGroupIds : xxxx
- subnetId (a-b-c)
iz_subnetIds1a: xxxxx iz_subnetIds1b: yyyyy iz_subnetIds1c: zzzzz
- Open section VPC subnet in app > file function.yml
- Deploy app // deploy back to service