Sunday, 26 May 2013

How To Install ORACLE on Debian Wheezy 64 Bit

This is just a tutorial how to install ORACLE 11 R2 on Debian, if you want something that fully supported go for RedHat Linux or Oracle Linux itself. This is just for education purpose and for fun.

My installation based on Debian Wheezy 64 bit with HVM under Xen.

1. Make your Debian more compatible with ORACLE.
apt-get install gcc make binutils libmotif4 lesstif2 rpm libaio1 libdb4.6 libstdc++5 
apt-get install xserver-xorg-video-dummy vnc4server x11-xserver-utils xterm wm2
   * if you get an error about libmotif4, please make sure you have non-free on your repositories.

2. Make all the symbolic links.

ln -s /usr/bin/awk /bin/awk 
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
ln -s /etc /etc/rc.d
ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib/
ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/
ln -s /usr/lib /usr/lib64

3. Once all the links created, edit /etc/sysctl.conf and add the following :
kernel.sem = 250 32000 100 128
kernel.shmmax = 2147483648
net.ipv4.ip_local_port_range = 9000 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
fs.file-max = 6815744
    * use command sysctl -p to make all the new parameters live.

4. Edit /etc/security/limits.conf and add the following:
*               soft    nproc   2047
*               hard    nproc   16384
*               soft    nofile  1024
*               hard    nofile  65536

5. Now go to  /etc/profile  then add the following:
if [ $USER = "oracle" ]; then
      if [ $SHELL = "/bin/ksh" ]; then
            ulimit -p 16384
            ulimit -n 65536
      else
            ulimit -u 16384 -n 65536
      fi
fi

6. Now create oracle user.
groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba -p passwd -s /bin/bash -d /home/oracle oracle
passwd oracle

7. Edit /home/oracle/.profile 
ORACLE_BASE=/u01/app/oracle
ORACLE_SID=instancename
export ORACLE_BASE ORACLE_SID
unset ORACLE_HOME
unset TNS_ADMIN
ORACLE_BASE=/u01/app/oracle
ORACLE_SID=instancename
ORATAB=/etc/oratab
export PATH=$PATH:/u01/app/oracle/product/11.2.0/dbhome_1/bin/
export ORACLE_BASE ORACLE_SID ORATAB
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
unset TNS_ADMIN
   *1st one is before the installation, change it become the second one after the installation done.

8. Create the following directory
mkdir /home/u01
ln -s /home/u01 /
mkdir /u02/oradata   <-- assuming it's already mounted
chown -R oracle.oinstall /home/u01 /u02/
chmod -R 775 /home/u01 /u02/

9. As an oracle user, please execute vnc4server once. Please kill the process after it runs. Now edit the file /home/oracle/.vnc/xstartup and add the following:
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
wm2 &

10. Extact the oracle zip file to folder /opt/ and then execute chown -R oracle.oinstall /opt/database

11. Now VNC to the server then execute the installer files.

12. You will encounter one error related with ins_emagent.mk, the things need to be done is go to /u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk, look for

$(MK_EMAGENT_NMECTL) then change it become $(MK_EMAGENT_NMECTL) -lnnz11

13. Follow all the steps and you are good to go.
14. Create /etc/init.d/oracle, and add the script below:
#!/bin/bash
#
# Run-level Startup script for the Oracle Instance and Listener
#
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance

### BEGIN INIT INFO
# Provides:          oracle
# Required-Start:    $remote_fs $syslog $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Oracle database server
# Description:       Oracle database server
### END INIT INFO

ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
ORACLE_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
        echo "Oracle startup: cannot start"
        exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
    start)
        # Oracle listener and instance startup
        echo -n "Starting Oracle: "
        su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
        su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
        touch /var/lock/oracle
        echo "OK"
        ;;
    stop)
        # Oracle listener and instance shutdown
        echo -n "Shutdown Oracle: "
        su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
        su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
        rm -f /var/lock/oracle
        echo "OK"
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)  
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0
References : http://www.debian-administration.org/article/656/Installing_Oracle11_on_Debian_Squeeze_and_Lenny http://trac.klp.org.in/wiki/OracleAccess#Oracleondev.klp.org.in https://cn.forums.oracle.com/forums/thread.jspa?threadID=1091616 http://www.gizmojunkee.com/2012/05/installing-oracle-11gr2-on-ubuntu-12-04/

Tuesday, 26 March 2013

How to install DBD::mysql on OSX (Perlbrew)

Step 1 : Install MySQL, from dev.mysql.com
Step 2 : Configure MySQL

  • PATH=$PATH:/usr/local/mysql/bin
  • mysqladmin -u root password 'your_password'
