A Oracle DBA's BLOG

Welcome to my ORACLE DBA blog. You will be Amazing!!!

Wednesday, November 7, 2012

Oracle Rename User

This article present easy way to change/rename User name and password.

Select FOR your users

SQL> select user#,name from user$;
Update user name
SQL>update user$ set name=’TESTUSER’ where name=’VEYSI’;
SQL>commit;
Close your database
SQL>shutdown immediate;
SQL>startup;

SQL> alter user TESTUSER identified by TESTUSER;

Oracle rename data file tips

This article present easy way to change/rename datafile_name or Tablespace name_name.
First select your dba_datafile_name and choose a file for renaming.
SQL> SELECT FILE_NAME FROM DBA_DATA_FILES;
 
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/test01.dbf
 

Now close your database;

 
SQL>shutdown immediate;
Now change the name of file
linux> mv /u01/app/oracle/oradata/orcl/test01.dbf ' '/u01/app/oracle/oradata/orcl/veysi01.dbf


Mount your database


SQL> Startup  mount;


Rename datafile


SQL>ALTER DATABASE   
RENAME file      
   '/u01/app/oracle/oradata/orcl/test01.dbf' 
TO 
   '/u01/app/oracle/oradata/veysi01.dbf'

sql>alter database open;

Renaming Tablespace

ALTER TABLESPACE TEST RENAME TO INTERBASE;


Saturday, August 25, 2012

Travelling America USA

At my second degree i decided to go to USA summer vacation, Actually as a student it was a little difficulty Finally i got Visa and My first airport station  was Parish and i was More excited in there i just felt like I'm flying with plane :) At last i saw my self at America, i got many experiences there and a lot of pictures.

New york Time square

New Orleans Jazz Festival

Washington DC


BROOKLYN BRIDGE


From Empire City New york

Looking New york From top on empire city

Niagara Falls


Apple Store internview with Steve Jobs :)

I met with Iroman :) 


Tuesday, June 5, 2012

Create Oracle database listener Using Netca and manually

This article presents creating a simple Oracle Listener service. DBA's can create Listener manually however Oracle Net Configuration Assistant provide us simple way.


First Method Manually Create the listener

Manually create the listener.ora file and start the listener from command line.


LISTENER_TEST =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST =orcl.localdomain )(PORT = 1522))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
    )
  )
 
ADR_BASE_LISTENER_ORACLEDB1 = /u01/app/oracle
 


[oracle@orcl admin]$ lsnrctl stop LISTENER_TEST
[oracle@orcl admin]$ lsnrctl status LISTENER_TEST



 Second method Start the Oracle Net Configuration Assistant (NETCA)


Choose Listener configuration And Click Next


 Here Add (to add new listener) Reconfigure(exist listener), delete(exist) Rename(exist).
Choose Add And click next


So, Give new listener Name  For example Listener_test

The important thing you must Select TCP here. Click next

The exist port is 1521 however user for different listener different port for example 1522 

 Asking for another listener to configure Choose No and click Next

Choose new listener to be started and click next


Almost its done! Click next


Click Finish
After all you we'll see the script of new listener.


AS You see there are two listener script my first and second listener.
Have a nice job! :)

Tuesday, May 1, 2012

Manual Oracle database creation Script

Today i will show how create a database Oracle syntax manually . We know that during installation oracle database is created Auto. Also we can create it by DBCA command auto however its good to know creating by your hand J


Before you create the database make sure you have done the planning about the size of the database, number of tablespaces and redo log files you want in the database.


Select the standard database block size.

Lets Begin...
First Change Instance name Export Oracle SID
export ORACLE_HOME=/path/to/oracle/home
oracle@... > export ORACLE_SID=test_orcl
Check it
oracle@...> echo $ORACLE_HOME
Create a init.ora
# $ORACLE_HOME/dbs/init<sid>.ora

