Programmer's Blog

Programmer's reference

Monthly Archives: December 2014

[OracleDB] maintain archivelog

//Command in sqlplus 
archive log list
archive log stop
archive log start
archive log next
archive log all
archive log n

//Command in rman
//Show all of the RMAN parameters for the database
RMAN> show all;

//Configure the disk channel to the format /backup/ora_df%t_s%s_s%p’
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/backup/ora_df%t_s%s_s%p';

//Configure the disk channel to the format +FLASHDG
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘+FLASHDG';

//Backup the database using the standard RMAN parameters
RMAN> backup database;

//List all of the current backups for the database
RMAN> list backup;

//List Backup summary
RMAN> list summary;

//Crosscheck backups to see if they still exist
RMAN> crosscheck backup;

//Crosscheck archive logs to see if they still exist
RMAN> crosscheck archivelog all;

//Remove any expired backup
RMAN> delete expired backup;

//Remove any expired archivelos
RMAN> delete expired archivelog;

//Backup the database and archivelogs using the standard RMAN parameters and delete the archivelogs after the backup
RMAN> backup archivelog all delete input;

And

RMAN> run

2> {

3> backup database;

4> backup  archivelog all delete input;

5> }

//Report of files that need backup due to unrecoverable operations
RMAN> report unrecoverable;

//Report the obsolete backups and archivelogs
RMAN> report obsolete;
 
//Delete the obsolete backups and archivelogs
RMAN> delete obsolete;

//List all of the archivelogs
RMAN> list archivelog all;

//Delete a specifed backupset
RMAN> delete backupset 1344

Sample backup command

RMAN> run

2> {

3> backup database;

4> sql “alter system switch logfile”;

5> backup archivelog all delete input;

6> sql “alter database backup controlfile to trace”;

7> }

Backup archive logs from scn 680

RMAN> run

2> {

3> ALLOCATE CHANNEL d1 DEVICE TYPE disk

4> FORMAT = ‘/app/oracle/admin/TEST/backup/df_%d_%s_%p.bak';

5> backup as compressed backupset archivelog from sequence 680;

6> }

//Backup archive logs and delete them up to scn 679

RMAN> run

2> {

3> ALLOCATE CHANNEL d1 DEVICE TYPE disk

4> FORMAT = ‘/app/oracle/admin/TEST/backup/df_%d_%s_%p.bak';

5> backup as compressed backupset archivelog high sequence 679 delete input;

6> }

//Point in time recovery

RMAN> run{

2> set until time “to_date(’05/07/11 09:00:00′ , ‘dd/mm/yy hh24:mi:ss’)”;

3> restore database;

4> recover database;

5> alter database open resetlogs;}

//Delete archive logs up to scn 650
RMAN> delete archivelog high sequence 650;

//list archivelogs from yesterday.
RMAN> list archivelog time between “sysdate -1″ and “sysdate”

//Delete archivelogs backed up 1 time to disk
RMAN> delete archive log all backed up 1 times to disk;

//Delete backups older than 7 days
RMAN> delete backup completed before ‘sysdate -7′;

//Restore archivelog between to scn numbers
RMAN> restore archivelog scn between 547484587 and 547662805;

//Check For Logical And Physical Block Corruption
RMAN> backup check logical validate database;

//RMAN command source : http://oracledbazone.com/2012/04/18/useful-rman-commands/

[Linux] Delete file by date

//for example, archive log file that is 7 days or older

# find ./oracle_*.arc -ctime +7 -exec rm {} \;

[Linux] Create share drive

//check if nfs-util is installed
# service nfs start

//in the /etc/export add the directories you want to share,
//and the host and permission you will share (ro/rw)
/datafiles 10.0.0.1(ro)

//export the directories
# /usr/sbin/exportfs -a
# /usr/sbin/exportfs

[Linux] Access sharefolder from Linux

$ sudo mount -t cifs //192.168.1.100/SharedFolder /mnt -o user=username

//make sure you have installed cifs-util

Setup telnet server

1. install telnet, xinetd and telnet-server

2. Edit file /etc/securetty by add

  pts/0
  pts/1
  pts/2
  pts/3
  pts/4
  pts/5
  pts/6
  pts/7
  pts/8
  pts/9

3. Restart both Service.

 # service xinetd restart
 # chkconfig telnet on
 # chkconfig --list|grep telnet

[Linux] Change hostname

1. at /etc/sysconfig/network
hostname=newhostname

2. using sysctl to change the kernel hsotname
# sysctl kernel.hostname
oldhostname

# sysctl kernel.hostname=newhostname
newhostname

[Solaris] enable usr/sfw/bin

There are many programs in solaris are installed but not added to the path

e.g. cc, gcc, to include, just include the path of the following to the /etc/profile

PATH="$PATH:$HOME/bin:/usr/sbin:/usr/bin:/root/bin:/usr/bin:/usr/sbin:/usr/local
/bin:/usr/local/sbin:/bin:/sbin:/opt/csw/bin:/opt/csw/sbin:/opt/csw/gcc3/bin:/us
r/sfw/sbin:/usr/sfw/bin:/opt/csw/mysql5/bin"

For gcc, you shall add a symbolic link to the /usr/sfw/sbin/ folder

[Solaris] using tar in solaris

1. for archive without .gz
# tar -cvf example.tar example
# tar -xvf example.tar

2. for archive including gz
# tar cvf - file | gzip > file.tar.gz
# gunzip -c file.tar.gz | tar xvf -

[Solaris] Static network configuration

1. To determine installed network card
# dladm show-link

2. To switch on the network card and assign ip (netmask optional)
# ifconfig <interface> plumb up
# ifconfig <interface> 10.0.0.1 netmask + 255.0.0.0