Wednesday, April 21, 2010

Install ruby-oci8 on Ubuntu

gzip -dc ruby-oci8-2.0.4.tar.gz | tar xvf -
cd ruby-oci8-2.0.4
make
make install

* When I issue command: sudo make install

luan@luan-laptop:/opt/download/ruby-oci8-2.0.4$ sudo make install
ruby -w setup.rb install
make: ruby: Command not found
make: *** [install] Error 127
luan@luan-laptop:/opt/download/ruby-oci8-2.0.4$ ruby -w setup.rb install
---> lib
mkdir -p /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/
install oci8.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/
Permission denied - /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8.rb
Try 'ruby setup.rb --help' for detailed usage.
luan@luan-laptop:/opt/download/ruby-oci8-2.0.4$ sudo ruby -w setup.rb install
sudo: ruby: command not found
luan@luan-laptop:/opt/download/ruby-oci8-2.0.4$ sudo /opt/ruby/bin/ruby -w setup.rb install
---> lib
mkdir -p /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/
install oci8.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/
---> lib/dbd
mkdir -p /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/dbd
install OCI8.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/dbd
<--- lib/dbd
---> lib/oci8
mkdir -p /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install oci8.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install encoding.yml /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install encoding-init.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install object.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install bindtype.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install datetime.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install metadata.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install compat.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
install oracle_version.rb /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/oci8
<--- lib/oci8
<--- lib
---> ext
---> ext/oci8
mkdir -p /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/x86_64-linux/.
install oci8lib_191.so /opt/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/x86_64-linux/.
<--- ext/oci8
<--- ext

----------------------------------------------------------------------------------


I can't install ruby-oci8 on Ubuntu 104 using:

sudo gem install ruby-oci8

luan@luan-laptop:~/app/software/ruby/dev$ sudo /opt/ruby/bin/gem install ruby-oci8
[sudo] password for luan:
Building native extensions. This could take a while...
ERROR: Error installing ruby-oci8:
ERROR: Failed to build gem native extension.

/opt/ruby-1.9.1-p376/bin/ruby extconf.rb
checking for load library path...
LD_LIBRARY_PATH is not set.
checking ld.so.conf... no
checking for cc... ok
checking for gcc... yes
checking for LP64... yes
checking for ruby header... ok
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/ruby-1.9.1-p376/bin/ruby
--with-instant-client
--without-instant-client
/opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:895:in `get_home': RuntimeError (RuntimeError)
from /opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:682:in `initialize'
from /opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:345:in `new'
from /opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:345:in `get'
from extconf.rb:18:in `
'
---------------------------------------------------
Error Message:
Set the environment variable ORACLE_HOME if Oracle Full Client.
Append the path of Oracle client libraries to LD_LIBRARY_PATH if Oracle Instant Client.

The 'sudo' command unset some environment variables for security reasons.
Pass required varialbes as follows
sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH /opt/ruby/bin/gem install ruby-oci8
or
sudo env ORACLE_HOME=$ORACLE_HOME /opt/ruby/bin/gem install ruby-oci8

Backtrace:
/opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:895:in `get_home'
/opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:682:in `initialize'
/opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:345:in `new'
/opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/oraconf.rb:345:in `get'
extconf.rb:18:in `
'
---------------------------------------------------
See:
* http://ruby-oci8.rubyforge.org/en/HowToInstall.html
* http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html



Gem files will remain installed in /opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4 for inspection.
Results logged to /opt/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.4/ext/oci8/gem_make.out

Tuesday, April 20, 2010

Install Oracle 11g R2 on Ubuntu 10.4

I follow the steps from
http://www.pythian.com/news/1355/installing-oracle-11gr1-on-ubuntu-810-intrepid-ibex/

I have to make some adjustments for my Ubuntu 10.4 64 bits, so here are steps:

luan@luan-laptop:~$ sudo su -
[sudo] password for luan:
root@luan-laptop:~# apt-get install gcc make binutils gawk x11-utils rpm alien ksh lsb-rpm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
(... long list ...)
Suggested packages:
(... another long list ...)
The following NEW packages will be installed:
(... even longer list ...)
0 upgraded, 54 newly installed, 0 to remove and 0 not upgraded.
Need to get 29.3MB of archives.
After this operation, 93.0MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://us.archive.ubuntu.com lucid/main gawk 1:3.1.6.dfsg-0ubuntu1 [500kB]
Get:2 http://us.archive.ubuntu.com lucid/main libdrm2 2.3.1-0build1 [260kB]
(...)
Setting up build-essential (11.4) ...
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
root@luan-laptop:~#

root@luan-laptop:~# apt-get install libaio1 lesstif2 libmotif3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libxp6
The following NEW packages will be installed:
lesstif2 libaio1 libmotif3 libxp6
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 1941kB of archives.
After this operation, 4772kB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://us.archive.ubuntu.com lucid/main libxp6 1:1.0.0.xsf1-2 [16.7kB]
Get:2 http://us.archive.ubuntu.com licid/multiverse libmotif3 2.2.3-2 [1283kB]

root@luan-laptop:~# cd /bin
root@luan-laptop:/bin# ls -l /bin/sh

lrwxrwxrwx 1 root root 4 2010-20-04 21:33 /bin/sh -> dash
root@luan-laptop:/bin# ln -sf /bin/bash /bin/sh
root@luan-laptop:/bin# ls -l /bin/sh

