Documentation ¶
Index ¶
- Constants
- Variables
- func ApexPasswordValidator(pwd string) bool
- func CheckDBConfig(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, ...) (bool, bool, bool, ctrl.Result)
- func CheckDBInitParams(sidbReadyPod corev1.Pod, r client.Reader, config *rest.Config, ...) (int, int, int, int, error)
- func ExecCommand(r client.Reader, config *rest.Config, podName string, namespace string, ...) (string, error)
- func FindPods(r client.Reader, version string, image string, name string, namespace string, ...) (corev1.Pod, int, []corev1.Pod, []corev1.Pod, error)
- func GenerateRandomString(n int) string
- func GetDatabaseOpenMode(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, ...) (string, error)
- func GetDatabaseRole(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, ...) (string, error)
- func GetDatabaseVersion(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, ...) (string, error)
- func GetDatabasesInDgConfig(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, ...) ([]string, string, error)
- func GetLabelsForController(version string, name string) map[string]string
- func GetNodeIp(r client.Reader, ctx context.Context, req ctrl.Request) string
- func GetPodNames(pods []corev1.Pod) []string
- func GetPrimaryDatabase(databases []string) string
- func GetSidPdbEdition(r client.Reader, config *rest.Config, ctx context.Context, req ctrl.Request) (string, string, string, error)
- func GetSqlClient(edition string) string
- func GetSqlpatchStatus(r client.Reader, config *rest.Config, readyPod corev1.Pod, ctx context.Context, ...) (string, string, string, error)
- func GetWatchNamespaces() map[string]bool
- func IsAnyPodWithStatus(pods []corev1.Pod, phase corev1.PodPhase) (bool, corev1.Pod)
- func IsDatabaseFound(sid string, databases []string, dgrole string) (bool, bool)
- func IsSourceDatabaseOnCluster(cloneFrom string) bool
- func IsStatusChanged(r client.Reader, objName string, namespace string, ctx context.Context, ...) wait.ConditionFunc
- func PatchService(config *rest.Config, namespace string, ctx context.Context, req ctrl.Request, ...) error
- func ResourceEventHandler() predicate.Predicate
- func StringToLines(s string) (lines []string, err error)
- func WaitForStatusChange(r client.Reader, objName string, namespace string, ctx context.Context, ...) error
Constants ¶
const AlterApexUsers string = "\nALTER SESSION SET CONTAINER=%[2]s;" +
"\n ALTER USER APEX_PUBLIC_USER IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK; " +
"\n ALTER USER APEX_REST_PUBLIC_USER IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK;" +
"\n ALTER USER APEX_LISTENER IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK;" +
"\nexec APEX_UTIL.set_workspace(p_workspace => 'INTERNAL');" +
"\nexec APEX_UTIL.EDIT_USER(p_user_id => APEX_UTIL.GET_USER_ID('ADMIN'), p_user_name => 'ADMIN', p_web_password => '%[1]s', p_new_password => '%[1]s');\n"
const AlterCpuCountCMD string = "echo -e \"alter system set cpu_count=%d; \" | %s"
const AlterProcessesCMD string = "echo -e \"alter system set processes=%d scope=spfile; \" | %s && " + CreateChkFileCMD + " && " + "echo -e \"SHUTDOWN IMMEDIATE; \n STARTUP MOUNT; \n ALTER DATABASE OPEN; \n ALTER PLUGGABLE DATABASE ALL OPEN; \n ALTER SYSTEM REGISTER;\" | %s && " + RemoveChkFileCMD
const AlterSgaPgaCMD string = "echo -e \"alter system set sga_target=%dM scope=both; \n alter system set pga_aggregate_target=%dM scope=both; \" | %s "
const ApexAdmin string = "BEGIN" +
"\napex_util.set_security_group_id(p_security_group_id => 10); APEX_UTIL.REMOVE_USER(p_user_name => 'ADMIN');" +
"\nCOMMIT;" +
"\nEND;" +
"\n/" +
"\nBEGIN" +
"\nAPEX_UTIL.create_user(p_user_name => 'ADMIN',p_email_address => 'admin@oracle.com',p_web_password => '%[1]s',p_developer_privs => 'ADMIN',p_failed_access_attempts => '5' ," +
" p_allow_app_building_yn => 'Y' ,p_allow_sql_workshop_yn => 'Y' ,p_allow_websheet_dev_yn => 'Y' , p_allow_team_development_yn => 'Y' , p_change_password_on_first_use => 'N' );" +
"apex_util.unlock_account(p_user_name => 'ADMIN'); APEX_UTIL.set_security_group_id( null );" +
"\nCOMMIT;" +
"\nEND;" +
"\n/" +
"\nALTER SESSION SET CONTAINER=%[2]s;" +
"\nBEGIN" +
"\napex_util.set_security_group_id(p_security_group_id => 10); APEX_UTIL.REMOVE_USER(p_user_name => 'ADMIN');" +
"\nCOMMIT;" +
"\nEND;" +
"\n/" +
"\nBEGIN" +
"\nAPEX_UTIL.create_user(p_user_name => 'ADMIN',p_email_address => 'admin@oracle.com',p_web_password => '%[1]s',p_developer_privs => 'ADMIN',p_failed_access_attempts => '5' ," +
" p_allow_app_building_yn => 'Y' ,p_allow_sql_workshop_yn => 'Y' ,p_allow_websheet_dev_yn => 'Y' , p_allow_team_development_yn => 'Y' , p_change_password_on_first_use => 'N' );" +
"apex_util.unlock_account(p_user_name => 'ADMIN'); APEX_UTIL.set_security_group_id( null );" +
"\nCOMMIT;" +
"\nEND;" +
"\n/"
const ArchiveLogFalseCMD string = CreateChkFileCMD + " && " + "echo -e \"SHUTDOWN IMMEDIATE; \n STARTUP MOUNT; \n ALTER DATABASE NOARCHIVELOG; \n SELECT log_mode FROM v\\$database; \n ALTER DATABASE OPEN;" + " \n ALTER PLUGGABLE DATABASE ALL OPEN; \n ALTER SYSTEM REGISTER;\" | %s && " + RemoveChkFileCMD
const ArchiveLogTrueCMD string = CreateChkFileCMD + " && " + "echo -e \"SHUTDOWN IMMEDIATE; \n STARTUP MOUNT; \n ALTER DATABASE ARCHIVELOG; \n SELECT log_mode FROM v\\$database; \n ALTER DATABASE OPEN;" + " \n ALTER PLUGGABLE DATABASE ALL OPEN; \n ALTER SYSTEM REGISTER;\" | %s && " + RemoveChkFileCMD
const CONTAINER_LISTENER_PORT int32 = 1521
const CONTAINER_TCPS_PORT int32 = 2484
const CheckModesSQL string = "" /* 162-byte string literal not displayed */
const ChownApex string = " chown oracle:oinstall /opt/oracle/oradata/${ORACLE_SID^^}/apex;"
const ClientWalletLocation string = "/opt/oracle/oradata/clientWallet/%s"
TCPS clientWallet location
const ClientWalletUpdate string = "sed -i -e 's/HOST.*$/HOST=%s)/g' -e 's/PORT.*$/PORT=%d)/g' ${ORACLE_BASE}/oradata/clientWallet/${ORACLE_SID}/tnsnames.ora"
TCPS clientWallet update command
const ConfigureApexRest string = "if [ -f ${ORDS_HOME}/config/apex/apex_rest_config.sql ]; then cd ${ORDS_HOME}/config/apex && " +
"echo -e \"%[1]s\n%[1]s\" | %[2]s ; else echo \"Apex Folder doesn't exist\" ; fi ;"
const CopyApexImages string = " ( while true; do sleep 60; echo \"Copying Apex Images...\" ; done ) & mkdir -p /opt/oracle/oradata/${ORACLE_SID^^}_ORDS/apex/images && " +
" cp -R /opt/oracle/oradata/${ORACLE_SID^^}/apex/images/* /opt/oracle/oradata/${ORACLE_SID^^}_ORDS/apex/images; chown -R oracle:oinstall /opt/oracle/oradata/${ORACLE_SID^^}_ORDS/apex; kill -9 $!;"
const CreateAdminPasswordFile string = "umask 177\n cat > admin.pwd <<EOF\n%s\nEOF\n umask 022"
const CreateChkFileCMD string = "touch \"${ORACLE_BASE}/oradata/.${ORACLE_SID}.nochk\" && sync"
const CreateDBRecoveryDestCMD string = "mkdir -p ${ORACLE_BASE}/oradata/fast_recovery_area"
const CreateDGMGRLScriptFile string = "umask 177\n echo -e \"%s\" > dgmgrl.cmd\n umask 022"
const CreateORDSSchemaSQL = "\nALTER SESSION SET CONTAINER=%[3]s;" +
"\nCREATE USER %[1]s IDENTIFIED BY \\\"%[2]s\\\";" +
"\nGRANT CONNECT, RESOURCE, DBA, PDB_DBA TO %[1]s;"
const CreateSIDlinkCMD string = "cd ${ORACLE_BASE}/oradata && test ! -e $ORACLE_SID && ln -s $(basename $PRIMARY_DB_CONN_STR)/$ORACLE_SID"
const DBA_GUID int64 = 54322
const DBShowConfigCMD string = "SHOW CONFIGURATION;"
const DataguardBrokerAddDBMaxAvailabilityCMD string = "ADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='SYNC';" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
"\nENABLE CONFIGURATION;"
const DataguardBrokerAddDBMaxPerformanceCMD string = "ADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='ASYNC';" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
"\nENABLE CONFIGURATION;"
const DataguardBrokerGetDatabaseCMD string = "SELECT DATABASE || ':' || DATAGUARD_ROLE AS DATABASE FROM V\\$DG_BROKER_CONFIG;"
const DataguardBrokerMaxAvailabilityCMD string = "CREATE CONFIGURATION dg_config AS PRIMARY DATABASE IS ${PRIMARY_SID} CONNECT IDENTIFIER IS ${PRIMARY_DB_CONN_STR};" +
"\nADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY LogXptMode='SYNC';" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='SYNC';" +
"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${PRIMARY_IP})(PORT=1521))" +
"(CONNECT_DATA=(SERVICE_NAME=${PRIMARY_SID}_DGMGRL)(INSTANCE_NAME=${PRIMARY_SID})(SERVER=DEDICATED)))';" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
"\nEDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;" +
"\nENABLE CONFIGURATION;"
const DataguardBrokerMaxPerformanceCMD string = "CREATE CONFIGURATION dg_config AS PRIMARY DATABASE IS ${PRIMARY_SID} CONNECT IDENTIFIER IS ${PRIMARY_DB_CONN_STR};" +
"\nADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY LogXptMode='ASYNC';" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='ASYNC';" +
"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${PRIMARY_IP})(PORT=1521))" +
"(CONNECT_DATA=(SERVICE_NAME=${PRIMARY_SID}_DGMGRL)(INSTANCE_NAME=${PRIMARY_SID})(SERVER=DEDICATED)))';" +
"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
"\nEDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;" +
"\nENABLE CONFIGURATION;"
const DisableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE disable"
Command to disable TCPS
const DropAdminUsersSQL string = "drop user C##DBAPI_CDB_ADMIN cascade;" +
"\ndrop user C##_DBAPI_PDB_ADMIN cascade;"
const EnableFSFOCMD string = "ENABLE FAST_START FAILOVER;"
const EnableORDSSchemaSQL string = "\nALTER SESSION SET CONTAINER=%[4]s;" +
"\nGRANT INHERIT PRIVILEGES ON USER SYS TO ORDS_METADATA;" +
"\nexec ORDS.enable_schema(p_enabled => %[2]s ,p_schema => '%[1]s',p_url_mapping_type => 'BASE_PATH',p_url_mapping_pattern => '%[3]s',p_auto_rest_auth => FALSE);"
const EnableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE"
Command to enable TCPS as a formatted string. The parameter would be the port at which TCPS is enabled.
const FlashBackFalseSQL string = "SELECT flashback_on FROM v\\$database;" +
"\nALTER DATABASE FLASHBACK OFF;" +
"\nSELECT flashback_on FROM v\\$database;"
const FlashBackTrueSQL string = "SELECT flashback_on FROM v\\$database;" +
"\nALTER DATABASE FLASHBACK ON;" +
"\nSELECT flashback_on FROM v\\$database;"
const ForceLoggingFalseSQL string = "SELECT force_logging FROM v\\$database;" +
"\nALTER DATABASE NO FORCE LOGGING;" +
"\nSELECT force_logging FROM v\\$database;"
const ForceLoggingTrueSQL string = "SELECT force_logging FROM v\\$database;" +
"\nALTER DATABASE FORCE LOGGING;" +
"\nALTER SYSTEM SWITCH LOGFILE;" +
"\nSELECT force_logging FROM v\\$database;"
const GetCheckpointFileCMD string = "find ${ORACLE_BASE}/oradata -maxdepth 1 -name .${ORACLE_SID}${CHECKPOINT_FILE_EXTN}"
const GetDBOpenMode string = "select open_mode from v\\$database;"
const GetDatabaseRoleCMD string = "SELECT DATABASE_ROLE FROM V\\$DATABASE; "
const GetEnterpriseEditionFileCMD string = "" /* 149-byte string literal not displayed */
const GetInitParamsSQL string = "column name format a20;" +
"\ncolumn display_value format a20;" +
"\nset linesize 100 pagesize 50;" +
"\nselect name,display_value from v\\$parameter where name in ('sga_target','pga_aggregate_target','cpu_count','processes') order by name asc;"
const GetORDSStatus string = "curl -sSkv -k -X GET https://localhost:8443/ords/_/db-api/stable/metadata-catalog/"
const GetPdbsSQL string = "select name from v\\$pdbs where name not like 'PDB\\$SEED' and open_mode like 'READ WRITE';"
const GetSessionInfoSQL string = "select s.sid || ',' || s.serial# as Info FROM v\\$session s, v\\$process p " +
"WHERE (s.username = 'ORDS_PUBLIC_USER' or " +
"s.username = 'APEX_PUBLIC_USER' or " +
"s.username = 'APEX_REST_PUBLIC_USER' or " +
"s.username = 'APEX_LISTENER' or " +
"s.username = 'C##_DBAPI_CDB_ADMIN' or " +
"s.username = 'C##_DBAPI_PDB_ADMIN' ) AND p.addr(+) = s.paddr;"
const GetSidPdbEditionCMD string = "echo $ORACLE_SID,$ORACLE_PDB,$ORACLE_EDITION;"
Get Sid, Pdbname, Edition for prebuilt db
const GetSqlpatchDescriptionSQL string = "" /* 135-byte string literal not displayed */
const GetSqlpatchStatusSQL string = "select status from dba_registry_sqlpatch order by action_time desc;"
const GetSqlpatchVersionSQL string = "select SOURCE_VERSION || ':' || TARGET_VERSION as versions from dba_registry_sqlpatch order by action_time desc;"
const GetStandardEditionFileCMD string = "" /* 145-byte string literal not displayed */
const GetUserORDSSchemaStatusSQL string = "alter session set container=%[2]s;" +
"\nselect 'STATUS:'||status as status from ords_metadata.ords_schemas where upper(parsing_schema) = upper('%[1]s');"
const GetVersionSQL string = "SELECT VERSION_FULL FROM V\\$INSTANCE;"
const InitORDSCMD string = "if [ -f $ORDS_HOME/config/ords/defaults.xml ]; then exit ;fi;" +
"\nexport APEXI=$ORDS_HOME/config/apex/images" +
"\n$ORDS_HOME/runOrds.sh --setuponly" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.auth.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.management.services.disabled false" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.admin.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property dbc.auth.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property restEnabledSql.active true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property db.serviceNameSuffix \"\" " +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InitialLimit 5" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.MaxLimit 20" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InactivityTimeout 300" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property feature.sdw true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property security.verifySSL false" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.maxRows 1000" +
"\nmkdir -p $ORDS_HOME/config/ords/conf" +
"\numask 177" +
"\necho db.cdb.adminUser=C##DBAPI_CDB_ADMIN AS SYSDBA > cdbAdmin.properties" +
"\necho db.cdb.adminUser.password=\"${ORACLE_PWD}\" >> cdbAdmin.properties" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu cdbAdmin.properties" +
"\nrm -f cdbAdmin.properties" +
"\necho db.adminUser=C##_DBAPI_PDB_ADMIN > pdbAdmin.properties" +
"\necho db.adminUser.password=\"${ORACLE_PWD}\">> pdbAdmin.properties" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu pdbAdmin.properties" +
"\nrm -f pdbAdmin.properties" +
"\necho -e \"${ORDS_PWD}\n${ORDS_PWD}\" > sqladmin.passwd" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war user ${ORDS_USER} \"SQL Administrator , System Administrator , SQL Developer , oracle.dbtools.autorest.any.schema \" < sqladmin.passwd" +
"\nrm -f sqladmin.passwd" +
"\numask 022"
const InitPrebuiltDbCMD string = "if [ ! -d /mnt/oradata/${ORACLE_SID} -a -d $ORACLE_BASE/oradata/${ORACLE_SID} ]; then cp -v $ORACLE_BASE/oradata/.${ORACLE_SID}$CHECKPOINT_FILE_EXTN /mnt/oradata && " +
" cp -vr $ORACLE_BASE/oradata/${ORACLE_SID} /mnt/oradata && cp -vr $ORACLE_BASE/oradata/dbconfig /mnt/oradata; fi "
const InitWalletCMD string = "if [ ! -f $ORACLE_BASE/oradata/.${ORACLE_SID}${CHECKPOINT_FILE_EXTN} ] || [ ! -f ${ORACLE_BASE}/oradata/dbconfig/$ORACLE_SID/.docker_%s ];" +
" then while [ ! -f ${WALLET_DIR}/ewallet.p12 ] || pgrep -f $WALLET_CLI > /dev/null; do sleep 0.5; done; fi "
const InstallApex string = "if [ -f /opt/oracle/oradata/${ORACLE_SID^^}/apex/apexins.sql ]; then ( while true; do sleep 60; echo \"Installing Apex...\" ; done ) & " +
" cd /opt/oracle/oradata/${ORACLE_SID^^}/apex && echo -e \"@apexins.sql SYSAUX SYSAUX TEMP /i/\" | %[1]s && kill -9 $!; else echo \"Apex Folder doesn't exist\" ; fi ;"
const InstallApexInContainer string = "cd ${ORDS_HOME}/config/apex/ && echo -e \"@apxsilentins.sql SYSAUX SYSAUX TEMP /i/ %[1]s %[1]s %[1]s %[1]s;\n" +
"@apex_rest_config_core.sql;\n" +
"exec APEX_UTIL.set_workspace(p_workspace => 'INTERNAL');\n" +
"exec APEX_UTIL.EDIT_USER(p_user_id => APEX_UTIL.GET_USER_ID('ADMIN'), p_user_name => 'ADMIN', p_change_password_on_first_use => 'Y');\n" +
"\" | sqlplus -s sys/%[2]s@${ORACLE_HOST}:${ORACLE_PORT}/%[3]s as sysdba;"
const IsApexInstalled string = "echo -e \"select 'APEXVERSION:'||version as version FROM DBA_REGISTRY WHERE COMP_ID='APEX';\"" +
" | sqlplus -s sys/%[1]s@${ORACLE_HOST}:${ORACLE_PORT}/%[2]s as sysdba;"
const KillSessionSQL string = "alter system kill session '%[1]s';"
const ListPdbSQL string = "SELECT NAME FROM V\\$PDBS;"
const ListenerEntry string = `` /* 705-byte string literal not displayed */
const LsnrNodePort string = "\"name\": \"listener\", \"protocol\": \"TCP\", \"port\": 1521, \"nodePort\": %d"
Payload section for listener node port
const LsnrPort string = "\"name\": \"listener\", \"protocol\": \"TCP\", \"port\": %d, \"targetPort\": 1521"
Payload section for listener port
const ModifyStdbyDBOpenMode string = "alter database recover managed standby database disconnect;"
const NoExternalIp string = "Node ExternalIP unavailable"
const ORACLE_GUID int64 = 54321
const ORACLE_UID int64 = 54321
const OpenPDBSeed = "alter pluggable database pdb\\$seed close;" +
"\nalter pluggable database pdb\\$seed open read only;"
const PDBTnsnamesEntry string = `` /* 169-byte string literal not displayed */
const PodMountsCmd string = "awk '$2 == \"%s\" {print}' /proc/mounts"
Check Mount in pods
const PrimaryTnsnamesEntry string = `` /* 193-byte string literal not displayed */
const ReconcileBlocked string = "ReconcileBlocked"
const ReconcileBlockedReason string = "LastReconcileCycleBlocked"
const ReconcileCompelete string = "ReconcileComplete"
const ReconcileCompleteReason string = "LastReconcileCycleCompleted"
const ReconcileError string = "ReconcileError"
const ReconcileErrorReason string = "LastReconcileCycleFailed"
const ReconcileQueued string = "ReconcileQueued"
const ReconcileQueuedReason string = "LastReconcileCycleQueued"
const RemoveAdminPasswordFile string = "rm -rf admin.pwd"
const RemoveChkFileCMD string = "rm -f \"${ORACLE_BASE}/oradata/.${ORACLE_SID}.nochk\""
const RemoveDGMGRLScriptFile string = "rm -rf dgmgrl.cmd"
const RemoveDataguardConfiguration string = "DISABLE FAST_START FAILOVER;" +
"\nEDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;" +
"\nREMOVE CONFIGURATION;"
const RemoveStandbyDBFromDGConfgCMD string = "DISABLE DATABASE ${ORACLE_SID};" +
"\nREMOVE DATABASE ${ORACLE_SID};"
const RenewCertsCMD string = EnableTcpsCMD
Command for TCPS certs renewal to prevent their expiry. It is same as the EnableTcpsCMD
const RunDatapatchCMD string = " ( while true; do sleep 60; echo \"Installing patches...\" ; done ) & if ! $ORACLE_HOME/OPatch/datapatch -skip_upgrade_check;" +
" then echo \"Datapatch execution has failed.\" ; else echo \"DONE: Datapatch execution.\" ; fi ; kill -9 $!;"
const SQLPlusCLI string = "sqlplus -s / as sysdba"
const SetAdminUsersSQL string = "CREATE USER C##DBAPI_CDB_ADMIN IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK CONTAINER=ALL;" +
"\nalter user C##DBAPI_CDB_ADMIN identified by \\\"%[1]s\\\" account unlock;" +
"\nGRANT DBA TO C##DBAPI_CDB_ADMIN CONTAINER = ALL;" +
"\nGRANT PDB_DBA TO C##DBAPI_CDB_ADMIN CONTAINER = ALL;" +
"\nCREATE USER C##_DBAPI_PDB_ADMIN IDENTIFIED BY \\\"%[1]s\\\" CONTAINER=ALL ACCOUNT UNLOCK;" +
"\nalter user C##_DBAPI_PDB_ADMIN identified by \\\"%[1]s\\\" account unlock;" +
"\nGRANT DBA TO C##_DBAPI_PDB_ADMIN CONTAINER = ALL;" +
"\nalter pluggable database pdb\\$seed close;" +
"\nalter pluggable database pdb\\$seed open read write force;"
const SetApexUsers string = "\numask 177" +
"\necho db.username=APEX_LISTENER > apexlistener" +
"\necho db.password=\"%[1]s\" >> apexlistener" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_al apexlistener" +
"\nrm -f apexlistener" +
"\necho db.username=APEX_REST_PUBLIC_USER > apexRestPublicUser" +
"\necho db.password=\"%[1]s\" >> apexRestPublicUser" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_rt apexRestPublicUser" +
"\nrm -f apexRestPublicUser" +
"\necho db.username=APEX_PUBLIC_USER > apexPublicUser" +
"\necho db.password=\"%[1]s\" >> apexPublicUser" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex apexPublicUser" +
"\nrm -f apexPublicUser" +
"\numask 022"
SetApexUsers is used to set Apex Users, pod that runs SetApexUsers is deleted and new ones is created.
const SetDBRecoveryDestSQL string = "SHOW PARAMETER db_recovery_file_dest;" +
"\nALTER SYSTEM SET db_recovery_file_dest_size=50G scope=both sid='*';" +
"\nALTER SYSTEM SET db_recovery_file_dest='${ORACLE_BASE}/oradata/fast_recovery_area' scope=both sid='*';" +
"\nSHOW PARAMETER db_recovery_file_dest;"
const SetupORDSCMD string = "$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.auth.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.management.services.disabled false" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.admin.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property dbc.auth.enabled true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property restEnabledSql.active true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property db.serviceNameSuffix \"\" " +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InitialLimit 5" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.MaxLimit 20" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InactivityTimeout 300" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property feature.sdw true" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property security.verifySSL false" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.maxRows 1000" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property pdb.open.asneeded true" +
"\numask 177" +
"\necho db.cdb.adminUser=C##DBAPI_CDB_ADMIN AS SYSDBA > cdbAdmin.properties" +
"\necho db.cdb.adminUser.password=\"%[4]s\" >> cdbAdmin.properties" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu cdbAdmin.properties" +
"\nrm -f cdbAdmin.properties" +
"\necho db.username=APEX_LISTENER > apexlistener" +
"\necho db.password=\"%[2]s\" >> apexlistener" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_al apexlistener" +
"\nrm -f apexlistener" +
"\necho db.username=APEX_REST_PUBLIC_USER > apexRestPublicUser" +
"\necho db.password=\"%[2]s\" >> apexRestPublicUser" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_rt apexRestPublicUser" +
"\nrm -f apexRestPublicUser" +
"\necho db.username=APEX_PUBLIC_USER > apexPublicUser" +
"\necho db.password=\"%[2]s\" >> apexPublicUser" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex apexPublicUser" +
"\nrm -f apexPublicUser" +
"\necho db.adminUser=C##_DBAPI_PDB_ADMIN > pdbAdmin.properties" +
"\necho db.adminUser.password=\"%[4]s\">> pdbAdmin.properties" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu pdbAdmin.properties" +
"\nrm -f pdbAdmin.properties" +
"\necho -e \"%[1]s\n%[1]s\" > sqladmin.passwd" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war user ${ORDS_USER} \"SQL Administrator , System Administrator , SQL Developer , oracle.dbtools.autorest.any.schema \" < sqladmin.passwd" +
"\nrm -f sqladmin.passwd" +
"\numask 022" +
"\nsed -i 's,jetty.port=8888,jetty.secure.port=8443\\nssl.cert=\\nssl.cert.key=\\nssl.host=%[3]s,g' /opt/oracle/ords/config/ords/standalone/standalone.properties " +
"\nsed -i 's,standalone.static.path=/opt/oracle/ords/doc_root/i,standalone.static.path=/opt/oracle/ords/config/apex/images,g' /opt/oracle/ords/config/ords/standalone/standalone.properties"
SetupORDSCMD is run only for the FIRST TIME, ORDS is installed. Once ORDS is installed, we delete the pod that ran SetupORDSCMD and create new ones. Newly created pod doesn't run this SetupORDSCMD.
const StandbyDatabasePrerequisitesSQL string = "ALTER SYSTEM SET db_create_file_dest='/opt/oracle/oradata/';" +
"\nALTER SYSTEM SET db_create_online_log_dest_1='/opt/oracle/oradata/';" +
"\nALTER SYSTEM SWITCH LOGFILE;" +
"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
"\nALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;" +
"\nALTER SYSTEM SET dg_broker_config_file1='/opt/oracle/oradata/dbconfig/dr1${ORACLE_SID}.dat' scope=both;" +
"\nALTER SYSTEM SET dg_broker_config_file2='/opt/oracle/oradata/dbconfig/dr2${ORACLE_SID}.dat';" +
"\nALTER SYSTEM SET dg_broker_start=TRUE;"
const StandbyTnsnamesEntry string = `` /* 219-byte string literal not displayed */
const StatusCreating string = "Creating"
const StatusError string = "Error"
const StatusNotReady string = "Unhealthy"
const StatusPatching string = "Patching"
const StatusPending string = "Pending"
const StatusReady string = "Healthy"
const StatusUpdating string = "Updating"
const TcpsNodePort string = "\"name\": \"listener-tcps\", \"protocol\": \"TCP\", \"port\": 2484, \"nodePort\": %d"
Payload section for TCPS node port
const TcpsPort string = "\"name\": \"listener-tcps\", \"protocol\": \"TCP\", \"port\": %d, \"targetPort\": 2484"
Payload section for TCPS port
const ThreePortPayload string = "{\"spec\": { \"type\": \"%s\", \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s},{%s}]}}"
Service Patch Payloads Three port payload: one OEM express, one TCP and one TCPS port
const TlsCertsLocation string = "/run/secrets/tls_secret"
Location of tls certs
const TwoPortPayload string = "{\"spec\": { \"type\": \"%s\", \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s}]}}"
Two port payload: one OEM express, one TCP/TCPS port
const UninstallApex string = "" /* 129-byte string literal not displayed */
const UninstallORDSCMD string = "\numask 177" +
"\necho -e \"1\n${ORACLE_HOST}\n${ORACLE_PORT}\n1\n${ORACLE_SERVICE}\nsys\n%[1]s\n%[1]s\n1\" > ords.cred" +
"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war uninstall advanced < ords.cred" +
"\nrm -f ords.cred" +
"\numask 022" +
"\nrm -f /opt/oracle/ords/config/ords/defaults.xml" +
"\nrm -f /opt/oracle/ords/config/ords/credentials" +
"\nrm -rf /opt/oracle/ords/config/ords/conf" +
"\nrm -rf /opt/oracle/ords/config/ords/standalone" +
"\nrm -rf /opt/oracle/ords/config/ords/apex"
const UnzipApexOnORDSPod string = "" /* 194-byte string literal not displayed */
const UnzipApexOnSIDBPod string = "" /* 181-byte string literal not displayed */
const ValidateAdminPassword string = "conn sys/\\\"%s\\\"@${ORACLE_SID} as sysdba\nshow user"
const WalletCreateCMD string = "" /* 241-byte string literal not displayed */
const WalletDeleteCMD string = "rm -rf ${WALLET_DIR}"
const WalletEntriesCMD string = "umask 177\ncat > wallet.passwd <<EOF\n${WALLET_PWD}\nEOF\n mkstore -wrl ${WALLET_DIR} -createEntry oracle.dbsecurity.sysPassword %[1]s -createEntry oracle.dbsecurity.systemPassword %[1]s " +
"-createEntry oracle.dbsecurity.pdbAdminPassword %[1]s -createEntry oracle.dbsecurity.dbsnmpPassword %[1]s < wallet.passwd\nrm -f wallet.passwd\numask 022;"
const WalletPwdCMD string = "export WALLET_PWD=\"`openssl rand -base64 8`1\""
Variables ¶
var ErrNoReadyPod = errors.New("SingleInstanceDatabase has no ready pod currently")
Functions ¶
func ApexPasswordValidator ¶
Apex password validation function
func CheckDBConfig ¶
func CheckDBConfig(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, req ctrl.Request, edition string) (bool, bool, bool, ctrl.Result)
returns flashBackStatus,archiveLogStatus,forceLoggingStatus of Primary Pod
func CheckDBInitParams ¶
func ExecCommand ¶
func ExecCommand(r client.Reader, config *rest.Config, podName string, namespace string, containerName string, ctx context.Context, req ctrl.Request, nologCommand bool, command ...string) (string, error)
Execs into podName and executes command
func FindPods ¶
func FindPods(r client.Reader, version string, image string, name string, namespace string, ctx context.Context, req ctrl.Request) (corev1.Pod, int, []corev1.Pod, []corev1.Pod, error)
retuns Ready Pod,No of replicas ( Only running and Pending Pods) ,available pods , Total No of Pods of a particular CRD
func GetDatabaseOpenMode ¶
func GetDatabaseRole ¶
func GetDatabaseRole(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, req ctrl.Request) (string, error)
Fetch role by quering the DB
func GetDatabaseVersion ¶
func GetDatabaseVersion(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, req ctrl.Request) (string, error)
Returns Database version
func GetDatabasesInDgConfig ¶
func GetDatabasesInDgConfig(readyPod corev1.Pod, r client.Reader, config *rest.Config, ctx context.Context, req ctrl.Request) ([]string, string, error)
Returns the databases in DG config .
func GetLabelsForController ¶
getLabelsForController returns the labels for selecting the resources
func GetNodeIp ¶
Get Node Ip to display in ConnectionString Returns Node External Ip if exists ; else InternalIP
func GetPodNames ¶
getPodNames returns the pod names of the array of pods passed in
func GetPrimaryDatabase ¶
Returns a Primary Database in "databases" slice
func GetSidPdbEdition ¶
func GetSidPdbEdition(r client.Reader, config *rest.Config, ctx context.Context, req ctrl.Request) (string, string, string, error)
GetSidPdbEdition to display sid, pdbname, edition in ConnectionString
func GetSqlClient ¶
func GetSqlpatchStatus ¶
func GetSqlpatchStatus(r client.Reader, config *rest.Config, readyPod corev1.Pod, ctx context.Context, req ctrl.Request) (string, string, string, error)
Get Datapatch Status
func GetWatchNamespaces ¶
func IsAnyPodWithStatus ¶
Returns true if any of the pod in 'pods' is with pod.Status.Phase == phase
func IsDatabaseFound ¶
CHECKS IF SID IN DATABASES SLICE , AND ITS DGROLE
func IsSourceDatabaseOnCluster ¶
Is Source Database On same Cluster
func IsStatusChanged ¶
func IsStatusChanged(r client.Reader, objName string, namespace string, ctx context.Context, req ctrl.Request, object string, statusChange string) wait.ConditionFunc
returns a func() that returns true if an object is confirmed to be created or deleted . else false
func PatchService ¶
func PatchService(config *rest.Config, namespace string, ctx context.Context, req ctrl.Request, svcName string, payload string) error
Function for patching the K8s service with the payload. Patch strategy used: Strategic Merge Patch
func ResourceEventHandler ¶
Filter events that trigger reconcilation
func StringToLines ¶
Convert "sqlplus -s " output to array of lines
func WaitForStatusChange ¶
func WaitForStatusChange(r client.Reader, objName string, namespace string, ctx context.Context, req ctrl.Request, timeout time.Duration, object string, statusChange string) error
Poll up to timeout seconds for Object to change state Returns an error if the object never changes the state
Types ¶
This section is empty.