oravirt / ansible-oracle-modules

Oracle modules for Ansible
MIT License
214 stars 159 forks source link

oracle_services: Unlucky RAC-like calls to srvctl on Single Server #166

Open jschampera opened 3 years ago

jschampera commented 3 years ago

oracle_services module may return unsuccessfully with

"msg": "Error modifying service. Command: /u01/app/oracle/product/19.3.0.0/db19300_prod/bin/srvctl modify service -d XD002A -s PROFAHR_ADMIN -modifyconfig -preferred None, stdout: PRKO-2002 : Invalid command line option: -modifyconfig\nPRKO-2002 : Invalid command line option: -preferred\n, stderr: "

After a bit of a research I found that the module automatically detects a GI by stating /etc/oracle/olr.loc and then uses srvctl to manage services. If GI is not detected, it uses DBMS_SERVICE package from within the database.

The calls to srvctl use parameters that look like it's designed for RAC usage (-preferred, -available, -modifyconfig, probably more). The problem here is that those options are unavailable on a non-RAC installation (tested only with 19c, so that's an assumption I can't verify at the moment - below is my srvctl modify service -h output).

A workaround might be to force the module to use DBMS_SERVICE, but there's no interface parameter for that. Will check how I can currently continue by a quick and dirty module modification for now.

I can't suggest a real fix since I don't know how to autodetect this.

srvctl modify service -h Modifies the configuration for the service.

Usage: srvctl modify service -db -service [-role [PRIMARY][,PHYSICAL_STANDBY][,LOGICAL_STANDBY][,SNAPSHOT_STANDBY]] [-policy {AUTOMATIC | MANUAL}] [-notification {TRUE | FALSE}] [-clbgoal {SHORT | LONG}] [-rlbgoal {NONE | SERVICE_TIME | THROUGHPUT}] [-failovertype {NONE | SESSION | SELECT | TRANSACTION | AUTO}] [-failovermethod {NONE | BASIC}] [-failoverretry ] [-failoverdelay ] [-failover_restore {NONE | LEVEL1}] [-edition ] [-pdb ] [-sql_translation_profile ] [-commit_outcome {TRUE | FALSE}] [-retention ] [replay_init_time ] [-tablefamilyid ] [-drain_timeout ] [-stopoption ] [-session_state {STATIC | DYNAMIC}] [-global_override] -db Unique name for the database -service Service name -role Role of the service (primary, physical_standby, logical_standby, snapshot_standby) -policy Management policy for the service (AUTOMATIC or MANUAL) -failovertype (NONE | SESSION | SELECT | TRANSACTION | AUTO) Failover type -failovermethod (NONE | BASIC) Failover method -failoverdelay Failover delay (in seconds) -failoverretry Number of attempts to retry connection -failover_restore Option to restore initial environment for Application Continuity and TAF (NONE or LEVEL1) -edition Edition (or "" for empty edition value) -pdb Pluggable database name -clbgoal (SHORT | LONG) Connection Load Balancing Goal. Default is LONG. -rlbgoal (SERVICE_TIME | THROUGHPUT | NONE) Runtime Load Balancing Goal -global_override Override value to modify the global service attributes. Used with -role, -policy, -notification, -failovertype, -failovermethod, -failoverdelay, -failoverretry, -failover_restore, -edition, -maxlag and -gsmflags. Ignored for a non-global service. -notification (TRUE | FALSE) Enable Fast Application Notification (FAN) for OCI connections -sql_translation_profile Specify a database object for SQL translation profile -commit_outcome (TRUE | FALSE) Commit outcome -retention Specifies the number of seconds the commit outcome is retained -replay_init_time Seconds after which replay will not be initiated -session_state Session state consistency (STATIC or DYNAMIC) -tablefamilyid Set table family ID for a given service -drain_timeout Service drain timeout specified in seconds -stopoption Options to stop service (e.g. TRANSACTIONAL or IMMEDIATE) -verbose Verbose output -help Print usage

matthiaslink77 commented 3 years ago

I already mentioned this in issue #141. But it seems development on this great work has almost come to a halt.

mapausch commented 6 months ago

Seems like this is caused by wrong/unfavourable initialization of 2 lists. In the end this leads to srvctl commands with "-preferred" and "-available" to be built also in non-RAC environments.

Modified oracle_services in a fork: https://github.com/mapausch/ansible-oracle-modules/blob/master/oracle_services

On my Single Instance environment this works, but don't have a RAC environment where I can test if it still works on RAC. So for now I don't want to go for a PR.