Removing sections from listener.ora


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing sections from listener.ora
# 8  
Old 10-25-2015
With above block in file INSERT.TXT, try
Code:
sed  -n '1,/SID_LIST/p; /(SID_D/ {:L;N;/\n *)/bK;bL; :K;/alias2/!p}; $rINSERT.TXT' listener.ora
SID_LIST_LISTENER=
        (SID_LIST=
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1_DGB)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3_DGB)
                )
                (SID_DESC=
                        (SID_NAME=${sid_alias})
                        (ORACLE_HOME=${DB_HOME})
                        (GLOBAL_DBNAME=${sid_alias})
                )
                (SID_DESC=
                        (SID_NAME=${sid_alias})
                        (ORACLE_HOME=${DB_HOME1)
                        (GLOBAL_DBNAME=${sid_alias}_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=${sid_alias})
                        (ORACLE_HOME=${DB_HOME)
                        (GLOBAL_DBNAME=${sid_alias}_DGB)

# 9  
Old 10-25-2015
Hi RudiC,
could you please explain your code.
Thanks,
# 10  
Old 10-26-2015
Hi,
thanks for the professional answer Smilie
I would also like to understand the solution and fix it since my listener.ora file has some other lines at the end, which this solution eliminate them

Code:
$ cat listener.ora
SID_LIST_LISTENER=
        (SID_LIST=
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1_DGB)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias2)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias2)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias2)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias2_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias2)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias2_DGB)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3_DGB)
                )
        )

ADR_BASE_LISTENER = /oracle

$ sed  -n '1,/SID_LIST/p; /(SID_D/ {:L;N;/\n *)/bK;bL; :K;/alias2/!p}; $rINSERT.TXT' listener.ora
SID_LIST_LISTENER=
        (SID_LIST=
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias1)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias1_DGB)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=sid_alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=sid_alias3_DGB)
                )
                (SID_DESC=
                        (SID_NAME=${sid_alias})
                        (ORACLE_HOME=${DB_HOME})
                        (GLOBAL_DBNAME=${sid_alias})
                )
                (SID_DESC=
                        (SID_NAME=${sid_alias})
                        (ORACLE_HOME=${DB_HOME1)
                        (GLOBAL_DBNAME=${sid_alias}_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=${sid_alias})
                        (ORACLE_HOME=${DB_HOME)
                        (GLOBAL_DBNAME=${sid_alias}_DGB)

Thanks
Yossi
# 11  
Old 10-26-2015
Sorry for missing the rest of the input file. Try
Code:
sed -e '/(SID_D/ {:L;N;/\n *)/bK;bL; :K;/alias2/d;/alias3_DGB/rINSERT.TXT' -e' }' file

As it is difficult if not impossible to determine the very last SID_DESC entry, I need to rely on alias3_DGB being the last. If that is not the case, hmmm?
Analysis of code:
Code:
sed -e '                        # first expression/script

/(SID_D/                        # start address for special processing
{:L;                            # L: label target
N;                              # append next line from input
/\n *)/bK;                      # last line of a SID_DESC block; branch out of loop to K label
bL;                             # branch to L label

:K;                             # K: out of loop target
/alias2/d;                      # delete all alias2 entries
/alias3_DGB/rINSERT.TXT'        # if the very last SID_D enrty found, read (and append) the INSERT file

 -e                             # second expr; needed to determine end of file name to read
' }'                            # just closing the block for /SID_D/
 file


Last edited by RudiC; 10-26-2015 at 02:07 PM..
This User Gave Thanks to RudiC For This Post:
# 12  
Old 10-27-2015
alias3_DGB is just a an example ..... Smilie

If we will have no other solution, I will have to put there a DUMMY ancor

---------- Post updated 10-27-15 at 12:02 PM ---------- Previous update was 10-26-15 at 05:47 PM ----------

this is my solution:

Code:
END_SID=$(awk 'BEGIN{FS="="}{if (index($1, "GLOBAL_DBNAME") != 0){a=$2}}END{print a}' listener.ora)

sed -e "/(SID_D/ {:L;N;/\n *)/bK;bL; :K;/alias2/d;/${END_SID}/rINSERT.TXT" -e " }" listener.ora

Thanks to you all, especially RudiC
# 13  
Old 10-27-2015
In order to determine the very last occurrence of GLOBAL_DBNAME, you'll need to run through the file twice in any case, so why not use sed for both?
Code:
sed -e '/(SID_D/ {:L;N;/\n *)/bK;bL; :K;/alias2/d;/'$(sed -n '/GLOBAL_DBNAME/h; $ {g; s/^[^=]*=//; s/)//;p}' listener.ora)'/rINSERT.TXT' -e ' }' listener.ora

# 14  
Old 10-28-2015
When there is only 1 alias, the replacement is not working Smilie

Code:
$ cat INSERT.TXT
                (SID_DESC=
                        (SID_NAME=alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=alias3)
                )
                (SID_DESC=
                        (SID_NAME=alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=alias3_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=alias3)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=alias3_DGB)
                )

$ cat listener.ora
# listener.ora Network Configuration File: 
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = l )(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER=
        (SID_LIST=
                (SID_DESC=
                        (SID_NAME=alias2)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=alias2)
                )
                (SID_DESC=
                        (SID_NAME=alias2)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=alias2_DGMGRL)
                )
                (SID_DESC=
                        (SID_NAME=alias2)
                        (ORACLE_HOME=/oracle/product/12.1.0.2/dbhome_1)
                        (GLOBAL_DBNAME=alias2_DGB)
                )
        )


ADR_BASE_LISTENER = /oracle

$ sed -e '/(SID_D/ {:L;N;/\n *)/bK;bL; :K;/alias2/d;/'$(sed -n '/GLOBAL_DBNAME/h; $ {g; s/^[^=]*=//; s/)//;p}' listener.ora)'/rINSERT.TXT' -e ' }' listener.ora
# listener.ora Network Configuration File: 
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = l )(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER=
        (SID_LIST=
        )


ADR_BASE_LISTENER = /oracle

$

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Ora-27603:ora-27626:

Hi, User claim that job is running slow from their end. I DBA found in database the below errors in alert log file. ORA-27603: Cell storage I/O error, I/O failed on disk o/192.168.10.3/RECO_DM01_CD_01_drm01 at offset 13335789568 for data length 1048576 ORA-27626: Exadata error: 2201 (IO... (2 Replies)
Discussion started by: Maddy123
2 Replies

2. Shell Programming and Scripting

Removing section from tnsnames.ora

Hi, I am trying to write a script or command to remove a section from tnsnames.ora file in the following example I would like to remove tns_alias2 section $ cat tnsnames.ora tns_alias1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = host1 )(PORT = 1521)) ... (3 Replies)
Discussion started by: ynixon
3 Replies

