BASISWORLD

Start, Learn and work on SAP Basis.

Thursday, October 25, 2018


 Useful Unix commands for basis consultant



                                 CREATING AND DELETING FILES

cat  > filename
              file will be created
cat >> filename
             append contents to existing file.
touch file1 file2
       no.of files will be created.
rm filename
       file will be deleted.





CREATING AND REMOVING DIRECTORIES


mkdir dir1 dir2
        no.of directories will be created.
rmdir dir1 dir2
        no.of empty directories will be deleted
rm –rf dir1
        it removes directories with contents.
cd
        to change one directory to another directory







pwd
    to know present working directory.
ps –ef
    to know all processes.
kill pid
    to kill particular process.
kill –9 pid
    to kill process forcefully.
vi filename
    to edit file in vi.




ls filename
              Lists all files and directories.
ls –l
             it gives full information of files and directories.
ls –a
             it displays hidden files
ls –p
             shows difference b/w files and directories.
ls –i
            Displys inode no of files and directories.





File permissions


We have two ways to assign permissions to files
          1. Numeric mode
          2. Symbolic mode or relative mode



Numeric mode

We assign numerics to permissions like
       read       4
       write      2
       execute  1
chmod 777 filename/dirname
        assign full permissions to all users.
chmod 666 filename/dirname
         it assigns read and write permissions to all users



chgrp newgroupname file/directory
      it changes groupname for file or directory.


chown newownername file/directory
               it changes owner for file or directory.

Symbolic mode or relative mode


     Here we assign symbols to users.
    owner     u
    group      g
    others      o
    all            a
    read          r
    write        w
    execute     x
    adding permissions        +
    removing permissions    -


To assign permissions

    chmod ugo+rwx file/dir.


      To remove permissions

    chmod ugo-rwx file/dir.



                                        Network communication


In hetrogenous and homogenous environment
     
     telnet  ipaddress
          it connets to remote system
      ftp  ipaddress
      scp /dir  ipaddress:/dir
           it copies date from source system to target  system
      ssh  ipaddress:mkdir /dir
           it executes commands in remote system.      
 


Only in homogenous environment
  
     rlogin ipaddress

     rcp /dir  ipaddress:/dir

     rsh ipaddress:rm /file

                                     User commads

useradd –u uid –g gid –G gid –d  homedirecory –m –s sh username
           it adds user g for primary group
                              G for secondary group
                              d,m for  homedirecoty
                               s  for default shell
                               u  user id
 su – username
          to swith from one user to another user.



who
       displays all users who are currently logged in system.
who am I
       displays detailed information about current logged in user.
last
       displays information about when system is lastly rebooted,who,time.
finger
       information about current logged in user.



                           filesystems



df
              it displays all filesystems with sizes
df –h
              it displays all filesystems with human readable form.

du         to know disk utilization




Shutdown commands

                           


shutdown
init 0      
      like shutdown
init 1
      single user mode
init 6
       like  reboot
reboot
poweroff


                           copy or move

To copy a file
            cp sourcefile targetfile
 To copy empty directory
            cp sourcedir targetdir
 To copy directory with all contents
            cp –r sourcedir targetdir
To move file
            mv sourcefile targetfile
To move directory
            mv sourcdir targetdir         



                                  creating links


To link file or directory in same filesystem
       ln soucefile/dir  targerfile/dir
    this is called hard mounting
If you link souce file or dir with another file which is in different file system that is called soft mounting
     ln –s sourcefile/dir targetfile/dir
For help
     man command




Pattern search


To seach for a single word in a file
     grep word filename
     it displays all lines which contains this word
To seach multiple words
     egrep word1 | word2 filename
To seach for a text
     fgrep text filename



                   find

searches in current directory for file or directory.

find . –name “<file>/<directory>” –type f/d  -print


type options:

              b      block (buffered) special
 
              c      character (unbuffered) special
 
              d      directory
 
              p      named pipe (FIFO)
 
              f      regular file
 
              l      symbolic link 

to search files exact n th day old from now


find . –name “<file>/<directory>” –mtime n –print


to search files morethan  n days old from now.


find . –name “<file>/<directory>” –mtime +n –print


to search files from n days old from now.

find . –name “<file>/<directory>” –mtime -n –print


for searched files in range( from more than 64 days old to 95 days old)

find . -name "*" -a "(" -mtime +64 -a -mtime -95 ")" -exec ll {} \;