lrwxrwxrwx 1 root root 4 2010-20-04 22:34 /bin/sh -> bash
root@luan-laptop:/bin#
Now create some users:

root@luan-laptop:/bin# cd
root@luan-laptop:~# pwd

/root
root@luan-laptop:~# addgroup oinstall
Adding group `oinstall' (GID 1001) ...
Done.
root@luan-laptop:~# addgroup dba
Adding group `dba' (GID 1002) ...
Done.
root@luan-laptop:~# addgroup nobody
Adding group `nobody' (GID 1003) ...
Done.
root@luan-laptop:~# usermod -g nobody nobody
root@luan-laptop:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
root@luan-laptop:~# mkdir /home/oracle
root@luan-laptop:~# chown -R oracle:dba /home/oracle
root@luan-laptop:~# ln -s /usr/bin/awk /bin/awk
root@luan-laptop:~# ln -s /usr/bin/rpm /bin/rpm
root@luan-laptop:~# ln -s /usr/bin/basename /bin/basename
root@luan-laptop:~# mkdir /etc/rc.d
root@luan-laptop:~# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
root@luan-laptop:~# mkdir -p /u01/app/oracle
root@luan-laptop:~# chown -R oracle:dba /u01
root@luan-laptop:~#

Copy the unpacked Oracle 11gR1 to the box we’re working on:


luan@luan-laptop:~$ sudo su -
root@luan-laptop:~# mv /home/download/database /media/database
root@luan-laptop:~# chown -R oracle:oinstall /media/database
root@luan-laptop:~#

Now change some system-wide configuration files, starting with /etc/sysctl.conf:

root@luan-laptop:~# cd /etc
root@luan-laptop:/etc# cp sysctl.conf sysctl.conf.original

Edit it, adding the following lines to the bottom of the file:

fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
Then, let’s modify /etc/security/limits.conf:

root@luan-laptop:/etc# cd /etc/security/
root@luan-laptop:/etc/security# cp limits.conf limits.conf.original

Add the following lines to the bottom of the file:

oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
The last one, for now, is /etc/pam.d/login:

root@luan-laptop:/etc/security# cd /etc/pam.d
root@luan-laptop:/etc/pam.d# cp login login.original

Edit login, adding to it:

session required /lib/security/pam_limits.so
session required pam_limits.so

Here is how to get display working on my laptop.

oracle@luan-laptop:~$ exit
logout
root@luan-laptop:~# DISPLAY=:0; export DISPLAY; xhost +;
access control disabled, clients can connect from any host
root@luan-laptop:~# su - oracle
oracle@luan-laptop:~$ DISPLAY=:0 ; export DISPLAY
oracle@luan-laptop:~$ xclock
oracle@luan-laptop:~$


oracle@luan-laptop:~$ cd /media/database
oracle@luan-laptop:/media/database$ ./runInstaller -ignoreSysPrereqs


Now the windows installation screen will appear. You should be able to follow the default installation.

....

This is a startup script:

root@luan-laptop:/# cat /etc/init.d/oracledb
#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin

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

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: `basename $0` start|stop|restart|reload"
exit 1
esac

exit 0
root@luan-laptop:/#


root@luan-laptop:/# chmod a+x /etc/init.d/oracledb
root@luan-laptop:/# update-rc.d oracledb defaults 99

update-rc.d: warning: /etc/init.d/oracledb missing LSB information
update-rc.d: see
Adding system startup for /etc/init.d/oracledb ...
/etc/rc0.d/K99oracledb -> ../init.d/oracledb
/etc/rc1.d/K99oracledb -> ../init.d/oracledb
/etc/rc6.d/K99oracledb -> ../init.d/oracledb
/etc/rc2.d/S99oracledb -> ../init.d/oracledb
/etc/rc3.d/S99oracledb -> ../init.d/oracledb
/etc/rc4.d/S99oracledb -> ../init.d/oracledb
/etc/rc5.d/S99oracledb -> ../init.d/oracledb


To startup database:


oracle@luan-laptop:~$ . oraenv
ORACLE_SID = [oracle] ? testdb

The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
oracle@luan-laptop:~$
oracle@luan-laptop:~$
oracle@luan-laptop:~$ sqlplus '/as sysdba'


SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 21 09:39:17 2010

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1269366784 bytes
Fixed Size 2212976 bytes
Variable Size 822086544 bytes
Database Buffers 436207616 bytes
Redo Buffers 8859648 bytes
SQL> alter database mount;

Database altered.

SQL> alter database open;

Database altered.

SQL>

------

How to start Oracle Enterprise Manager


oracle@luan-laptop:~$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
https://luan-laptop:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ............. started.
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/luan-laptop_testdb/sysman/log
oracle@luan-laptop:~$

Monday, April 19, 2010

Install sys-proctable in Ubuntu 10.04 64 bits

luan@luan-laptop:~$ sudo /opt/ruby/bin/gem install sys-proctable --platform x86-64-linux
Successfully installed sys-proctable-0.9.0-x86-linux
1 gem installed
Installing ri documentation for sys-proctable-0.9.0-x86-linux...
Updating class cache with 3248 classes...
Installing RDoc documentation for sys-proctable-0.9.0-x86-linux...