Thursday, November 10, 2011

Clone Virtual Box machine

I have existing Virtual Box machine, Rehat 5.5 and Oracle database are installed and configured.

I want to create Oracle Data Guard standby database, so I need to clone the existing one in order to save time and here's how to do it:

Operating System: CentOS 5.5 64 bit
Oracle Virtual Box version: 4.0.6
The first machine name: DataGuard1 existed at /home/osama/VirtualBox VMs

1-Clone the virtual disk:
[root@omniyapc osama]# VBoxManage clonevdi /home/osama/VirtualBox\ VMs/DataGuard1/DataGuard1.vdi /home/osama/VirtualBox\ VMs/DataGuard2/DataGuard2.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 4413e40f-f3e5-4aa0-858a-873bb539cf26


Note that Virtual Box will create the needed directories by itself.

2-Create new Virtual machine, and chose the cloned virtual disk.
When tried, I've get this error:
That's because permissions, as you note I cloned the disk using root user, simple change the owner and the group of the "DataGuard2" directory into the right user:

[root@omniyapc osama]# chown osama VirtualBox\ VMs/DataGuard2/ -R
[root@omniyapc osama]# chgrp osama VirtualBox\ VMs/DataGuard2/ -R


Then try using the disk again:

It works actually, but I disappointed again because Redhat didn't start and give me this error:
It could not mount the cloned disk, after double check the difference between it and the original machine, I found that the original machine disks type was IDE, while the newly created one are SATA, after removing the SATA disk and adding it as IDE one it works and Redhat starts successfully.

At other hand I got this dialog at Virtual Box manager:

and this one too after shutting down the new machine:

This message disappeared after closing and re-opening Virtual Box, it seems that it cashing some thing, actually I'm not sure why I got it but that's solve my problem.

Sunday, October 16, 2011

Session timeout at Apache 2.2

I have Oracle BI Publisher 10.1.3.4 deployed over Apache Tomcat 7 using it as a reporting tool.
At other hand, there's Apache web server 2.2 used as proxy server and it redirects the reporting requests to Tomcat.


Today I finished building some new report, actually it consumes much time to execute, when try it from BI Publisher that deployed at Tomcat it works perfectly, but when try to access it via the redirector (httpd 2.2) it gives this error:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /xmlpserver///Dialup_Reports/Geographical_Total_Calls/Geographical_Total_Calls.xdo.
Reason: Error reading from remote server

Apache/2.2.3 (CentOS) Server at 31.193.78.197 Port 80
 