to know files in current directory which are more than 10M size.

find . -type f -size +10M -exec ls -l {} \;       (for files)
                                        or

find . -xdev -size +10000000c -exec ls -l {} \;                          (for files and directories)


             `b'    for 512-byte blocks (this is the default if no suffix                
                    used)
 
              `c'    for bytes
 
              `w'    for two-byte words
 
              `k'    for Kilobytes (units of 1024 bytes)
 
              `M'    for Megabytes (units of 1048576 bytes)
 
              `G'    for Gigabytes (units of 1073741824 bytes)



If you want to see if you have any directories with world write permission, use:
find . -type d -perm 777 –print
















1. Check the current version of the database

>sudo su -  ora<SID>
 >sqlplus / as sysdba

Connected.
SQL> select comp_id, version, status from dba_registry;



2. Check OS requirements

Note: The OS requirements can be found in metalink note 169706.1
For the PA-RISK B11.11 or Itanium B11.23



#uname –a

/usr/sbin/swlist |grep –i PG



3. Check OS kernel settings

Check kernel settings in Unix via command: /usr/sbin/kmtune
Check Kernel settings in SAP.  Logon to SAP -> Transaction SM51 -> Remote logon to the central instance -> launch transaction OS06 -> Detail analysis menu -> System configuration




4. Check JDK Java SDK 1.4.2.00 is installed

sudo su –
[root@bdhk:/root]
/opt/java1.4/bin/java –version


5. Disk space requirements


You need to check if the following filesystems are already available. This can only be the case when an already upgraded database is running on the same server. If they are not available you have to request them.
/oracle/stage/102_64           3GB
/oracle/client/10x_64             200MB

You need to request the following new filesystem:
/oracle/<DBSID>/102_64     8 GB  

Use the Service Desk standard template “UNIX – LVM/Filesystem/NFS (SLA)” to get the required filesystems created


6. Populate stage directory with Oracle 10.2.0.2 binaries

***Note: ITSS will be doing this step until the end***

Make sure that /oracle/stage/102_64 filesystem exists with the size of at least 3GB.

Cleanup the filesystem before populating:
# sesu –
# rm –rf /oracle/stage/102_64

Run the following command to populate the stage directory with the Oracle 10202 binaries:
# sesu -# swinstall –x mount_all_filesystems=false \
-x allow_multiple_versions=true \
-s bdhm:/var/opt/sapsoe_arch/depot SAP_ORASTAGE_10202_HP64:/oracle/stage/102_64

Note: The swinstall command will take about 20 min to finish depending on the speed of file transfer (other regions aside from NA may be longer e.g. in Asia it takes about 2-3 hours to finish). So you can leave your terminal open and get back later to check if the command is done. You may proceed to the next steps using another telnet session.

Note: Make sure that your terminal is not interrupted while the swinstall command is still running and the command shows successful when it finishes.



7. Check oraInventory

Check the location of oraInventory.

[root@bdhp4202:/root]
cat /var/opt/oracle/oraInst.loc
inventory_loc=/oracle/oraInventory
inst_group=dba

By default, oraInventory is located in /oracle/oraInventory, however, in some cases oraInventory is stored somewhere else e.g. /oracle/<SID>/920_64/oraInventory. Make sure that this oraInventory folder has at least 300 MB of space. If the current oraInventory folder doesn’t have this enough space, you may need to either do the following:

      A.     Request UIT to increase the filesystem
  • Use ServiceDesk ticket to request UIT

Or

      B.     Move the directory to another location
  • e.g. as root, move /oracle/oraInventory to /oracle/<SID>/920_64/oraInventory
# cp –R –p /oracle/oraInventory /oracle/<SID>/920_64/
# chmod 775 /oracle
# chmod 775 /oracle/<SID>
# chmod 775 /oracle/<SID>/920_64
# chmod –R 775 /oracle/<SID>/920_64/oraInventory
# vi /var/opt/oracle/oraInst.loc and modify inventory_loc to reflect the new location

inventory_loc=/oracle/<SID>/920_64/oraInventory

Note: In some cases, the one referred to by inventory_loc is a soflink.
e.g. in ST1:

bdhp4245:ai5134 15> ll /oracle/oraInventory
lrwxr-xr-x   1 root  sys  25 Aug  2  2004 /oracle/oraInventory -> /oracle/NP6/oraInventory/