Step 3 : Install DBD::mysql

  • perl -MCPAN -e 'shell'
  • get DBD::mysql
  • cd ~/.cpan/build/DBD-mysql-5*/
  • perl Makefile.PL--testuser='mysql_user_name' --testpassword='mysql_passwd'
  • cd /usr/local/lib
  • sudo ln -s /usr/local/mysql/lib/*.dylib .
  • make
  • make test
  • sudo make install
It voila..it works now :)

Saturday, 29 December 2012

Upgrading OpenBSD from 5.1 to 5.2


OpenBSD 5.1 -> 5.2 upgrade guide

1. Get 5.2′s bsd.rd from FTP and put it on /
2. Boot it by typing boot bsd.rd (on PC architectures only)
3. Select Upgrade
4. Follow the steps…
*When put location you can use disk or through internet, if it can't found the server just key in one more time the server name.
5. Reboot
6. Get etc52.tgz and xetc52.tgz
7. cd to that location and do
    sysmerge -s etc52.tgz -x xetc52.tgz
8. Follow the steps
9. Reboot
10. Welcome to the latest openBSD system.

ref : http://threebsd.wordpress.com/2012/11/03/openbsd-5-1-5-2-upgrade-guide/

Wednesday, 17 October 2012

Color Terminal on freeBSD/OpenBSD

This is how to get color on your freeBSD or openBSD terminal.

for freeBSD user please follow
#cd /usr/ports/misc/gnuls
#make install clean

for openBSD user please follow
#pkg_add -r http://ftp.openbsd.org/pub/OpenBSD/5.1/packages/amd64/gnuls-4.1p2.tgz

$vi ~/.profile (if you are using csh) or $vi ~/.bash_profile

FreeBSD users:
-----
alias ls="gnuls --color =always"
-----

OpenBSD users:
----
alias ls="gls --color=always"
----

Tuesday, 16 October 2012

Build OAMP Server on OpenBSD from tarball

OAMP is stands for OpenBSD Apache MySQL and PHP.

In this blog, I'm trying to use the latest version on each software, however for PHP  I'll use 5.3.x instead of 5.4.x, since it has some issue make the PHP 5.4.x not able to be compiled on openBSD. I'll use the MySQL which comes comes from openBSD it self.

However, this tutorial will works on Linux machine as well.

1.First download all the tarball first.
#mkdir -p /usr/local/source
#cd /usr/local/source
#wget http://apache.mirror.rafal.ca//httpd/httpd-2.4.3.tar.gz
#wget http://www.php.net/get/php-5.3.17.tar.gz/from/a/mirror

2.Once it's done, untar both of the tarballs, by executing the command below:
#tar -xzvf httpd-2.4.3.tar.gz
#tar -xzvf php-5.3.17.tar.gz
#cd httpd-2.4.3
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-cgi --enable-info --enable-rewrite --enable-speling --enable-usertrack --enable-deflate --enable-ssl --enable-mime-magic
#make && make install
#cd ../php-5.3.17
#./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --prefix=/usr/local/apache2/php --with-config-file-path=/usr/local/apache2/php --enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext --with-gdbm --enable-zip --with-gettext --with-curl
#make && make install

3.Copy and edit the following file
#cp -p .libs/libphp5.so /usr/local/apache/modules
#cp -p php.ini-recommended /usr/local/apache/php/php.ini

vi /usr/local/apache2/conf/httpd.conf
---
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
DirectoryIndex index.html index.php
AddType text/html .php
---

4.Edit the following files
#cd /usr/sbin/
#mv apachectl{,.bakcup}
#mv httpd{,.bakcup}
#ln -s /usr/local/apache2/bin/apachectl /usr/sbin/apachectl
#ln -s /usr/local/apache2/httpd /usr/sbin/httpd

#vi /etc/rc.conf
---
...
httpd_flags=""
...
---

5. Test the apache configuration and run it.
#/etc/rc.d.d/apache configtest
#/etc/rc.d/apache restar

FreeBSD DESKTOP

I would assume the freeBSD installation already done. And you have one extra user account.

1. We need to upgrade the port
#portsnap upgrade
#portsnap extract

2. I would like to use bash and I like to use the latest bash. If you dont wish to use bash you can ignore step 2 and 3. Download it from here.
#mkdir -p /usr/local/source
#cd /usr/local/source
#fetch http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz
#tar -xzvf bash-4.2.tar.gz
#cd bash-4.2
#./configure
#make && make install clean

3.Set the shell become bash
#chsh -s /usr/local/bin/bash username
#chsh -s /usr/local/bin/bash root
#cd /bin
#mv bash{,.original}
#ln -s /usr/local/bin/bash bash => to replace the default bash with bash 4.2 if you already previous bash. you can ignore this part if you have a fresh installation.

4. set "su -" and sudo on the user account
#pkg_add sudo
#visudo
---
...
%wheel ALL=(ALL) NOPASSWD: ALL
...
---
#pw user mod username -G wheel

5.Installing Xserver, in here I would like to use GNOME as my desktop
#pkg_add -r xorg gnome2 => It will take a while for installation.
#vi /etc/fstab
---
...
proc    /proc    procfs    rw  0  0
...
---
#vi /etc/rc.conf
---
...
hald_enable=YES
dbus_enable=YES
gnome_enable=YES
gdm_enable=YES
...
---

6. Well done the GNOME packages and Xorg has been installed, what you need to do now, is by getting the VGA driver, in this case since I installed my freeBSD under VMWare workstation. You can ignore the vmmouse if you install in the normal machine.
#cd /usr/ports/x11-driver/xf86-video-vmware
#cd /usr/ports/x11-driver/xf86-input-vmmouse

7.Once its done just execute command reboot  and there you go welcome to GNOME2 desktop.

Note : when you do some installation through port sometimes there is some error not allowed you to upgrade to the latest version, so to do this. Follow the following command.
#csh
#setenv FORCE_PKG_REGISTER
#make install clean