...
Code Block |
---|
# From your developer machine log into the server aws ssm start-session --target i-026c4881c032096e0 --region us-east-2 # This process needs to be completed as root sudo su - docker pull 747101682576.dkr.ecr.us-east-2.amazonaws.com/r2d2-server:prod # Stop the running service. systemctl stop r2d2.service # Remove the current container. docker rm r2d2-api-service # Re-start the prod service container. docker run -d --name r2d2-api-service -p 80:80 \ -e MYSQL_USER='r2d2' \ -e MYSQL_DATABASE='r2d2' \ -e MYSQL_HOST='r2d2-api-prod-rdsinstance-eja4eofrohvy.cg24vilqoa8w.us-east-2.rds.amazonaws.com' \ 747101682576.dkr.ecr.us-east-2.amazonaws.com/r2d2-server:prod \ run_r2d2_app --port 80 --nodebug # Restart the systemd service. systemctl start r2d2.service |
Accessing the RDS SQL database
The RDS database cannot be accessed from the public internet and must be accessed from one of our dev servers using a ssm shell login.
1) Log into the dev server (see quick reference)
2) Fetch the server password from the parameters in our cloud formation stack (see link in quick refrence)
3) From the dev server execute this command, using the password retrieved above
Code Block |
---|
mysql -h r2d2-api-prod-rdsinstance-eja4eofrohvy.cg24vilqoa8w.us-east-2.rds.amazonaws.com -u admin -p |
Load "dev" server data onto r2d2 database
This should not be done! This procedure was used to test the R2D2 database prior to release and is documented here for historical context and in case some of these steps have useful analogs for other work.
Code Block |
---|
For the localhost server container, can we pre-load r2d2-data and the r2d2 mysql user so
that end users just download the container and execute it on port 8080? Basically execute
the setup database script from r2d2/scripts.
Update crontabs on all platforms (experiment scrubber)
- Platforms include derecho, discover, hercules, orion, s4
- Update venv used by crontabs to use r2d2-client and not r2d2
Create username and api keys for all users
- We will have to massage the user database table since some humans have more than one username
- We need an api key generator and a way to send these api keys to the user
Go to dev server dump dev database into IAC bucket
- Access astromech-nonprod
$ aws ssm start-session --target i-0e97feb060f886e43 --region us-east-2
$ sudo su ubuntu && cd ~
- Use password "local-server-root-password" (only works on dev server)
- DATE=$(date "+%Y%m%dT%H%M%SZ")
- mysqldump -h 127.0.0.1 -u root -p --databases r2d2 > r2d2-dev-backup-${DATE}.sql
- aws s3 cp r2d2-dev-backup-20250205T171114Z.sql s3://jcsda-usaf-iac-artifacts/r2d2/
Log into prod server and load database with dev data
- Login and load data
- ssm login command (see quick ref)
- sudo su ubuntu && cd ~
- aws s3 cp s3://jcsda-usaf-iac-artifacts/r2d2/r2d2-dev-backup-20250205T171114Z.sql ./r2d2-dev-backup.sql
- Get password cloud formation console parameters
- Log into server
- mysql -h r2d2-api-prod-rdsinstance-eja4eofrohvy.cg24vilqoa8w.us-east-2.rds.amazonaws.com -u admin -p
- Run these sql commands
CREATE DATABASE r2d2;
USE r2d2;
source /home/ubuntu/r2d2-dev-backup.sql |