You need to remove the softlink and adjust the /var/opt/oracle/oraInst.loc file to reflect the correct location.
e.g.
inventory_loc=/oracle/NP6/oraInventory
inst_group=dba

Note: If you have moved the oraInventory to another location, you also have move the oui and jre directories to the same location.
  • e.g. if orainventory is located originally at /oracle/oraInventory and you want to move it to /oracle/<SID>/920_64/oraInventory, then you have to be the user root, and move /oracle/oui to /oracle/<SID>/920_64/oui and /oracle/jre to /oracle/<SID>/920_64/jre
# cp –R –p /oracle/oui /oracle/<SID>/920_64
# cp –R –p /oracle/jre /oracle/<SID>/920_64





8. Backup the Oracle inventory (only if it was found in the steps above)


As a precaution, TAR up the current Oracle Inventory to another location on the server with approximately 20 MB free disk space.

e.g.
# tar –cvf  /oracle/<SID/Inventorybackup.tar  /oracle/oraInventory



Checking the correct UNIX users, groups and activezation

Check that ora<sid> has write permission in /oracle

#sesu – ora<sid>
#touch /oracle/write_test
#rm /oracle/write_test

In case that doesn’t work:

#sesu –
#chgrp dba /oracle
#chmod 775 /oracle

Check that ora<sid> has write permission in /oracle/admin (only in case more instances are running on the same server, you may need to verify that ora<SID> has write permission on /oracle/admin

#cd /oracle
#ll
drwxrwxr-x   3 oraINT     dba             96 Jul 31 10:41 admin

Check umask
#sesu – ora<sid>
#umask



Running the pre-upgrade script

This tool provides information on the existing pre-upgrade database. It also suggests any changes that need to be made before the upgrade is started

#sesu – ora<sid>
sqlplus /nolog
SQL>connect / as sysdba
SQL>spool /oracle/<SID>/pre_upgrade.log
SQL>@/oracle/stage/102_64/database/Disk1/SAP/utlu102i.sql  
Oracle Database 10.2 Upgrade Information Utility    07-26-2006 13:34:18
.
Database:
à name:       INT
à version:    9.2.0.6.0
à compatible: 9.2.0.4.0
à blocksize:  8192
.
Logfiles: [make adjustments in the current environment]
i.  Ã The existing log files are adequate. No changes are required.
.
Tablespaces: [make adjustments in the current environment]
i.  Ã SYSTEM tablespace is adequate for the upgrade.                  
.... minimum required size: 694 MB
.
Update Parameters: [Update Oracle Database 10.2 init.ora or spfile]
WARNING: Ã  “java_pool_size” needs to be increased to at least 67108864
WARNING: Ã  “streams_pool_size” is not currently defined and needs a value of
at least 50331648
WARNING: Ã  “large_pool_size” needs to be increased to at least 8388608
WARNING: Ã  “session_max_open_files” needs to be increased to at least 20
.
Renamed Parameters: [Update Oracle Database 10.2 init.ora or spfile]
i.  No renamed parameters found. No changes are required.
.
Obsolete/Deprecated Parameters: [Update Oracle Database 10.2 init.ora or spfile]
à “hash_join_enabled”
à “transaction_auditing”
à “log_archive_start”
à “enqueue_resources”
.
Components: [The following database components will be upgraded or installed]
à Oracle Catalog Views         [upgrade]  VALID
à Oracle Packages and Types    [upgrade]  VALID
.
Miscellaneous Warnings
WARNING: Ã  Passwords exist in some database links.
.... Passwords will be encrypted during the upgrade.
.... Downgrade of database links with passwords is not supported.
WARNING: Ã  Deprecated CONNECT role granted to some user/roles.
.... CONNECT role after upgrade has only CREATE SESSION privilege.
WARNING: Ã  Database contains stale optimizer statistics.
.... Refer to the 10g Upgrade Guide for instructions to update
.... statistics prior to upgrading the database.
.... Component Schemas with stale statistics:
....   SYS
WARNING: Ã  Database contains INVALID objects prior to upgrade.
.... USER SAPR3 has 229 INVALID objects.
.
SYSAUX Tablespace:
[Create tablespace in the Oracle Database 10.2 environment]
i.  Ã New “SYSAUX” tablespace
.... minimum required size for database upgrade: 500 MB
.

PL/SQL procedure successfully completed.

SQL>spool off
SQL>exit

Check the result by looking at the logfile /oracle/<SID>/pre_upgrade.log

*** Make the changes listed in the pre_upgrade.log file, otherwise you might have problems during the upgrade ***

Note: The required parameter changes will be done later in step #205 so there is no separate downtime required to adjust those.
Note: Obsolete/Deprecated Parameters will be removed later during oracle upgrade via DBUA
Note: the freespace check for the system tablespace is not reliable, you have to perform that later as described in step #95
Note: The parameter streams_pool_size cannot be set on an Oracle 9 system it will be changed by the DBUA.
Note: The stale optimizer statistics will be updated during the downtime in step #210
Note: SYSAUX tablespace will be created during upgrade in step #245




Checking the prerequisites for the Oracle Universal Installer

You must run the following script to check the prerequisites for the Oracle Installer:


#sesu – ora<sid>
#cd /oracle/stage/102_64/database/Disk1/
#./runInstaller –executeSysPrereqs

Starting Oracle Universal Installer...
Checking installer requirements...
Checking operating system version: must be B.11.23 or B.11.11.    Actual B.11.11
                                      Passed
All installer requirements met.
Preparing to launch Oracle Universal Installer from /oracle/INT/920_64/tmp/OraIn
stall2006-07-26_01-26-40PM. Please wait ...
DISPLAY not set. Please set the DISPLAY and try again.

If the OUI complains that the OS version is not certified or supported you can ignore that.
The information that DISPLAY is not set can be ignored in this check.
*** If the OUI reports missing OS patches you need to make sure that those are applied before you continue! -> Go back to step 015 of this documentation!



Check the temporary tablespace

The database upgrade assistant (DBUA) will report an error in case the temporary tablespace is still dictionary managed if it’s content is defined as TEMPORARY. In case the Content is PERMANENT there should be no issue, so no action needed.

Run the following command for verification:

#sesu – ora<sid>
#sqlplus “/ as sysdba”

select tablespace_name, status, contents, extent_management
from dba_tablespaces
where tablespace_name =’PSAPTEMP’;

if you receive output like bellow, you have to recreate it as temporary LMT tablespace with Uniform extent allocation:

TABLESPACE_NAME        STATUS    CONTENTS  EXTENT_MANAGEMENT
 ----------------------------------- ------------ -------------------- --------------------------
PSAPTEMP                        ONLINE      TEMPORARY     DICTIONARY

The extent_management=’DICTIONARY’  indicates that it is a dictionary-managed tablespace. In this case you have to:

Create/Recreate Locally managed temporary tablespace PSAPTEMP
1.)     Create a new PSAPTEMP2 (tablespace_content=temp; locally managed, uniform allocation, extent size 1MB) – use BRTools, option 2 , than option 3 and set tablespace_content to temp. Other values are set by default
2.)     Change all users in the database to use PSAPTEMP2 instead of PSAPTEMP as temporary tablespace
You will be prompted to change temporary tablespace for SAP users within creation of temporary tablespace procedure in BRTools, but to check it on oracle leavel you can execute:
sqlplus “/ as sysdba”
select ‘alter user ‘||username||’ temporary tablespace PSAPTEMP2;’ from dba_users where temporary_tablespace=’PSAPTEMP’;
This statement will create all “alter user” statements for changing temporary tablespace for users that have it set to PSAPTEMP that can be executed as sysdba directly on the database via SQLPLUS.
3.)     Drop tablespace PSAPTEMP and re-create it (tablespace_content=temp; locally managed) – Drop PSAPTEMP with BRTools. You will see during dropping of tablespace original size of PSAPTEMP. Note this value and create PSAPTEMP with the same size. To create PSAPTEMP in a proper way and avoid issues with “sparse files”, follow the CBA “Creating locally managed PSAPTEMP tablespace CBA – V1.doc”
4.)     Point all DB users back to use PSAPTEMP  as temporary tablespace
You will be prompted to change temporary tablespace for SAP users within creation of temporary tablespace procedure in BRTools, but to check it on oracle leavel you can execute:
sqlplus “/ as sysdba”
select ‘alter user ‘||username||’ temporary tablespace PSAPTEMP;’ from dba_users where temporary_tablespace=’PSAPTEMP2’;
This statement will create all “alter user” statements for changing temporary tablespace that can be executed as sysdba directly on the database.
5.)     Drop PSAPTEMP2 – use BRTools