Friday, August 10, 2007


Xen 3.1 Binary installation on CentOS 5.0 & ASUS P5B Deluxe



Perform Xen 3.1 binary download from following location :-








Try "http://xen.xensource.com/download/dl_31tarballs.html" if mentioned URL doesn't work.




Attempt to use compiled binaries might fail sooner or later due to hardware issues.
Fortunately, 2.6.18-xen kernel does understand the hardware assembled
on ASUS P5B Deluxe and Marvell Yukon Gigabit Ethernet in particular. Actually, it means that any board based on (I965+ICH8R) or (I975+ICH7R) would be in general OK for Xen 3.1 Binary installation , but might have trouble with Ethernet Adapter. The first example is Atansic Gigabit Eternet on ASUS P5B-E. This board would require xen kernel source to compile Atansic Ethernet Driver.


Install bridge-utils-XXXX-x86_64.rpm if needed.



cd /tmp
tar –xzvf xen-3.1.0-install-x86_64.tgz




The tar command will create a directory named "dist"



# cd dist




Place all of the Xen files into their places in the file system by running



# sh ./install.sh




Determine the name of the Xen Linux kernel version that was installed.



# ls /lib/modules




There should be a directory for the Xen Linux kernel (e.g., 2.6.18-xen)
Generate the module dependency list and map files



# /sbin/depmod 2.6.18-xen




Create the Xen initial ramdisk image



# /sbin/mkinitrd /boot/initrd-2.6.18-xen.img 2.6.18-xen




Disable tls


 
# mv /lib64/tls /lib64/tls.disabled




Set xend service to start



# /sbin/chkconfig --add xend
# /sbin/chkconfig xend on




Edit /boot/grub/grub.conf and copy one of the existing boot entries to make the required changes for Xen.



title Xen-3.1 x86_64 (2.6.16-xen)
root (hd0,2)
kernel /xen-3.1gz
module /vmlinuz-2.6.18-xen ro root=/dev/VolGroup00/LogVol01 rhgb quiet
module /initrd-2.6.18-xen.img




Reboot into new kernel and start network bridge.



# /etc/xen/scripts/network-bridge start netdev=eth0




System and Windows 2000 VM configuration:-








Perform HVM Windows 2000 VM install utilizing ISO image of distribution CD
already copied by "dd" to SATA hard drive.
Set boot="d" in VM's profile (w2k0.hvm) and proceed:-



# /usr/sbin/xm create w2k0.hvm
# vncviewer localhost::5900







Now set boot="c" in VM's profile (w2k0.hvm) :-



# /usr/sbin/xm create w2k0.hvm
# vncviewer localhost::5900







# /usr/sbin/xm create w2k0.hvm
# vncviewer localhost::5900









Windows XP VM installation procedure is quite similar


Network Bridge verification for Windows XP VM:-






Wednesday, August 08, 2007


Xen 3.1 Network Configuration on SLES 10 SP1



This posting is targeting to accomplish work started in [1]
Modify VMs profiles in /etc/xen/vm directory as follows:-





This is not important when you have just one Ethernet interface on the box.
Suppose you have two and created two bridges:-



# /etc/xen/scripts/network-bridge start bridge=xenbr0 netdev=eth0
# /etc/xen/scripts/network-bridge start bridge=xenbr1 netdev=eth1




For example the line:-



vif = [ 'bridge=xenbr0, mac=00:00:00:11:11:11' , 'bridge-xenbr1, mac=00:00:00:22:22:22' ]




would pass two NICs to the VM with different MAC addresses, eth0 pointing to xenbr0
and eth1 pointing to xenbr1, either you can choose which one of NICs to pass to particular VM.
Start network bridge with default name, start VMs windowsxp and windowsxp1 and disable Control Panel->Firewall
for both of them , then issue "brctl show":-








Start Network Wizard in each one of VMs and activate Windows Network GUI.
Verification of TCP/IP connectivity:-














Verification of TCP/IP connectivity from remote PC:-








VNC Connection to SLES 10 SP1 box running Xen 3.1 HVM VM



Adding line containing IP-address of SLES box on local network :-



vnclisten="192.168.0.56"