control_files = (/path/to/control1.ctl,/path/to/control2.ctl,/path/to/control3.ctl)
undo_management = AUTO
undo_tablespace = UNDOTBS1
db_name = test
db_block_size = 8192
sga_max_size = 1073741824 #one gig
sga_target = 1073741824 #one gig

u01/app/oracle/product/11.2.0/dbhome_1/dbs/init_test.ora
and set init.ora make sure that
DB_NAME=test_orcl

(remember the parameter file name should of the format init<sid>.ora and it should be in ORACLE_HOME/dbs  directory)
3.  Create a password file

$ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/pwd<sid>.ora password=oracle entries=5

Start the instance

sqlplus / as sysdba
startup nomount
 Create the database
 SQL> create database Test_orcl

logfile group 1 ('/u01/app/oracle/oradata/redo1.log') size 50M,
            group 2 ('/u01/app/oracle/oradata/redo2.log') size 50M,
            group 3 ('/u01/app/oracle/oradata /redo3.log') size 50M

character set WE8ISO8859P1

national character set utf8

datafile '/u01/ app/oracle/oradata/system.dbf' size 500M

autoextend on next 10M maxsize unlimited extent management local

sysaux datafile '/u01/app/oracle/oradata/sysaux.dbf' size 100M autoextend on

next 10M maxsize unlimited

undo tablespace undotbs1 datafile '/u01/app/oracle/oradata /undotbs1.dbf' size 100M
default temporary tablespace temp tempfile '/u01/app/oracle/oradata /temp01.dbf' size 100M;
SQL> CREATE TABLESPACE users DATAFILE ‘/u01/app/oracle/oradata/deneme/users01.dbf’ SIZE 25M AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
Run catalog and catproc 
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
 
Change passwords
alter user sys identified by sys_password;
alter user system identified by sys_password;

SQL> alter database mount;
SQL> alter database open;
SQL> select instance_name,version,status,database_status from v$instance;

INSTANCE_NAME   VERSION       STATUS         DATABASE_STATUS
—————-            —————–    ————           —————–
test_orcl                    11.2.0.1.0          STARTED          ACTIVE



Saturday, April 7, 2012

TNS Listener Configuration for Oracle

Today I will mention Oracle Listener and prepare for database.
Listener is provide connection between databases at different location.

Generally standard Listener port is 1521.
Scenario:
When Oracle installed Listener_name is Listener and port is 1521. If more databases are located on the same machine then using different listener and port more beneficial.
At this Scenario I’ll use Listener_name: My_Listener and port:1525

    1.   Preparation Database
At first we are going to look default configuration status when database is up.  For this we must create
init.ora from spfile (server parameter file or binary parameter
file)

SQL> create pfile='/tmp/test_pfile.ora' from spfile;

Open the “test_pfile” and save the following command
 *.local_listener='MY_LISTENER'
SHUTDOWN IMMEDIATE the database.

We have to make this test_pfile as Oracle Spfile in order to Up database.

SQL> create spfile from pfile='/tmp/test_pfile.ora';


   2.   Preparation LISTENER.ORA

Now we have to change listener.ora file.
When you open Listener.ora you will see the default setting change like following
MY_LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = machine_name)(PORT = 1525))
)
)

Here write the machine_name and change port number..

After the setting Listener would be changed like following.:

Thursday, April 5, 2012

Oracle Linux useful Command

Today i will show how to use Linux commands And Useful for Oracle DBA.

man
To show command knowledge

man(manual):

 To show contents
ls(list):
 To show hiding contents
ls -a :
 To show one under the other
ls -l :
 To show size and more information's
ls -lh :
 To show last update
ls -lrt : 
Cd
 To go other folder
cd :

/ : Linux above folder
To go above folder
Cd .. :

pwd
 To show own folder
pwd :

To create folder

mkdir

 To delete folder
rm

rm :
 to delete all
rm -R :


rmdir
 To delete empty folder
rmdir :

TO COPY FOLDER 
cp
 To move Folder 
mv
  
To show file or text 
cat | more
  
To Gzip Folder 
gzip
  
TO GUNZIP FOLDER 
gunzip

 To find folder
