Archive for Uncategorized

Oracle AQ

Getting Started

Create Users

 
CONNECT system/manager;
DROP USER aqadm CASCADE;
CREATE USER aqadm IDENTIFIED BY aqadm;
GRANT CONNECT, RESOURCE TO aqadm;
GRANT EXECUTE ON DBMS_AQADM TO aqadm;
GRANT Aq_administrator_role TO aqadm;
 
DROP USER aq CASCADE;
CREATE USER aq IDENTIFIED BY aq;
GRANT CONNECT, RESOURCE TO aq;
GRANT EXECUTE ON dbms_aq TO aq;
GRANT EXECUTE ON dbms_aqadm TO aq;
 

Create Q Table and Q of Object Type

 
connect aq/aq;
 
CREATE type aq.Message_typ AS object (
subject VARCHAR2(30),
text VARCHAR2(80));
/
 
begin
  DBMS_AQADM.CREATE_QUEUE_TABLE (
  queue_table => 'aq.objmsgs80_qtab',
  queue_payload_type => 'aq.Message_typ');
 
   DBMS_AQADM.CREATE_QUEUE (
  queue_name => 'msg_queue',
  queue_table => 'aq.objmsgs80_qtab');
 
   DBMS_AQADM.START_QUEUE (
  queue_name => 'msg_queue');
end;
/
 

Create a Q Table and Q of Raw Type

 
begin
  DBMS_AQADM.CREATE_QUEUE_TABLE (
  queue_table => 'aq.RawMsgs_qtab',
  queue_payload_type => 'RAW');
 
  DBMS_AQADM.CREATE_QUEUE (
  queue_name => 'raw_msg_queue',
  queue_table => 'aq.RawMsgs_qtab');
 
  DBMS_AQADM.START_QUEUE (
  queue_name => 'raw_msg_queue');
end;
/
 

Create a Prioritized Message Q Table and Q

 
begin
  DBMS_AQADM.CREATE_QUEUE_TABLE (
  queue_table => 'aq.priority_msg',
  sort_list => 'PRIORITY,ENQ_TIME',
  queue_payload_type => 'aq.Message_typ');
 
  DBMS_AQADM.CREATE_QUEUE (
  queue_name => 'priority_msg_queue',
  queue_table => 'aq.priority_msg');
 
  DBMS_AQADM.START_QUEUE (
  queue_name => 'priority_msg_queue');
end;
/
 

Drop Queue

 
begin
   DBMS_AQADM.STOP_QUEUE(
      queue_name => 'TEST_QUEUE');
 
   DBMS_AQADM.DROP_QUEUE(
      Queue_name => 'TEST_QUEUE');
 
   DBMS_AQADM.DROP_QUEUE_TABLE(
        Queue_table => 'TEST_QUEUE_TAB');
END;

References

* Oracle® Streams Advanced Queuing User's Guide and Reference Release 10.1 Part No. B10785-01
* http://www.akadia.com/services/ora_advanced_queueing.html
* AQ vs JMS
* Oracle DBMS_AQADM

Linux Services

Starting Services

init daemon

* Run when system boots or enter a run level.
* Starts all rc scripts starting with "S" in a run level's rc subdirectory (e.g. /etc/rc.d/rc.3).
* Restarts a service if service dies in a particular run level and marked by respawn (e.g. x:5:respawn:/etc/X11/prefdm -nodaemon).

Run levels

* Defined in /etc/inittab file
* Total 7 run levels (0 to 6).
* Default run level defined by "id:5:initdefault:" (5 for GUI, 3 for non-GUI).
* System can only be at one run level at a time.
* /sbin/runlevel: current run level.

Manages init Script Symbolic Links

/sbin/chkconfig

* Copy startup script, e.g. myscript, to /etc/init.d directory.
* Add to the beginning of myscript:

# chkconfig: 234 99 90
# description: myscript runs my daemon at runlevel 2, 3, or 4

* Run chkconfig:

chkconfig --delete myscript
chkconfig --add myscript

* This will create symbolic links named "S99myscript" in the rc.2, rc.3, rc.4 directories and "K90myscript" in the rc.0, rc.1, rc.5, rc.6 directories.

Start/Stop Services

/etc/init.d/myscript start
/etc/init.d/myscript stop

# Redhat
service myscript start
service myscript stop
service myscript restart

heartbeat

* When service starts or need a resource
* Better to have redundant heartbeat connections
- Serial cable
- Ethernet cable
* Partitioned clusters
- When both assume primary server role
- Resolution: stonith
* Heartbeat configuration files
- /etc/ha.d/ha.cf # specifies how ha daemons communicate with each other
- /etc/ha.d/haresources # specifies which server should act as primary for a resource
- /etc/ha.d/authkeys # specifies how ha packets should be encrypted

xinetd: when network request comes in

Other non-standard method

Secondary IP Addresses

# View both primary and secondary ip addresses
ip addr sh
ip addr sh dev eth0

# Add secondary ip
ip addr add 209.100.100.3/24 broadcast 209.100.100.255 dev eth0

# Remove secondary ip
ip addr del 209.100.100.3/24 broadcast 209.100.100.255 dev eth0

References

The Linux Enterprise Cluster by Karl Kopper

Configure Savvion SBM75

Integrate with ldap
* Edit conf/umacl.conf

userMgr.external=false
ldap.server.provider=MSActive
ldap.server.location=ldap://my.com:3268
ldap.ssl=false
ldap.user.name=me
ldap.user.password=pass
ldap.user.search.root=DC=my,DC=com
ldap.group.search.root=

Java Extension Mechanism

Three types of classes

Bootstrap classes

* Core Java classes
* Specified by system property sun.boot.class.path
* -Xbootclasspath switches bootstrap classpath

Extension classes

* Specified by system property -Djava.ext.dirs
* Defaults to java.home/lib/ext
* Can use soft link in Unix or junction in Windows to switch to a different extension directory

User classes

* User classes are searched last

References
The Java Extension Mechanism