Overview
With pre-init and/or post-init scripts, it is possible to customize FlashGrid deployments by adding custom steps.
Examples:
- Linux OS hardening
- Creating Oracle database
- Configuring Oracle services
- Additional software installation
How it works
- Pre-init script(s) will run on the server (in a cluster, on each node) at the beginning of the init process before FlashGrid software initialization starts. Typical use cases are OS hardening or installing 3rd party software packages. The script(s) will run as root user. If multiple scripts are specified, then they will run serially in the order they are specified.
- Post-init script(s) will run on the server (in a cluster, on each node) at the end of the init process. Typical use cases include creating a database or configuring Oracle services. The script(s) will run as root user. If multiple scripts are specified, then they will run serially in the order they are specified.
The script files must be accessible from the same storage location (storage bucket/container) where Oracle installation files are located. The same script files can be used for different deployments. The scripts can be bash scripts or any executable files. Parameters for the scripts can be passed through the Launcher config file when generating the CloudFormation / ARM / Deployment Manager template.
Parameters
The following parameters can be added to the [nodes]
section of the FlashGrid Launcher config file:
pre_init_script_filenames = ['script.a', 'script.b' ... ]
post_init_script_filenames = ['script.c', 'script.d' ... ] pre_and_post_init_script_env = { 'var1': 'value1', 'var2': 'value2' ... }
Note that the following parameters have been deprecated, starting with Launcher version 21.11. Use the parameters above instead.
pre_init_script_filename = 'script.a' # deprecated
post_init_script_filename = 'script.b' # deprecated
The pre_and_post_init_script_env
parameter allows setting environment variables that are used in the scripts.
In the case of deploying the FlashGrid cluster, additionally, the following environment variables will be set automatically and can be used for executing node-specific actions inside your custom scripts:
FG_FIRST_NODE=yes/no
- check this variable to determine whether the node is the first database node in the cluster. This can be used when specific actions must be executed from one node only, e.g. creating a database.
FG_NODE_TYPE=database/db-only/quorum/storage
- check this variable to determine node type. This can be used when certain actions depend on node type, e.g. if action must be executed on database nodes only.
Example:
#!/bin/bash
run_dbca() {
sudo su - oracle -c '<replace this with this with your dbca script>'
}
main() {
if [[ $FG_FIRST_NODE == "yes" ]];
then
run_dbca
else
echo "This is not the first database node"
fi
}
main "$@"
Do not specify FG_FIRST_NODE
or FG_NODE_TYPE
in pre_and_post_init_script_env
.
Error handling
If the script returns a non-zero return code, then the FlashGrid initialization will be considered failed.
Troubleshooting
FlashGrid recommends logging the timestamp and the result of each action performed in the custom scripts in /tmp/pre_init.log and /tmp/post_init.log files.
If FlashGrid initialization fails in the presence of a pre-init and/or post-init script, the following actions are recommended:
- Check /tmp/fg_setup.log to determine whether the failure occurred before, during, or after executing the pre-init or post-init scripts.
- Try re-deploying the environment without the pre-init and post-init scripts. This will help to confirm whether one of the scripts has introduced the problem. Note that a pre-init script might introduce incompatibility and cause the subsequent init actions to fail even if the pre-init script completes successfully.
- Upload /tmp/fg_setup.log, /tmp/pre_init.log, and /tmp/post_init.log files to FlashGrid support, open a support ticket and share your custom scripts if possible.