3. Shell Programming and Scripting

Parsing Listener.ora

Anymore have any code to easily parse the listener.ora to update the ORACLE_HOME for a specific sid? thanks. (1 Reply)
Discussion started by: nugent
1 Replies

4. UNIX for Advanced & Expert Users

grep all ORA errors except one ORA error

Hi - I am trying to grep all "ORA" errors in a log files.I have to grep all ORA errors except one error for example ORA-01653.How can exclude that error in "grep" command? In following "grep" command I want to exclude "ORA-01653" error grep -i ORA alert.log >>/tmp/ora_errors.txt ... (7 Replies)
Discussion started by: Mansoor8810
7 Replies

5. Solaris

maxuprc and maxusers - ORA-27300, ORA-27301, ORA-27302

Hi all, Am intermittently getting the following errors on one of my databases. Errors in file /oracle/HRD/saptrace/background/hrd_psp0_13943.trc: ORA-27300: OS system dependent operation:fork failed with status: 12 ORA-27301: OS failure message: Not enough space ORA-27302:... (1 Reply)
Discussion started by: newbie_01
1 Replies

6. Shell Programming and Scripting

awk removing sections of a file

I have a file that looks liek this (see below). can somebody provide me with and awk or sed command that can take a piece of the file starting from the time to the blank line and put in into another file. For example: How would I get the data from 10:56:11 to the blank line. Two things: ... (5 Replies)
Discussion started by: BeefStu
5 Replies

7. UNIX for Dummies Questions & Answers

Listener port

Hi All, I'm installation a server we have client -server architecture I need to configure a port for client to communicate with the server and server to communicate with the clients Pls let me know how to configure in linux (2 Replies)
Discussion started by: gwrm
2 Replies

8. Shell Programming and Scripting

How to know the location of the listener?

Hi, I have an unknown listener of of one of my port. How would I know the location of that specific listener? (4 Replies)
Discussion started by: fif14344
4 Replies

9. Shell Programming and Scripting

Removing sections

I have a file like this %( PHASES P %) %( SOURCES (10,0.0) (13,0.0) (16,0.0) (19,0.0) (22,0.0) (25,0.0) (28,0.0) (31,0.0) (34,0.0) (37,0.0) (40,0.0) (1 Reply)
Discussion started by: kristinu
1 Replies

10. Shell Programming and Scripting

Removing sections and leaving separators intact

I have an awk script like below function abs(val) { return val > 0 ? val : -val } # 1. Main input loop, executed for each line of input BEGIN { RS = ORS = ">" } { if ( NF > 2 ) { if ( abs( $1 - $(NF-2) ) < 40 ) { print } } } The input file is something like... (2 Replies)
Discussion started by: kristinu
2 Replies
Login or Register to Ask a Question