This document describes the necessary tools and steps needed for the installation of JChem Choral in AWS RDS and Fargate environment.
Oracle RDS with Admin password
AWS rights
Local or EC2 Instance (AppServer) with
AWS CLI
Docker
Terraform
SQLDeveloper
AppServer connection to Oracle RDS
Familiarity with
An RDS database running with a user that the Choral service can use to create its backend data. In this docs this user will be referred to as <RDS user> and <RDS password>.
Fargate service CPU and memory capacity is limited, you can check if the suggested values do not exceed Fargate’s capacity. If memory seems insufficient, you can uncheck caching options to lower memory requirements. If it still exceeds Fargate’s capacity then our recommendation would be to run Choral service in an EC2 instance as it is described in this documentation.
The installation is twofold, we fake the application service for initialization using a local or EC2 instance. We create the application service in Fargate which will serve the database and replace the local fake application service with this one.
During the installation we make the following steps:
The first (partial) installation of Choral will be executed here. RDS is set as database and a local machine or an EC2 instance is applied for the application service.
RDS instance is accessed by the local machine or by the EC2 instance.
Use SQLdeveloper.
The application service is initialized by the without SQL script execution (8b) method.
Have Oracle RDS in place
Create indexuser with indexuserpassword passwd
CREATE USER <RDS_USER> IDENTIFIED BY <RDS_PASSWORD>;
GRANT connect, resource to <RDS_USER>;
GRANT unlimited tablespace to <RDS_USER>;
Example:
CREATE USER indexuser IDENTIFIED BY indexuserpassword;
GRANT connect, resource to indexuser;
GRANT unlimited tablespace to indexuser;
Local or EC2 (AppServer) installation of the service
Connection to RDS is OK (tunnel)
configure config/choral.conf in order to store index in Oracle
# write back to oracle
com.chemaxon.jchem.psql.scheme=gcrdb
com.chemaxon.jchem.psql.gcrdb.isSingleTable=true
com.chemaxon.jchem.psql.gcrdb.singleTableName=engine_data
com.chemaxon.jchem.psql.gcrdb.sqlBuilderProvider=ORACLE
com.chemaxon.jchem.psql.gcrdb.jdbcUrl=jdbc:oracle:thin:@localhost:1521/test
com.chemaxon.jchem.psql.gcrdb.user=<RDS_USER>
com.chemaxon.jchem.psql.gcrdb.password=<RDS_PASSWORD>
localhost is set below since the RDS is tunneled
choral.init.oracleUrl=jdbc:oracle:thin:@localhost:1521:<SID>
choral.init.grantingUser=ADMIN
Memory settings
License file, see step 5
Molecule type, see step 7
Initialize server without SQL script execution
./init-choral-service
This step serves for the docker image creation. Please take care of the configuration of the docker file and of entrypoint.sh. Copy the Choral installer - referenced in docker file - also into the directory where the docker build will be issued.
Create docker image
Please see the provided docker file and entrypoint.sh example. These can be used as customizable templates to build a docker image usable for AWS Fargate service. entrypoint.sh is used by the docker image to initialize Choral application properties via fix values and environment variables.
<RDS_USER> and <RDS_PASSWORD> should be set as JDBC_USER and JDBC_PASSWORD environment variables along with the RDS database endpoint as JDBC_URL.
The default values of the caching properties are the same that can be found at JChem Engines cache and memory calculator by default. A container created from this image also starts the Choral service and can write the logs in AWS if e.g. Cloudwatch is configured and LOG environment variable is set to true. Time between sending log messages can be set with SLEEP_TIME_WHEN_LOG environment variable.
For setting the license
docker build --build-arg="CHORAL_VERSION=<CHORAL_VERSION>" -t <LOCAL_IMAGE_NAME>:<LOCAL_TAG>
Set the same Choral version as the one used in step 1 (Local initialization of the service without SQL script execution).
AWS CLI is applied.
Create a repository for your docker image in ECR <ECR_REPOSITORY>
Log into ECR with Docker:
aws ecr get-login-password --profile <AWS_PROFILE> --region <AWS_REGION> | docker login --username AWS --password-stdin <ECR_ADRESS>
Example:
aws ecr get-login-password --profile 123456789012_Access --region eu-west-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.eu-west-1.amazonaws.com
Tag your local docker image on ECR:
docker tag <LOCAL_IMAGE_NAME>:<LOCAL_TAG> <ECR_ADRESS>/<ECR_REPOSITORY>:<ECR_TAG>
Example:
docker tag choralrds:latest 123456789012.dkr.ecr.eu-west-1.amazonaws.com/choralrds:latest
Push your local docker image to ECR:
docker push <ECR_ADRESS>/<ECR_REPOSITORY>:<ECR_TAG>
Example:
123456789012.dkr.ecr.eu-west-1.amazonaws.com/choralrds:latest
In this step the communication between ECR and RDS will be ensured.
Setup terraform files An example terraform module is available here
configuration in terraform files you should use the same configuration as above JDBC_USER=indexuser JDBC_PASSWORD=indexuserpassword provide the JDBC_USER as db_user, RDS access url as db_url in terraform.tfvars file:
db_url = "<RDS_URL>:1521:<DB_NAME>"
Example:
db_url = "jdbc:oracle:thin:@choral.abcdefgh1234.eu-west-1.rds.amazonaws.com:1521:TEST"
db_user = "indexuser"
the JDBC password is provided in ecs.tf file
"JDBC_PASSWORD" : "indexuserpassword"
The fargate route name, the Fargate service name are also set in the terraform files. The security groups are also created as defined in the terraform files.
Start Fargate cluster using terraform AWS credentials should be in place (was already required for logging into ECR with docker)
Allow module-test-sg security group to access ChoralSecurity security group on Oracle port (1521), this will allow the choral service on the Fargate cluster to access the database
Allow ChoralSecurity security group to access module-test-sg security group on port 8128, this will allow the database to access choral service on the Fargate cluster
Later if needed destroy Fargate cluster (if not used any more)
During this step SQL scripts for finishing the Choral configuration must be executed.
RDS is tunneled.
Use SQLdeveloper. The SQL scripts to be run are available in <choral_home>/sql/ folder.
Find the name of the router (Route 53 -> Hosted Zones -> Records) that handles the Fargate cluster (you can also find information about which target group the Fargate service was registered to in the Fargate service’s Deployment > Events tab), this will be referred to as Fargate_Route_name
Modify 2_http.sql
host => 'Fargate_Route_name',
Example:
host => 'choral-fargate-internal.jcb.cxcloud.io',
Execute as Admin user in RDS (scripts work on SQLDeveloper but not in SquirrelSQL or DBeaver)
or
Modify 5_indextype.sql
call set_choral_setting('HOST','Fargate_Route_name')
Example:
call set_choral_setting('HOST','choral-fargate-internal.jcb.cxcloud.io')
Execute as CHORAL_OWNER user in RDS (scripts work on SQLDeveloper but not in SquirrelSQL or DBeaver)
or
3_choral_settings.sql
4_logger.sql
5_indextype.sql
6_choral_idxstat.sql
7_choral_assoc_stats.sql
Test the installation by running 8_smoke_test.sql as CHORAL_OWNER.