find

TO GIVE ALIAS 
Alias

 alias Nick_name=”<command >”  


mounting disk:

1- create a folder where to mounted.
mkdir /media/newdisk
mkdir /DATA


if we want to mount with FAT32:
mount -t vfat -o umask=ooo /dev/hdb1 /media/newdisk

if we want to mount with NTFS
mount -t ntfs -o umask=0222 /dev/hdb1 /media/newdisk

if we want to mount  CDROM:
mount -t iso_name -r /dev/cdrom /media/cdrom


if we want to mount with  OCFS2:
mount -t ocfs2 -o noatime,_netdev,datavolume,nointr /dev/emcpowera1 /DATA


if we want to mount with  EXT3:
mount -t ext3 /dev/sdb1 /software


unmounting disk:

umount -l /dev/sdb1
umount /DATA


Partitioning

fdisk /dev/sdb


Formatting


if we want to format with EXT3:
mkfs -t ext3 /dev/sdb1
if we want to format with  OCFS2:
mkfs.ocfs2 -b 4K -C 128K -N 5 -L /DATA /dev/emcpowera1

FILE SYSTEM CHECK

fsck.ocfs2 -n /dev/sdf2
fsck.ocfs2 -y /dev/sdf2 –>repair
List drives

df -h


tmpfs increase

mount -t tmpfs shmfs -o size=3g /dev/shm


Getting user id

id username
id oracle


Set user folder

chown -R oracle:dba /oracle

Change folder permission


chmod 775 file_name


Checking installed “rpm” packages

rpm -qa | grep “package name”


Rpm download 

rpm -ivh package

Rpm update


rpm -Uvh package


Rpm Delete

rpm -e package


Checking Oracle installing requires packages 
—————————————————————————————————————-

rpm -q binutils compat-db compat-libstdc++-33 libgcc glibc glibc-devel glibc-headers gcc gcc-c++ libgcc libstdc++ cpp make libaio ksh elfutils-libelf make sysstat libaio libaio-devel setarch libXp unixODBC –qf “%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n”|sort

Date of rpm

rpm -qa –last | more

CPIO extract


cat cpio_file | cpio -idmv

Create MD5 In order To copy or move validate folder


md5sum file > file.md5


Checking moved MD5 

md5sum -c file.md5

Folder transfer between servers


scp 192.168.192.168:oracle/veysi.pw /

 scp /oracle/full.dmp ora11g@192.168.192.166:/export #copy folder

Search folder

grep -ins 192.168.192.168(Text) -A2 -B1 list1.log


Get Process value

ps -ef |grep veysi|wc


Change Date

date -s “21 MAR 2010 02:04:00″


SEMAPHORE

ipcs -s
ipcrm

Trace OS process


strace -p pid


List Tar zip 

tar -tf java_patch.tar


Add a file or folder to Tar zip 

tar -rf java_patch.tar jre


Create Tar zip 

tar -cf java_patch.tar jdk


Change user ID 

usermod -u UID user


Delete folder after killed process 

echo “”>veysi_ora_7001.trc

Give easy path to folder


ln -s path kısayol_adı


Show status SELinux 

sestatus


To show version of download rmp package

echo ocfs2-`uname -r`


i/o static list

iostat 3


checking RAC node date: 

ssh rac1 date; ssh rac2 date; date


without using root password to get information

/etc/SUDOERS
ora11g localhost=NOPASSWD:/bin/mount,/bin/umount
ora11g talipdb=NOPASSWD:/bin/mount,/bin/umount


Last log in 

last | more


Send file to Via E-mail

mail -s “file_name” muh.veysi.47@hotmail.com < sqlnet.log


Finding word in folder

grep -ins word *

To kill more process using process_name


ps -ef |grep “process_name” |awk ‘{print ” kill -9 ” $2}’>/tmp/kill.sh


To watch process_name every 3 second

watch -n 2 “ps -ef | grep process_name | grep -v ps”


Open Log file
tail -f /var/log/messages