Table of Contents
Installing Oracle 10g on a Gentoo Vserver
Introduction
This document explains how to install Oracle 10g on a Gentoo box, in its own virtual server.
Host setup
Installing required packages
We'll need to rebuild the kernel (see Resources below), and install some vserver tools.
emerge -uv vserver-sources util-vserver
Preparing a partition for the guest server
In this document we'll use a brand new partition for the guest. It could be improved by dynamically create lvm logical volumes upon virtual server creation, but such mechanism is out of the scope of this document.
Using LVM
If you're using LVM2, then free up some space and create a new logical volume. If all the disk space is taken by the LVM logical volumes, then you'll have to resize some filesystems, and afterwards resize the logical volume(s) in order to allocate a new one, for the guest server. The LVM commands you'll need will be
umount [lvName] lvchange -a n [vgName/lvName] lvresize -L -[X]G [vgName/lvName] lvchange -a y [vgName/lvName] mount [lvName] lvcreate -L [X]G [vgName/guestName] lvchange -a y [vgName/guestName] mkreiserfs /dev/mapper/[vgName-guestName]
Using physical partitions
In this case it's easy, just create the filesystem you choose in it.
Mounting the partition
Update your /etc/fstab so that it includes a line indicating to mount under /vservers the new filesystem for the guest. Then,
cd /vservers mkdir [guestName] mount [guestName]
Choose a name for your guest and stick with it. I chose gentora for Gentoo and Oracle.
Host services
One thing you need to know regarding vservers is that when both the host and any guest is providing the same service (using the same port), the service on the host will need to define in which IP address it's listening. Since you'll likely want to access your guest(s) using ssh, start by editing your /etc/ssh/sshd_config, so that the ListenAddress directive includes the host IP:
ListenAddress [HostIP]
The same applies to any other service (such as Apache) you want to offer both on the host and in all or some of the guests.
Sysctl changes
Read Gentoo-Wiki page (see Resources below) and update etc/sysctl.conf accordingly. In my case I had to append to my sysctl.conf the following:
kernel.shmmax = 2147483648 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 1024 65000
And afterwards,
sysctl -p
Guest setup
Creating from template
Download a pre-packaged stage3 from a Gentoo mirror and copy it to your /vservers folder.
cd /vservers vserver-new [guestName] --context 1[IP] --hostname [yourHostname]-[guestName] --interface eth0://[IP]/24 --destroy stage3 stage3-x86-20060317.tar.bz2 x86
The destroy argument is needed so that the script will be able to remount the guest partition.
Update settings
In the guest server (that is, under /vservers/[guestName]/, you'll have to
cp /etc/resolv.conf /vservers/[guestName]/etc/ cp /etc/conf.d/net /vservers/[guestName]/etc/conf.d
and then update
*. /etc/conf.d/net
Comment
config_eth0=( "dhcp" )
and define the static IP
config_eth0=( "[IP] netmask 255.255.255.0" )
as well as the default route
routes_eth0=("default via [gateway]")
*. /etc/conf.d/hostname, to specify the correct hostname for the guest. *. /etc/conf.d/domainname, to point to the correct domain. *. /etc/hosts, deleting the last fake entry, and adding
[IP] [guestName] [guestName].[domain]
Starting the guest
Now, let's try to start the guest:
vserver [guestName] start
In case it complains about invalid IP or mask, just edit /etc/vservers/[guestName]/interfaces/0/ip and/or /etc/vservers/[guestName]/interfaces/0/mask and fix it.
Now you can enter in your new guest!
vserver [guestName] enter
In case the script didn't manage it for you, just make sure the profile (/etc/make.profile) points to the correct one (/usr/portage/profiles/default-linux/x86/vserver), and that it's using sys-apps/baselayout-vserver instead of sys-apps/baselayout.
You can leave your guest for a while
exit
Shared portage among host and guest(s)
Since the contents of /usr/portage are equal to both the host and the guests, it's best to use only one folder structure. You just need to tell the guest what to mount whenever it starts. Do it by editing /etc/vservers/[guestName]/fstab
[..] # Comment the /tmp entry #none /tmp tmpfs size=16m,mode=1777 0 0 [..] # shared portage tree /usr/portage /usr/portage none bind,ro 0 0 /usr/portage/distfiles /usr/portage/distfiles none bind,rw 0 0
When you restart your guest you'll get the same portage contents as the host from now on.
vserver [guestName] restart cp /etc/resolv.conf /vservers/[guestName]/etc cp /etc/make.conf /vservers/[guestName]/etc vserver [guestName] enter
Should you have lots of desktop-related USE flags, you should get rid of them since they wouldn't fit into the purpose behind a database server.
Installing useful tools
I recommend to start emerging some basic stuff to make our lives easier:
emerge -C pam-login emerge -uv eix vixie-cron syslog-ng bash-completion vim gentoolkit unzip slocate openssh update-eix rc-update add sshd default emerge -uv world etc-update revdep-rebuild
Chances are that it'll update gcc and glibc, so take a seat and wait...
Downloading Oracle 10g
You can proceed to download Oracle 10g either from Oracle directly. The rest of this document expects the zip file under /vservers/[guestName]/opt
Installing Oracle 10g
cd /opt unzip 10201_database_linux32.zip
If you try to execute /opt/database/runInstaller, it'll complain saying the distribution is not supported. The Gentoo-Wiki page (see Resources below) has the answer.
groupadd dba groupadd oinstall useradd -c "Oracle Software Owner" -g oinstall -G dba -d /opt/oracle -m oracle chown root:root /tmp chmod 1777 /tmp export TEMP=/tmp export TMPDIR=/tmp mkdir -p /opt/oracle/product/10.1.0.3 chown -R oracle:oinstall /opt/oracle chmod 755 /opt/oracle/
You should change the password of the new user:
passwd oracle
Create the environment script:
cat <<EOF > /etc/env.d/99oracle ORACLE_BASE=/opt/oracle ORACLE_HOME=/opt/oracle/product/10.1.0.3 ORACLE_SID='YOURSID' ORACLE_TERM=xterm ORACLE_OWNER=oracle ORACLE_HOSTNAME=[guestName].[domain] TNS_ADMIN=/opt/oracle/product/10.1.0.3/network/admin NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 ORA_NLS10=/opt/oracle/product/10.1.0.3/nls/data CLASSPATH=/opt/oracle/product/10.1.0.3/jdbc/lib/classes12.zip LD_LIBRARY_PATH=/opt/oracle/product/10.1.0.3/lib:/opt/oracle/product/10.1.0.3/lib32 DISABLE_HUGETLBFS=1 PATH=/opt/oracle/product/10.1.0.3/bin ROOTPATH=/opt/oracle/product/10.1.0.3/bin LDPATH=/opt/oracle/product/10.1.0.3/lib:/opt/oracle/product/10.1.0.3/lib32 TZ=GMT EOF
Notice the SID and ORACLE_HOSTNAME above are just placeholders.
env-update source /etc/profile
Installing packages required to run the installer
This will take a lot of time too.
emerge -uav openmotif xorg-x11 libaio ln -s /usr/lib/libstdc++-v3/libstdc++.so.5 /usr/lib
Configuring SSH X forwarding
We'll use the host X server to manage the GUI apps. First, make sure your ssh server (in the guest) is configured to allow X11 port forwarding, and that the exported DISPLAY doesn't include localhost. Edit /etc/ssh/sshd_config, uncommenting and changing the following entries:
[...] X11Forwarding yes #X11DisplayOffset 10 X11UseLocalhost no [...]
Also, make sure the host /etc/hosts knows about the guest, as well as the guest's /etc/hosts knows about the host.
Now restart the server with /etc/init.d/sshd restart, and try this from the host:
xhost +[guestName].[domain] ssh -X oracle@[guestName].[domain] /usr/bin/xclock
If you get the clock, you can now proceed installing Oracle 10g.
Running the Installer
Let's execute the installer instead of the xclock:
ssh -X oracle@[guestName].[domain] /opt/database/runInstaller -ignoreSysPrereqs
However, in my environment, the installer window appears, but its contents are not displayed. It's possible to manage the installer using the keys, so I guessed it had to do with the JRE it was using. I'm installing Oracle 10g on a gentoo-hosted gentoo virtual server, and the problem gets solved by installing JDK 1.5
echo "dev-java/sun-jdk X" >> /etc/portage/package.use/sun-jdk emerge -uv jdk rpm gentoolkit ln -s /usr/bin/rpm /bin
and then
./runInstaller -nobackground -ignoreSysPrereqs -jreLoc /opt/sun-jdk-1.5.XX/jre
Change the previous XX with the version of the JDK 5.0 installed in the guest. You could use the script below as part of the previous command-line (executing it inside ` symbols), but take care in which environment it's being executed. It has to point to the guest's JDK, of course.
equery list -i | grep sun-jdk-1.5 | awk -F"-" '{print $4;}'
Note: Installing in other host and guest led me to the same problem of invisible window contents (and also, the window size was huge). After some tries, I installed sun-jdk-1.6 with no effect. I started to work after I switched to it with java-config --set-user-vm=sun-jdk-1.6.
Resources
- Gentoo VServer HOW-TO
.
- Gentoo's forum post
.
- Gentoo-Wiki Gentoo-wiki
.