to VM's profile /etc/xen/vm/windowsxp
allows vncviewer to run Windows XP session on remote Linux and Windows boxes:-











References
1.Xen 3.1 HVM on SLES 10 SP1
http://lxer.com/module/newswire/view/90738/index.html

Friday, August 03, 2007


Xen 3.1 HVM on SLES 10 SP1



RPM's install suggested in [1] still causes SLES 10 GUI procedure creating Xen Windows XP VM to crash:-




Workaround for this issue follows bellow.


Kernel vmlinuz-2.6.16.46-12-xen and initrd-2.6.16.46-12-xen have been
created with YaST->Software Management using distribution CD
and system rebooted with new entry into menu.lst (grub.conf)
referencing xen-3.1.gz.








When graphical install for HVM VMS fails, keeping in mind notice [2] copy all missing files:-



-rwxr-xr-x 1 root root 18512 Aug 3 06:22 xenstore-chmod
-rwxr-xr-x 1 root root 17360 Aug 3 06:22 xenstore-exists
-rwxr-xr-x 1 root root 18280 Aug 3 06:22 xenstore-list
-rwxr-xr-x 1 root root 18312 Aug 3 06:22 xenstore-read
-rwxr-xr-x 1 root root 17960 Aug 3 06:22 xenstore-rm
-rwxr-xr-x 1 root root 17616 Aug 3 06:22 xenstore-write




from /usr/bin to /bin



# cd /etc/xen/vm
# ls -l
total 16
-rw-r--r-- 1 root root 496 Aug 3 15:25 windowsxp
-rw-r--r-- 1 root root 1032 Aug 3 15:19 windowsxp.xml


# /usr/sbin/xm create windowsxp




At this time boot="d" in file /etc/xen/vm/windowsxp
File /var/lib/xen/images/windowsxp/disk0 has been created 10 GB size utizing "dd":-



# dd if=/dev/zero of=/var/lib/xen/images/windowsxp/disk0 bs=1k count=10000000




Next:-



# vncviewer localhost




Perform text part of installation :-

formatting and coping data from CD to reiser FS file /var/lib/xen/images/windowsxp/disk0





After windows reboots vncviewer connection to server gets lost
Change boot from "d" to "c" in file /etc/xen/vm/windowsxp










# /usr/sbin/xm create windowsxp
# vncviewer localhost




Perform graphical part of installation




After windows reboots vncviewer connection to server gets lost again



# /usr/sbin/xm create windowsxp
# vncviewer localhost




Perform final part of installation




Start of already created HVM VMS:-






Several HVM VMs running at a time:-






References
1.http://www.novell.com/coolsolutions/tools/19338.html
2.http://wiki.novell.com/index.php/Talk:Xen_3.1_On_SLES_10_SP1

Thursday, July 19, 2007


Block Browser and Editor on Linux with Oracle 10g R2 database



Article [1] has been written in French, contains two interesting examples .
The posting bellow is supposed to be a translation final part from [1] to English,
dealing with other tables from sample schemas loaded during standard installation.
However , the way to obtain oracle's file number and block number for particular
record from selected table is different from [1].
We also focus attention at index corruption after changing field's value or record
recovery by BBED.


1.Modifying field's value for particular record in hr.departments table.


Get file number and header block for table hr.departments:-



select owner,segment_name,header_file,header_block,blocks
from dba_segments
where owner='HR' and segment_name='DEPARTMENTS';


OWNER SEGMENT_NAME HEADER_FILE HEADER_BLOCK BLOCKS
------- ------------------- -------------------- ---------------------- -------------
SCOTT EMP 5 55 8




Getting block number of record, supposed to be changed, with dbms_rowid package:-




Searching for offset of the pattern:-




Run "modify /c Abcdefg" to replace "Support" :-




Update block's checksum:-




Verify data with select statement:-



SQL> alter system flush buffer_cache;




To force Oracle perform reading block from disk device,not from buffer cache.




2.Recovering deleted record from scott.emp.


Get file number and header block for table scott.emp:-



select owner,segment_name,header_file,header_block,blocks
from dba_segments
where owner='SCOTT' and segment_name='EMP';


OWNER SEGMENT_NAME HEADER_FILE HEADER_BLOCK BLOCKS
------ ----------- ------------- -------------- ------
SCOTT EMP 4 27 8




