06 December 2011

Oracle 11g Flash Cache


Owerview:
        Oracle Flash Cache looks like a Linux swap or Windows page file.
Requirements:
        Oracle 11g RDBMS must be run on Linux or Solaris
Purpose:
        Reduce db file sequential read  waiting
Configuration:
        Set parameter - db_flash_cache_file to the name of the file
        Set parameter - db_flash_cache_size to the size of Flash Cache (must be less than or equal to the physical memory size)

10 November 2011

Linux. To delete expiration interval of user password


Linux. To delete expiration interval of user password
1. login as root
        ls -lh /etc |grep shadow
       
2. change permition
        chmod 600 /etc/shadow
3. edit shadow
        vi /etc/shadow
                change the string
                        oracle:$1$/lFSo3aP$LHkIxXXxkGtveA8cAjk7//:15197:1:90:7:::
                to
                        oracle:$1$/lFSo3aP$LHkIxXXxkGtveA8cAjk7//:15197:1::7:::
4. change permission back
        chmod 400 /etc/shadow  

05 October 2011

Disable X Window in Red Hat

Edit inittab (as root)
   vi /etc/inittab
      replace line 
id:5:initdefault:
      with 
id:3:initdefault:

Run the commands
  init q
  init 3

X Window will not start next reboot.

07 July 2011

Linux ftp server

1.find
find -name vsftp*
./vsftpd-2.0.5-16.el5_5.1.x86_64.rpm

2. install
# rpm -Uvh vsftpd-2.0.5-16.el5_5.1.x86_64.rpm

3. configure
Default port: TCP / UDP - 21 and 20
The main configuration file: /etc/vsftpd/vsftpd.conf
Users that are not allowed to login via ftp: /etc/vsftpd/ftpusers
-------------------------------------
Open the configuration file, type:
# vi /etc/vsftpd/vsftpd.conf
Turn off standard ftpd xferlog log format:
xferlog_std_format=NO
Turn on verbose vsftpd log format. The default vsftpd log file is /var/log/vsftpd.log:
log_ftp_protocol=YES
Above to directives will enable logging of all FTP transactions. Lock down users to their home directories:
chroot_local_user=YES
Create warning banners for all FTP users:
banner_file=/etc/vsftpd/issue
Create /etc/vsftpd/issue file with a message compliant with the local site policy or a legal disclaimer
-------------------------------------

4. start and stop
Turn on vsftpd on boot:
# chkconfig vsftpd on

/sbin/service vsftpd start
/sbin/service vsftpd stop

Linux remote desktop

1. find
[]$ find .-name vnc*
vnc-4.1.2-14.el5_5.4.x86_64.rpm

vnc-server-4.1.2-14.el5_5.4.x86_64.rpm

2. install
[]$ rpm -Uvh vnc-server-4.1.2-14.el5_5.4.x86_64.rpm
 
3. configure
edit /home/.vnc/xstartup
----- example for gnome ------------------------------
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startx
----------------------------------------------------------------
edit
/etc/sysconfig/vncservers
-------------------------------------------------------------
# The VNCSERVERS variable is a list of display:user pairs.

#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-nohttpd" to prevent web-based VNC clients connecting.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the "-via" option in the
# `man vncviewer' manual page.
VNCSERVERS="1:oracle"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
VNCSERVERARGS[2]="-geometry 1024x768 -depth 32"
-------------------------------------------------------------

4. start
vncserver
-- set password when start first time
-- or set passwd running
vncpasswd

5. start and stop
/sbin/service vncserver start

/sbin/service vncserver stop

6. use via http
in browser
http://server_name:port  (http://192.168.1.1:5801)

7. use on remote pc (linux)
export DISPLAY=1:
vncviewer server_name:port (192.168.1.1:5901)

13 April 2011

Rename & Move DB files

Rename&Move Controlfile
1. alter system
2. shutdown
3. rename OS
4. start
SQL> ALTER SYSTEM SET control_files='C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_CONTROL01.CTL', - > 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL02.CTL', - > 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL03.CTL' SCOPE=SPFILE;
SQL> SHUTDOWN IMMEDIATE
SQL> HOST MOVE C:\ORACLE\ORADATA\DB10G\CONTROL01.CTL C:\ORACLE\ORADATA\DB10G\RENAME_CONTROL01.CTL
SQL> STARTUP

VMvare shared disk

To make disk shared for two or many servers find .vmx and set
disk.locking="FALSE"
diskLib.dataCacheMaxSize="0"
scsi.sharedBus="virtual"

01 March 2011

Oracle Database System Triggers


System event list that could to be triggered:
AFTER STARTUP
BEFORE SHUTDOWN
AFTER LOGON
BEFORE LOGOFF
AFTER DB_ROLE_CHANGE -- for Data Guard failover and switchover
AFTER SUSPEND
AFTER SERVERERROR

AFTER SERVERERROR triggers fire after an Oracle error is raised, unless the error is one of
the following:
ORA-00600
Oracle internal error
ORA-01034
Oracle not available
ORA-01403
No data found
ORA-01422
Exact fetch returns more than requested number of rows
ORA-01423
Error encountered while checking for extra rows in an exact fetch
ORA-04030
Out-of-process memory when trying to allocate N bytes
In addition, the AFTER SERVERERROR trigger will not fire when an exception is raised
inside this trigger (to avoid an infinite recursive execution of the trigger).

Trace you session

Trace you session

1. Regular
Trace your own session
alter session set sql_trace=true;
or
alter session set events '10046 trace name context forever, level 4';
-- levels: 1(sql_trace=TRUE), 4, 8, 12

1.1. Regular 1
Trace your own session
exec dbms_session.set_sql_trace(TRUE);

2. Distance 1
dbms_system.set_bool_param_in_session(
sid IN NUMBER,
serial# IN NUMBER,
parnam IN VARCHAR2,
bval IN BOOLEAN);
example:
exec dbms_system.set_bool_param_in_session(10, 161, 'sql_trace', TRUE/FALSE);

3. Distance 2
dbms_system.set_sql_trace_in_session(
sid
NUMBER,
serial# NUMBER,
sql_trace BOOLEAN);
example
exec dbms_system.set_sql_trace_in_session(10, 1008, TRUE/FALSE);
or
EXEC DBMS_System.Set_Ev(sid, serial#, event, level, name);
EXEC DBMS_System.Set_Ev(31, 97, 10046, 4, '');

4. Distance 3 (new 11g)
DBMS_MONITOR.SESSION_TRACE_ENABLE(
session_id IN BINARY_INTEGER DEFAULT NULL,
serial_num IN BINARY_INTEGER DEFAULT NULL,
waits
IN BOOLEAN
DEFAULT TRUE,
binds
IN BOOLEAN
DEFAULT FALSE,
plan_stat IN VARCHAR2
DEFAULT NULL);

Write your own message into alert log


Run under SYS
begin
  dbms_system.ksdwrt(2, 'Message from DB');
end;

Original
dbms_system.ksdwrt(n, message_string);
where n is:
1 - Write to trace file.
2 - Write to alertlog.
3 - Write to both.