Configuring Databases
Shipped with the MidVision application are some sample scripts that allow users to quickly configure and create a database. The database instance creation is often carried out by a Database Administration function but the values used within the scripts could be communicated to that function.
Configuring DB2
These scripts make use of some Java classes that manage the database scripts and can determine if the database is up to date. Subsequent releases might require additional scripts to be run, using the maintain-db2-db.sh (or bat) scripts will ensure only new scripts are run in.
The following steps give an example of how a user with sufficient database privileges could create and populate the MidVision database.
NOTE: MidVision is not licenced to supply the DB2 connector library files db2jcc-3.4.65.jar and db2jcc-license-3.4.65.jar. To run tomcat with a DB2 database, copy these Jar files from the DB2 installation into the directory %MV_HOME%/web-apps/tomcat/lib. To populate the DB2 database using the scripts below then also copy these Jar files from the DB2 installation into the directory %MV_HOME%/web-apps/db/lib.
- Create a database user e.g. on Linux create user rddbusr with: useradd -g db2iadm1 rddbusr
- Stop your midvision application (if it is running)
- Switch user (su) to a db2 admin user (db2inst1 by default)
- Ensure the db2admin user has write permission on the web-apps directory (chmod 777 if necessary).
- For first time database install run the install_db2_db.sh (or bat) script and fill in the details (leave as default unless you have a preference). Note this option will drop any existing database of the same name so treat with caution
- Run the maintain-db2-db.sh (or bat) script. If you run this for the first time use "installNew" action - this will run SQL script which creates all tables used by RapidDeploy. If you are upgrading your RD version and you are aware of any updates in database (see Changes Report ) run this script with default action "updateDatabase". This will run in any newly added database scripts.This can be done as any user with access to the script file
- Run reorg-local-db2-db.sh script
- As the owning user Edit the rapiddeploy.properties found in %MV_HOME%/bin
- uncomment all the DB2 settings
- Update the userid and password fields
- comment out the HSQL settings and disable built in server
- comment out the JNDI settings
- Start the web application
Configuring Oracle
Oracle does not require an operating system user. You do however need access to the Oracle sys account userid and password.
If your Databases are managed by a centralised database team it is unlikely you will have the necessary access to create the MidVision schema. In that instance the scripts can be given to your database administrators who may choose to use them as a basis for creating the schema. The procedure below can then be followed from ignoring Step 3 by the application owner running as the MidVision service id.
- Stop your midvision application (if it is running)
- Set the following variable export JRE_HOME=path to your Sun 1.8 version of jre
- For first time database install run the install_oracle_db.sh (or bat) script and fill in the details (leave as default unless you have a preference). Note this option will drop any existing database of the same name so treat with caution.
- For subsequent database data updates run the maintain-oracle-db.sh (or bat) script. This will run in any newly added database scripts. This can be done as any user with access to the script file and enclosing directory.
- As the owning user Edit the rapiddeploy.properties found in %MV_HOME%/bin
- uncomment all the Oracle settings
- update userid and password as appropriate from step 3 and optionally the URL as per your RAC requirements (see below)
- comment out the HSQL settings and disable built in server
- Start the web application
Considerations for Oracle
RAC Considerations
When using Oracle RAC (Real Application Cluster) a different URL format is required for installing the database and using the MidVision extensions. This requires some alteration to the maintain-oracle-db.sh script and/or the %MV_HOME%/bin/rapiddeploy.properties files.
Standard URL (find in maintain-oracle-db.sh script):
jdbc:oracle:thin:@$ORACLE_HOSTNAME:$ORACLE_PORT:$ORACLE_SID
RAC Format:
jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = RD_DB_HOST_NAME)(PORT = RD_DB_PORT_NUMBER))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME=RD_DB_SERVICE_NAME)))
Where:
- RD_DB_HOST_NAME = The host where the orcale database in installed
- RD_DB_PORT_NUMBER = The listener port to connect to
- RD_DB_SERVICE_NAME = The service name
For example:
jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.245.229.108)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME=rapiddeploy-db.mycompany.co.uk))) jdbc:oracle:thin:@(DESCRIPTION=(load_balance=on)(ADDRESS = (PROTOCOL = TCP)(HOST = rddb1a.test.midvision.com)(PORT = 1521))(ADDRESS=(PROTOCOL = TCP)(HOST = rddb1b.test.midvision.com)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = rddbdb.test.midvision.com)))
NB: Note, this requires you to enter the SERVICE when prompted for the SID when running the script. These can be the same but contact your DBAs for the SERVICE name.
Alternate Script Runner Factory
Occasionally there are problems connecting to ORACLE using the default SQLPlus mechanism. JDBC can be used to execute database updates as follows
Within the maintain-oracle-db.sh script change the script runner factory change:
-Dcom.midvision.rapiddeploy.db.script.runner.ScriptRunner.factory=com.midvision.rapiddeploy.db.script.runner.SqlPlusScriptRunnerFactory
to
-Dcom.midvision.rapiddeploy.db.script.runner.ScriptRunner.factory=com.midvision.rapiddeploy.db.script.runner.JdbcScriptRunnerFactory
Importing the schema manually
It is possible for the DBA to run the scripts manually. Typically you will need to run 3 scripts, in order, these being:
- Create the schema user and roles:
${MV_HOME}/web-apps/db/bin/create-oracle-db.sql
- Import the complete DDL for your version, e.g.
${MV_HOME}/web-apps/db/scripts/oracle_v3_3/incremental/v_3.3/3.3.01_new-data-model-from-scratch.sql
- Compile triggers for your version, e.g.
${MV_HOME}/web-apps/db/scripts/oracle_v3_3/postprocessing/1.0.01_compile-all-triggers.sql