Get the block number contains record with ename='JAMES' like in previous example.
Then search for word 'JAMES' to get it's offset.



Make dump with offset=offset-16 and look for first byte of the record (0x2c)
Watch the value of first byte of record when it got deleted.




First byte of deleted record appears to be changed to hexadecimal 0x3c.
The intend is to put 0x2c back on it's place as the first byte of deleted record.



SQL> delete from emp where ename='JAMES';

1 row deleted.

SQL> commit;

Commit complete.




Run "modify /x 2c" in bbed:-




Update block's checksum:-




Restart Oracle instance:-



SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 83887720 bytes
Database Buffers 192937984 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.




Or just:-



SQL> alter system flush buffer_cache;




To force Oracle perform reading block from disk device,not from buffer cache.


Check for undeleted record:-



SQL> conn scott/tiger@orcl;
Connected.

SQL> select * from emp where ename='JAMES';

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7900 JAMES CLERK 7698 03-DEC-81 950
30

SQL> select * from emp where empno=7900;
no rows selected




At this point it became quite clear , that we have to recreate any indexes on table,
which records have been recovered by BBED.They are no longer valid.
Same issue will be in place regarding indexes based on columns have been modified by BBED.
Recreate index on empno field of emp table:-



SQL> alter table emp drop constraint PK_EMP;

Table altered.

SQL> alter table emp add constraint PK_EMP primary key(empno);

Table altered.

SQL> select * from emp where empno=7900;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7900 JAMES CLERK 7698 03-DEC-81 950
30




References.


1.http://mbouayoun.developpez.com/bbed/
2.http://orafaq.com/papers/dissassembling_the_data_block.pdf

Sunday, July 15, 2007


Block browse and edit utility (BBED) in Oracle 10g R2 on Linux



First login as oracle to compile bbed:



$ cd $ORACLE_HOME/rdbms/lib
$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
$ls -la bbed
$ cp $ORACLE_HOME/rdbms/lib/bbed $ORACLE_HOME/bin




Use any hexadecimal editor on Linux to discover password
needed to start bbed:-



[oracle@ServerORCL orcl]$ bbed
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Sun Jul 15 14:17:39 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> show
FILE# 0
BLOCK# 1
OFFSET 0
DBA 0x00000000 (0 0,1)
FILENAME
BIFILE bifile.bbd
LISTFILE
BLOCKSIZE 8192
MODE Browse
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No




Next run as sysdba:-




SQL> select owner,segment_name,header_file,header_block,blocks
2 from dba_segments
3 where owner='HR' and segment_name='DEPARTMENTS';

OWNER
------------------------------
SEGMENT_NAME
-----------------------------------
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
HR
DEPARTMENTS
5 51 8




Tune BBED properly to perform block corruption for hr.departments table.



BBED> set listfile '/home/oracle/bbed.log'
LISTFILE /home/oracle/bbed.log
BBED> set blocksize 8192
BLOCKSIZE 8192
BBED> set filename '/u02/oradata/orcl/example01.dbf'
BBED> set dba 5,52
BBED> set mode edit
BBED> show
FILE# 5
BLOCK# 52
OFFSET 0
DBA 0x01400034 (20971572 5,52)
FILENAME /u02/oradata/orcl/example01.dbf
BIFILE bifile.bbd
LISTFILE /home/oracle/bbed.log
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 64
LOGFILE log.bbd
SPOOL No


[oracle@ServerORCL ~]$ cat bbed.log
1 /u02/oradata/orcl/system01.dbf 503316480
2 /u02/oradata/orcl/undotbs01.dbf 41943040
3 /u02/oradata/orcl/sysaux01.dbf 262144000
4 /u02/oradata/orcl/users01.dbf 5242880
5 /u02/oradata/orcl/example01.dbf 104857600




Replace second block of table



BBED> set offset 0
OFFSET 0

BBED> copy dba 5,10 to dba 5,52
File: /u02/oradata/orcl/example01.dbf (5)
Block: 52 Offsets: 0 to 63 Dba:0x01400034
------------------------------------------------------------------------
21a20000 0a004001 0ed00600 00000104 414e0000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000




Restart Oracle instance.



SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 75499112 bytes
Database Buffers 201326592 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.




Connect as HR to get block corruption error
when SELECT * FROM DEPARTMENTS.
Then start rman:-



RMAN> connect target /
RMAN> run {BACKUP VALIDATE DATABASE;}
Starting backup at 15-JUL-07
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u02/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u02/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u02/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u02/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u02/oradata/orcl/users01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 15-JUL-07




Run query as SYSDBA



select * from V$backup_corruption;


RECID STAMP SET_STAMP SET_COUNT PIECE# FILE# BLOCK#
---------- ---------- ---------- ---------- ---------- ---------- ----------
BLOCKS CORRUPTION_CHANGE# MAR CORRUPTIO
---------- ------------------ --- ---------
7 628005346 628005315 9 1 5 52
1 0 YES CORRUPT




Proceed with RMAN block recovery



RMAN> run {blockrecover datafile 5 block 52;}

Starting blockrecover at 15-JUL-07
using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: reading from backup piece
/u01/app/oracle/flash_recovery_area/ORCL/backupset/2007_07_15/
o1_mf_nnndf_TAG20070715T105801_39mkctc7_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1 piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2007_07_15/
o1_mf_nnndf_TAG20070715T105801_39mkctc7_.bkp
tag=TAG20070715T105801
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:07
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished blockrecover at 15-JUL-07




Connect as HR to perform SELECT * FROM DEPARTMENTS without errors.

Friday, June 29, 2007


Deployment Seam Application against MySQL 5 database to Jboss 4.0.5
utilizing Seam Plugin for NetBeans 5.5.1



Attempt of straightforward deployment performed as suggested in Michael Yuan's blog ([2])
for HyperSonic Database causes some issues.View comment # 47 in [2].
Procedure described bellow generates runnable Seam application under Jboss 4.0.5
working with MySQL 5.0.37 database
First of all tune Jboss for proper connection to MySQL datavase as advised in [1].
Install the JDBC driver for JBoss by entering the following:



# cp mysql-connector-java-VERSION.jar $JBOSS_HOME/server/default/lib




Creating a New Data Source
Create a data source binding for a JDBC driver by performing the following on the JBoss Application Server:
Create a data source descriptor file named $JBOSS_HOME/server/default/deploy/mysql-ds.xml
and add the following contents:



<datasources>
<local-tx-datasource>
<jndi-name>MysqlDS</jndi-name>
<connection-url>
jdbc:mysql://localhost:3306/mytestdb
</connection-url>
<driver-class> com.mysql.jdbc.Driver</driver-class>
<user-name>jboss</user-name>
<password>jboss</password>
<max-pool-size>50</max-pool-size>
<min-pool-size>20</min-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements>true</track-statements>
</local-tx-datasource>
</datasources>




Configure the MySQL Server by performing the following steps (unix environment) :
Verify that the MySQL Server is running by entering the following:
# ps -ef|grep mysqld
If the MySQL Server is running, a process named mysqld displays in the output; otherwise, enter the following command:
# /etc/init.d/mysql start
If the database used in the JBoss data source does not exist, create the mytestdb database by entering the following:
# mysqladmin -u root -p create mytestdb
If the database user in the JBoss data source does not exist, create the user and
grant the appropriate privileges by entering the following from the MySQL prompt:
mysql> grant all on mytestdb.* to jboss@'%.%.%.%' identified by \
'jboss'; flush privileges;
The user named jboss with the password jboss is created and granted all operation privileges on the database mytestdb.
To test the connectivity between JBoss and MySQL, perform the following steps on the JBoss Application Server:
Create a JSP file named $JBOSS_HOME/server/default/deploy/jmx-console.war/mysqltest.jsp and add the following contents:



<%@page contentType="text/html" import="java.net.*,java.util.*,org.jboss.jmx.adaptor.model.*,
java.io.*,java.sql.*,javax.sql.*,javax.naming.*"%>
<html>
<head>
<title>JBoss->MySQL Test </title>
<link rel="stylesheet" href="style_master.css" type="text/css">
<meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<%
InitialContext ctx = new InitialContext();
DatabaseMetaData dm = null;
DataSource ds = (DataSource)
ctx.lookup("java:/MysqlDS");
Connection conn = null;
Statement stmt = null;
try {
conn = ds.getConnection();
dm =conn.getMetaData();
out.println("Connected to-> database version "+dm.getDatabaseProductVersion());
}catch (Exception sqlex) {
out.println(sqlex.getMessage());
}finally{
conn.close();
}
%>
</body>
</html>




