Saturday, November 16, 2019

Oracle Net Configuration Assistant (netca) command line interface (CLI)

Everything is clear about using netca in graphical mode. Understandable questions and "transparent" interface do they job perfectly, although for comprehensive Oracle Net setup the Net Manager is more preferable (imho). But netca CLI has some specificities. 

There are several options of using netca CLI.

To configure listener and naming services via netca response file :

netca -silent -responsefile

The example of such file can be as following (the empty and commented lines was removed) :

[GENERAL]
RESPONSEFILE_VERSION="12.1"
CREATE_TYPE="CUSTOM"
LOG_FILE=""/tmp/netca.log""
[oracle.net.ca]
INSTALLED_COMPONENTS={"javavm","net8","cman","aso","client","server"}
INSTALL_TYPE=""custom""
LISTENER_NUMBER=0
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"EZCONNECT","TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"ASM"}
NSN_SERVICE={"+ASM"}
NSN_PROTOCOLS={"TCP;db-01;1521"}


In the above some fields has 2 double quotes in a row in their values. It's required, else run-time error can occur.

The following lines are required :
[GENERAL]
RESPONSEFILE_VERSION="12.1"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]


The listener only created when one of installed components is "server".

If you set INSTALL_TYPE=""minimal"" or ""typical"", then sqlnet.ora with NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
is created and default listener named LISTENER on 1521 port also is created with appropriate entries in listener.ora file (if it was already there, the file is left as is).


Creation of TNS entries is possible only when INSTALL_TYPE=""custom"".

You can override entries from response file or add some more parameters using command line options. Thus, you can change install_type on the way, listener_name and listener port (only in custom install_type) etc.

netca -h
Usage: netca [-silent] { }

Perform network configuration by specifying the following arguments:
    [-silent]
        -responsefile ]
        [-local {Perform configuration on only local node}]
    -instype
        [-listener ]
        [-lisport ]
        [-lps ]
        [-lpe ]
        [-netnum ]
        [-nostartlsnr {Do not start listener}]
    [-crsupgrade {Upgrade default listener from lower version database home to Grid Infrastructure home (only for RAC)}]
    [-inscomp ]
    [-insprtcl ]
    [-orahome ]
    [-orahnam ]
    [-log ]
    [-h|-help {Print usage}]


As we can see there are no options for tnsnames.ora or sqlnet.ora entries. When install type is custom, tns entries are taken from response file.

You can add tns entries and listeners by running netca with another content of response file or command line options. The entries are added into listener.ora and tnsnames.ora.

Naming methods are updating only in custom install type from the response file.

P.S. When I tried default value for NSN_NAMES={"EXTPROC_CONNECTION_DATA"} in the response file, tns entries were not created. If this name is changed in one char only, tnsnames.ora is populated :)

P.P.S. netca creates appropriate listener configuration in grid infrastructure if it's running on the server.

Examples :

1. Does network service name settings according to response file parameters and add new listener bbb to those already registere, try to set listening port to first free between 1500 and 1505, without starting listener bbb after creating it.

$ netca -silent -responsefile /install/oracle/response/netca5.rsp -instype custom -listener bbb -lps 1500 -lpe 1505 -nostartlsnr

2. Create default listener LISTENER (-instype typical) on default port and start it not accounting it's existence.

$ netca -silent -responsefile /install/oracle/response/netca5.rsp -instype typical -lps 1500 -lpe 1505 -nostartlsnr