Actually that was because of the session timeout of Apache server 2.2 (by default it's 120 seconds) :


So the problem sovled by increasing the "Timeout" value to 600 (5 minutes) and adding "ProxyTimeout 600" directive.
Finally restart the httpd service and it should work well.

Tuesday, September 13, 2011

Configure VNC at Centos 5.5 Linux


Intro:

As former Windows user, I used to lean on remote desktop service in order to access another Windows computer over the network.
That was the single practical way to deal with remote computer for Windows, because there (at Windows) every thing is done using GUI.

At Linux it's a bit different, because you can almost do everything using secure shell (ssh) connection, just access the target computer shell and enjoy ;)
But some times you need (or prefer) to use Windows way in order to access other Linux machine, and one of the most famous way to do this is using Virtual Networked Computing (VNC).
This is simple tutorial shows how much it's easy and effective to use VNC.

Requirements:

The VNC method is based on using a VNC Server installed and running over the target machine, and using VNC Viewer installed and running over your machine which you could use it to communicate with target machine VNC Server.

At this tutorial, at both machines there's CentOS Linux 5.5 installed, VNC server and viewer are available at CentOS updates repository and you can install them using yum:

# yum install vnc-server
# yum install vnc
At other hand you can check if VNC is installed by using rpm to query VNC installed packages:
# rpm -qa | grep vnc
vnc-4.1.2-14.el5_6.6
vnc-server-4.1.2-14.el5_6.6
At target machine:

As I described, VNC server should be installed at the target machine, after finishing this step you should add a user to this server in order to use it for accessing.

Edit the file /etc/sysconfig/vncservers as root user and add this couple lines to the end of the file:

# nano /etc/sysconfig/vncservers
VNCSERVERS="1:osama"
VNCSERVERARGS[1]="-geometry 800x600 -depth 16 -nolisten tcp -nohttpd -localhost"
The first line sets up a user (osama) for the NVC server, surly you can add any additional number of users here.
Whereas the second line describes the argument (configuration) for each user, ie:
VNCSERVERARGS[1] <=> VNCSERVERS="1:osama"

Geometry argument describes the screen resolution (800 pixel x 600 pixel), Depth argument describes the color depth, nolisten tcp argument used to prevent X connections to your VNC server via TCP, nohttpd argument used to prevent web-based VNC clients connecting., and finally localhost argument used to prevent remote VNC clients connecting except when doing so through a secure tunnel.

Tip about the ports:

When you try to connect using VNC, you need to specify the port number used for this connection, to know the used port you should calculate it using this tricky way:
5900 + (Session number) = VNC Port
The session number is the defined number at “/etc/sysconfig/vncservers” file, for our case it was “1” for the user “osama”, VNCSERVERS="1:osama".
So the used port number for our case is : 5900 + 1 = 5901

Setting a password:

VNC need to specify a password before a connection can be established, you can do so using “vncpasswd” command:
# vncpasswd
Password:
Verify:

Starting and stopping the server:

You can start the VNC server using “vncserver” command followed by the session number that you configured at “/etc/sysconfig/vncservers” file:
# vncserver :1
New 'omniyapc:1 (osama)' desktop is omniyapc:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/omniyapc:1.log
Now the server is started and a user could connect.
For stopping the VNC server use the command “vncserver” followed by “kill” parameter and the session number:

# vncserver -kill :1
Killing Xvnc process ID 30857
 
Configuring VNC server

By default, the connected users will get gray desktop because the connection will not start new session for X server, so you need to edit the startup script in the .vnc folder in the home directory:

# nano /root/.vnc/xstartup
Then un-comment these two lines and save:

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
But remember please that you have to restart the “vncserver” after this update.

At your machine:

As I described you should install “vnc” package at your machine in order to use it for connecting VNC server, and thus you can use it like this:

# vncviewer 192.168.30.15:5901
Which “192.168.30.15” is the remote machine IP address (surly you can use it defined name at your DNS) and “5901” is the calculated port that we talked about at previous section.

Then, VNC Viewer will ask you to enter the remote VNC server password that we defined at previous steps:


Enter the password and “play” remotely with visual desktop ;)

Sunday, September 11, 2011

The first "Date" with Apache Wicket !

Many JAVA developers didn't hear about Apache Wicket before, I was one of them too, but a happy occasion happened and I met Wicket !


When you are planning to build JAVA web application you have many choices, the first one is JSP and JAVA servlets, but for advanced application you need a framework make things more easy and enhance your productivity.


I've searched about JAVA frameworks before, I've checked Struts2, Spring MVC, JBoss Seam, Apache Tapestry and JSF, but actually I didn't applied them into any application, I've just tested them a little, so I didn't fall in love with these frameworks really !


Last month I decided to begin new "ambitious" project, and I was need a free JAVA framework, at other hand I was afraid of using these frameworks because of "XML tags soup", so Wicket was my decision at last for these reasons:


  1. It's free and open source
  2. It's Component Centric approach
  3. Swing-like Object Oriented Component Model
  4. No XML soup
  5. Just plain Java and HTML 
  6. There's many reuseable and flexible components
I had a look at couple books, Wicket in action and  Wicket Cookbook, the first one aimed for bigginers but I found it somehow "buggy" and confusing, while Wicket Cookbook is more clear and divided to sample with clear and complete description, so I recommend to go for Wicket website tutorials and examples first, then you can read Wicket Cookbook for great and usefull Wicket capabilities.

I'll post a tutorials about Wicket later, but for now if you tried Wicket let'us know your opinion ;)