Launch JBoss by entering the following:
# $JBOSS_HOME/bin/run.sh
Verify that JBoss is connecting to MySQL by opening a browser and navigating to the following URL:
http://localhost:8080/jmx-console/mysqltest.jsp


For windows environment manage accordingly.
Create schema in database "mytestdb" to generate Seam project with entities.




Make following changes to generated entities:-



In Dba01.java
@Entity
@Table(name = "dba01", catalog = "mytestdb")
replace with
@Entity
@Table(name = "dba01", catalog = "")


In Dba02.java
@Entity
@Table(name = "dba02", catalog = "mytestdb")
replace with
@Entity
@Table(name = "dba02", catalog = "")






Deploy modified project to Jboss :-




Run deployed Seam Application:-





Jboss output during this run:-




References.
1.http://docs.hp.com/en/5991-5569/ar01s04.html?btnNext=next%A0%BB
2.http://www.michaelyuan.com/blog/2007/04/17/first-release-of-seam-plugin-for-netbeans/

Saturday, June 23, 2007


Deployment Seam Application against Oracle 10g database to Jboss 4.0.5
utilizing Seam Plugin for NetBeans 5.5.1 on CentOS 5.0



To tune Jboss 4.0.5 instance as advised in [1] and make it connects to Oracle Server, perform the following steps on the JBoss Application Server:
Download the JDBC driver for Oracle 10g Release 2 located at:
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
For the Oracle JDBC driver with JDK 1.4 and 1.5, use the ojdbc14.jar file.
Copy the JDBC driver to the JBoss environment by entering the following:
# cp ojdbc14.jar $JBOSS_HOME/server/default/lib
Create a file named $JBOSS_HOME/server/default/deploy/oracle-ds.xml and add the following contents:



<datasources>
<local-tx-datasource>
<jndi-name>oracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@IP_OR_HOSTNAME_OF _ORACLE_DB_ SERVER:1521:ORACLE_SID
</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>USERNAME</user-name>
<password>PASSWORD</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>




Testing the Oracle Database Connectivity
Test the connectivity between JBoss and Oracle by performing the following steps on the JBoss Application Server:
Create a JSP file named $JBOSS_HOME/server/default/deploy/jmx-console.war/oracleTest.jsp and add the following contents:



<%@page contentType="text/html" import="java.net.*,java.util.*,org.jboss.jmx.adaptor.model.*,
java.io.*,java.sql.*,javax.sql.*,javax.naming.*"%>
<html>
<head>
<title>JBoss->Oracle Test </title>
<link rel="stylesheet" href="style_master.css" type="text/css">
<meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<%
InitialContext ctx = new InitialContext();
DatabaseMetaData dm = null;
DataSource ds = (DataSource)
ctx.lookup("java:/oracleDS");
Connection conn = null;
Statement stmt = null;
try {
conn = ds.getConnection();
dm =conn.getMetaData();
out.println("Connected to-> database version "+dm.getDatabaseProductVersion());
}catch (Exception sqlex) {
out.println(sqlex.getMessage());
}finally{
conn.close();
}
%>
</body>
</html>




Start JBoss by entering the following:
# $JBOSS_HOME/bin/run.sh
Verify that the Oracle test page is displayed by opening a browser and navigating to the following URL:
http://YOUR_HOSTNAME:8080/jmx-console/oracleTest.jsp




JDK version has been used 1.5.09. You might experience problems with 1.6.01.


Install Seam Plugin [2] and facelets support for NetBeans 5.5.1.
Register Jboss 4.0.5 instance with NetBeans and proceed following [2]












Unload NetBeans IDE, restart Jboss to make sure application run stable.








References.
1.http://docs.hp.com/en/5991-5569/ar01s04.html?btnNext=next%A0%BB
2.http://www.michaelyuan.com/blog/2007/04/17/first-release-of-seam-plugin-for-netbeans/