Tuesday, September 27, 2022

Why and How to add new DNS client in Solaris?

Why ?

A basic needed is to resolve the naming service with IP using your company DNS Server, below I am sharing the Oracle official we that I follow to add and check the service of the DNS client.

How ?

Please follow the below to achieve this ,:

1- Oracle documentation for Solaris 11.4:

https://docs.oracle.com/cd/E37838_01/html/E60988/gnlbt.html

## Example :

## configure the DNS

$ svccfg -s network/dns/client

svc:/network/dns/client> setprop config/search = astring: ("nameserver")

svc:/network/dns/client> setprop config/nameserver = net_address: (10.1.1.100)

svc:/network/dns/client> select network/dns/client:default

svc:/network/dns/client:default> refresh

svc:/network/dns/client:default> validate

svc:/network/dns/client:default> select name-service/switch

svc:/system/name-service/switch> setprop config/host = astring: "files dns"

svc:/system/name-service/switch> select system/name-service/switch:default

svc:/system/name-service/switch:default> refresh

svc:/system/name-service/switch:default> validate

svc:/system/name-service/switch:default> quit


2- Check the status of the service :

 https://docs.oracle.com/cd/E19120-01/open.solaris/819-2379/ecdne/index.html

## Check DNS status

$ svcadm enable dns/client

$ svcadm enable name-service/switch

## Do any use nslookup

nslookup google.com

Why and How to prepare a rebuild indexes using a wild select to generate all scripts?

 Why ?

Indexes will need a rebuild for certain cases and some cases it will be optional or have a different way to do it as well, however here I am sharing a situation where you will be must do this rebuild when the status become unusable.

How ?

Instead of do a manual rebuild for your indexes it is easier and more accurate if you use the below script to create the rebuild, keep on your mind that online rebuild and parallel and nologing are feature you have to measure it and use whatever is suitable for your case :

The main structure of this rebuild options, logging is the default option:

alter index my_idx rebuild online parallel 63 nologging; 
alter index my_idx noparallel;
alter index my_idx logging;

1- You may use the below for non-partition index:

select 'alter index '||owner||'.'||index_name||' REBUILD ONLINE;' from dba_indexes where status='UNUSABLE' and index_type not in ('LOB');;

2- You may use the below for partition index:

select 'ALTER INDEX '||index_owner||'.'||index_name||' REBUILD PARTITION ' ||partition_name||' ONLINE;' from DBA_IND_PARTITIONS where status='UNUSABLE' and index_type not in ('LOB');

Sunday, September 18, 2022

Why and How to update the user password to same password without knowing their actual password?

 Why ?

For certain reason you may need to update the password record for the Oracle user , for example if the user will be expired soon and you want to update the expiration period by change the password however you may want to keep the same password and you don’t know the password as well, in this case if you run Oracle 11g and more you can use the below query to get the alter and use the hash value as input thus the same old password will be kept however Oracle will update all dependencies like you enter a new password , that is mean expiration and graceful period all will be updated..

How ?

Below is scripts I used to generated all user under graceful message and update their password to same current password (no change) , you may change the where ( like ) with any situation that you may need to list,:

select

'alter user ' || su.name || ' identified by values'

   || ' ''' || spare4 || ';'    || su.password || ''';'

from sys.user$ su

join dba_users du on ACCOUNT_STATUS like 'EXPIRED(GRACE)%' and su.name = du.username;

Thursday, August 18, 2022

Why and How to export using a Data Pump utility?

  Why ?

In oracle database to move a data between systems or duplicate a schema in the same system there are several ways to achieve it. One of the common way to do this data migration and/or duplication you may use the Data Pump utility in the command line of the server and or the client with a full administration client installation. Below I will share a sample scripts that export and import using this utility, for advantage and features of this you may refer back to the oracle documentations, However on of the most important feature is that cross platform can be easily maintains by using this.

How ?

Below are sample script to do export and import using data pump ( dp), you have to create or use a user rather than sys, here I am using a system user and have created a Backup directory in OS/Oracle ,:

1- you may run export and import in one line with all necessary values as below, dmp will have the date and .log is the export/import logs, you may rename the import using REMAP as below example:

expdp system/<password>@<db_tns_name> directory=BACKUP schemas=<schema1>,<schema2> dumpfile=<name>.dmp logfile=<name>.log

impdp system/<password>@<db_tns_name> REMAP_SCHEMA=<old_name>:<new_name>,<old_name2>:<new_name2> directory=BACKUP dumpfile=<name>.dmp logfile=<name>.log

2- Export using parameter file with further export features as below example for certain tables of schame:

vi <parm_name>.par

 

DUMPFILE="<name>.dmp"

LOGFILE="<name>.log"

LOGTIME=NONE

DIRECTORY=BACKUP

FLASHBACK_TIME=SYSTIMESTAMP

COMPRESSION=METADATA_ONLY

CONTENT=ALLCOMPRESSION_ALGORITHM=BASIC

TABLES=('<schema."<table_name1>"', '<schema."<table_name2>"', '<schema>."<>table_name3"')

 

expdp system/<password>@<tns_name> PARFILE= <parm_name>.par

3- Import the export dump as needed.


Wednesday, August 10, 2022

Why and How to manage disk space quota in Solaris 11?

  Why ?

In Solaris you will have a disk and after that the sub disk will be assigned for a value of space to make sure that total space in disk divided on these sub directories and each take the assigned space from disk only , for example if you 100G and you need to make sure /u01 is only 20G and /u02 takes 80G , set a quota is the soft way , reservation and refquota will do this as well with different properties of each , here I will show only how to do quota.

How ?

Below are simple commands for getting and setting the quota

1- list the disks and it is detail:

zpool list

2- get a list of all list of create directory in the disk as mount point:

df –h

zfs list

3- To get/set specific path quota if any :

# zfs set quota=10G tank/home/jeff

# zfs get quota tank/home/jeff

 

My reference always is : https://docs.oracle.com/cd/E23824_01/html/821-1448/gazvb.html



Why and How to Monitor a Servers in WebLogic using a script?

  Why ?

In WebLogic admin console you can see the list of servers and it is health/state , if you don’t have a monitoring tools that is connected to WebLogic and check these servers ( like OEM with WebLogic pack) you have to write a script to get this status in the file for example. Most monitoring tool will be able to be configured with the file or shell script and report an alert in certain condition.

How ?

Below are steps and a sample code to monitor certain servers in WebLogic, WebLogic script use a jython which mostly like a python programing language, tab is considered in the jython code:

1- Create a shell script .sh file with executing permission to call the WebLogic file and store the result in a text file , this can be run in a crontab for example every 5 minutes to be like an archived logs or appended somewhere in a log file:

#!/bin/bash

now=$(date +%d-%m-%Y_%H-%M)

/oracle/Middleware/Oracle_Home/oracle_common/common/bin/wlst.sh /export/home/oracle/get_wls_serverstate_all.py &>/export/home/oracle/weblogic_status.txt

cp -p /export/home/oracle/weblogic_status.txt /export/home/oracle/archive_weblogic_status/weblogic_status_${now}.txt

2- Create a jython code file to monitor and exclude certain servers as below example:

redirect('/dev/null', 'false')

connect('weblogic','<password>','t3://<serverIP>:7001')

import datetime

servers = cmo.getServers()

domainRuntime()

 

for server in servers:

        if server.getName() not in ["",""]:

                try:

                        cd('/ServerRuntimes/' + server.getName());

                        currentState = get('OverallHealthState').getState()

                        now = datetime.datetime.now()

                        current_time = now.strftime("%d-%b-%y_%H:%M:%S")

                        dump_file = '/export/home/oracle/threadDump/'+current_time+server.getName()+'-ThreadDump.log'

                        if currentState == 0:

                                print server.getName() + ': ' + get('State') + ': HEALTH_OK'

                        elif currentState == 1:

                                try:

                                        threadDump('true',dump_file,server.getName())

                                        messg1 = 'ThreadDump has been generated on:'+dump_file

                                except WLSTException, e:

                                        messg1 = 'Exectpiont occur in threadDump'

                                print server.getName() + ': ' + get('State') + ': HEALTH_WARN :'+messg1

                        elif currentState == 2:

                                try:

                                        threadDump('true',dump_file,server.getName())

                                        messg1 = 'ThreadDump has been generated on:'+dump_file

                                except WLSTException, e:

                                        messg1 = 'Exectpiont occur in threadDump'

                                print server.getName() + ': ' + get('State') + ': HEALTH_CRITICAL :'+messg1

                        elif currentState == 3:

                                try:

                                        threadDump('true',dump_file,server.getName())

                                        messg1 = 'ThreadDump has been generated on:'+dump_file

                                except WLSTException, e:

                                        messg1 = 'Exectpiont occur in threadDump'

                                print server.getName() + ': ' + get('State') + ': HEALTH_FAILED :'+messg1

                        elif currentState == 4:

                                try:

                                        threadDump('true',dump_file,server.getName())

                                        messg1 = 'ThreadDump has been generated on:'+dump_file

                                except WLSTException, e:

                                        messg1 = 'Exectpiont occur in threadDump'

                                print server.getName() + ': ' + get('State') + ': HEALTH_OVERLOADED :'+messg1

                        else:

                                try:

                                        threadDump('true',dump_file,server.getName())

                                        messg1 = 'ThreadDump has been generated on:'+dump_file

                                except WLSTException, e:

                                        messg1 = 'Exectpiont occur in threadDump'

                                print server.getName() + ': ' + get('State') + ': UNKNOWN_HEALTH_STATE (' + str(currentState) + ') :'+messg1

                except WLSTException, e:

                        print server.getName()+': SHUTDOWN: Not_Running'

 

disconnect()

3- To use a crontab for example :

####

#Weblogic status

####

0,5,10,15,20,25,30,35,40,45,55 * * * * /export/home/oracle/check_weblogic_all.sh

 


Tuesday, February 15, 2022

Why and How to enable a DB system event traces?

  Why ?

In certain cases a further information will be needed in order to get know what it is the details of these issue occur, especially for those cases where Oracle consider it as an information ORA like 28 and 3136. Actually these steps can be used for any type of event traces where event is an ORA error expected to be. This is can be enabled for current connected session or sql it is self or for the whole system.

Note*: alter system will be reset and loosed after DB restart.

How ?

Below is steps to enable traces for ora-28 and ora-3436:

1- As sys user , login to sqlplus:

alter system set events '3136 trace name errorstack level 3';

ALTER SYSTEM SET EVENTS '28 trace name errorstack level 12';

2- To make sure trace is enabled you may use on of the below whether to send all details to trace file or get the details on screen as below:

oradebug setmypid

oradebug eventdump session

oradebug eventdump process

oradebug eventdump system

3- To send details to file :

oradebug setmypid

oradebug UNLIMIT

alter session set tracefile_identifier='myevents';

oradebug eventdump session

oradebug eventdump process

oradebug eventdump system

oradebug tracefile_name

Why and How to install Grid 19c on RHEL 8?

  Why ? Simply we will be requested to install Oracle Grid RAC DB on Redhat RHEL 8, below is my note for this installation . How ? 1-  OS in...