Ruang Web Hosting Indonesia - Solusi Handal, Cepat dan Murah

Posts Tagged ‘Oracle’

Setting Roc@t-Remote Catalogue (Apache, Oracle InstantClient, PHP di RHEL5)

August 19, 2008 - 12:45 pm No Comments

Apa sih itu Roc@t

ROC@T merupakan produk dari PT. Sigma Cipta Utama (http://scu.co.id) dibuat untuk membantu Anda dalam pengelolaan pencarian dan peminjaman pada lokasi penyimpanan data katalog di perusahaan Anda agar lebih efisien dalam pencarian, pendistribusian dan pemeliharaannya. Hal ini memungkinkan untuk membuat index dari data yang disimpan pada banyak unit penyimpanan asset menjadi katalog yang secara sentral dikelola dari data fisik yang didistribusikan. Aplikasi ini juga termasuk sistem pemesanan. Sistem pemesanan adalah fasilitas yang membantu pengguna untuk memesan beberapa item dari catatan yang ditunjukkan pada laporan

Apa aja sih yang dibutuhkan :

  1. Web Server (Apache)

  2. Oracle Database atau InstantClient jika database Oraclenya terpisah

  3. PHP

Langkah Instalasi di sistem operasi RedHat Enterprise Linux 5

1. Compile Apache

Buka console/terminal untuk memulai installasi

Pindah ke direktori dimana file aplikasi disimpan

Ekstract file Apache dengan mengetikkan

tar -xvf httpd-[versi aplikasi].tar.gz

Pindah ke dalam folder aplikasi Apache dengan mengetikkan perintah

cd httpd-[versi aplikasi]/

Compile aplikasi dengan mengetikkan perintah

./configure –enable-so

make

make install

2. Install Oracle InstantClient

Buka console/terminal untuk memulai installasi

Pindah ke direktori dimana file aplikasi disimpan

Install aplikasi dengan mengetikkan perintah

rpm -ivh oracle-instantclient-basic-11.1.0.1-1.i386.rpm

PATH instantclient di : /usr/lib/oracle/11.1.0.1/client/

Set Environment Variables:

export LD_LIBRARY_PATH=/usr/lib/oracle/11.1.0.1/client/:$PATH

export ORACLE_HOME=/usr/lib/oracle/11.1.0.1/client/

export PATH=$ORACLE_HOME/bin:$PATH

tambah baris diatas ke /etc/rc.local sehingga variabel tetap efektif walaupun setelah reboot

3. Compile PHP

Buka console/terminal untuk memulai installasi

Pindah ke direktori dimana file aplikasi disimpan

Ekstract file PHP dengan mengetikkan

tar -xvf php-[versi aplikasi].tar.gz

Pindah ke dalam folder aplikasi PHP dengan mengetikkan perintah

cd php-[versi aplikasi]/

Compile aplikasi dengan mengetikkan perintah

./configure –with-apxs2=/usr/local/apache2/bin/apxs –enable-debug –with-zlib-dir=/usr/ local/lib –enable-dba –enable-dbase –with-regex –with-pear –with- oci8=instantclient,/usr/lib/oracle/11.1.0.1/client/lib/

make

make install

Jika Anda terhubung ke database Oracle Anda harus mendefinisikan service dalam file yang bernama tnsnames.ora. Buat file tnsnames.ora di direktori /etc/

Contoh tnsnames.ora :

ORCL =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))

)

(CONNECT_DATA =

(SID = ORCL)

(SERVER = DEDICATED)

)

)

Setting variabel TNS_ADMIN untuk mencari variabel tnsnames.ora :

export TNS_ADMIN=/etc/

dan tambah baris diatas pada /etc/rc.local
Done :)

Install Oracle Database 11g R1 di RHEL 5

August 16, 2008 - 4:53 am No Comments

Sumber :

http://www.oracle.com/technology/pub/articles/smiley-11gr1-install.html
http://www.sqlplex.com/articles/oracle/installation/installing-oracle-database-11g.html
http://rattyboy.wordpress.com/2008/07/09/encrypted-rsync-with-centos-5-rhel-5-fuse-sshfs-and-duplicity/
http://www.oracle-base.com/articles/linux/AutomatingDatabaseStartupAndShutdownOnLinux.php#the_rsh_command
http://ifrozi.wordpress.com/2008/05/

Setting Public Key
[root@rocat /]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
e9:44:24:20:dc:6a:1b:5e:6a:73:58:ca:5e:3e:35:fd root@testbox

Install Library yang dibutuhkan :
* elfutils-libelf-devel-0.125-3.el5
rpm -ivh elfutils-libelf-devel-0.125-3.el5.i386.rpm elfutils-libelf-devel-static-0.125-3.el5.i386.rpm
* compat-libstdc++-33-3.2.3-61
* elfutils-libelf-0.125-3.el5
* glibc-2.5-12
* glibc-devel-2.5-12
* glibc-common-2.5-12
* gcc-4.1.1-52.el5
* gcc-c++-4.1.1-52.el5
* libgcc-4.1.1-52.el5
* libaio-0.3.106-3.2
* libaio-devel-0.3.106-3.2
* libstdc++-4.1.1-52.el5
* libstdc++-devel-4.1.1-52.el5
* unixODBC-2.2.11-7.1
* unixODBC-devel-2.2.11-7.1
* sysstat-7.0.0-3.el5
* binutils-2.17.50.0.6-2.el5
* make-3.81-1.1

Setting User dan Group :
[root@rocat /]# /usr/sbin/groupadd oinstall
[root@rocat /]# /usr/sbin/groupadd dba
[root@rocat /]# /usr/sbin/useradd -m -g oinstall -G dba oracle
[root@rocat /]# passwd oracle

Pembuatan direktori dan hak akses :
[root@rocat /]# mkdir -p /u01/app/oracle
[root@rocat /]# chown -R oracle:oinstall /u01/app
[root@rocat /]# chmod -R 775 /u01/app

Setting Kernel :
[root@rocat /]# cat >> /etc/sysctl.conf <<EOF
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
> kernel.shmmni = 4096
> kernel.sem = 250 32000 100 128
> fs.file-max = 65536
> net.ipv4.ip_local_port_range = 1024 65000
> net.core.rmem_default=4194304
> net.core.wmem_default=262144
> net.core.rmem_max=4194304
> net.core.wmem_max=262144
> EOF

[root@rocat /]# /sbin/sysctl -p

Minimum Kernel
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=4194304
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=262144

Install Oracle :

* Login sebagai User oracle

* [root@rocat /]# ./runInstaller

Start Oracle automatically :

Setting oratab
/etc/oratab : SID:ORACLE_HOME:Y

Setting /etc/init.d/dbora
#########################################################
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

#ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_HOME=/u01/app/oracle/product/11.1.0/db_1
ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo “Oracle startup: cannot start”
exit
fi

case “$1″ in
’start’)
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c “$ORA_HOME/bin/dbstart $ORA_HOME”
;;
’stop’)
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c “$ORA_HOME/bin/dbshut $ORA_HOME”
;;
esac

#########################################################

[root@rocat /]# chmod 750 /etc/init.d/dbora
[root@rocat /]# chkconfig –level 345 dbora on

Start Oracle
[root@rocat /]# $ORACLE_HOME/bin/lsnrctl start
[root@rocat /]# $ORACLE_HOME/bin/dbstart

Kalau masih masalah, tambahkan aja skrip dibawah ke /etc/rc.local
/etc/rc.local
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1/
$ORACLE_HOME/bin/lsnrctl start
/etc/init.d/dbora start

Oracle DBMS_SCHEDULER

May 7, 2008 - 2:12 pm No Comments

Paket DBMS_SCHEDULER menyediakan koleksi fungsi dan prosedur penjadualan yang dapat dipanggil dari program PL/SQL.

#DBMS_SCHEDULER

BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB
(
job_name        => ‘COMPILE_SCHEMA_SCOTT’
,start_date      => SYSDATE
,repeat_interval => ‘FREQ=DAILY;BYHOUR=7;BYMINUTE=0;BYSECOND=0′
,end_date        => NULL
,job_class       => ‘DEFAULT_JOB_CLASS’
,job_type        => ‘PLSQL_BLOCK’
,job_action      => ‘begin
dbms_utility.compile_schema(”SCOTT”);
end;’
,comments        => ‘Compile schema scott’
);

SYS.DBMS_SCHEDULER.ENABLE
(name                  => ‘COMPILE_SCHEMA_SCOTT’);

END;
/

Export, Archiving, Delete Older file Oracle Database automaticly using Linux Script and Crontab

April 21, 2008 - 6:24 am 3 Comments

This is script that export Oracle Database, archive it automatically and delete archive automatically where archive older than 20 day

####################
# Oracle Backup            #
# Bayu Kurniawan R       #
# 17 April 2008             #
####################

# Buat environment
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
ORACLE_HOME=/opt/oracle/product/9ir2/
ORACLE_BASE=/opt/oracle
ORACLE_SID=orcl
export ORACLE_HOME ORACLE_BASE ORACLE_SID
PATH=$PATH:$HOME/bin:$ORACLE_HOME:$ORACLE_HOME/bin

# File naming : year.month.day
tanggal=$(date +%y%m%d)

# Path to save file
dir=/home/bayu

# Daily Backup DB Oracle
echo Exporting DB Oracle ….
su - oracle -c “exp user/password@orcl file=$dir/file_$tanggal.dmp log=$dir/file_$tanggal.log”

echo Archiving Oracle Backup…
tar -zcf $dir/file_$tanggal.tar.gz $dir/file_$tanggal.dmp $dir/file_$tanggal.log

echo Removing Oracle .dmp and .log…
rm $dir/file_$tanggal.dmp $dir/file_$tanggal.log

echo Removing Dump Oracle which older than 20 day…
find /home/bayu -name file*tar.gz -mtime +20 -exec rm -f {} \

# End #

Save it as backup.sh

Edit the Crontab
crontab -e

Add following line

0 22 * * * /opt/oracle/product/9ir2/bin/backup.sh

This script will execute backup.sh everyday at 22.00

Mapserver dengan menggunakan data Oracle Spatial

April 18, 2008 - 3:21 pm 4 Comments

Konversi data ESRI Shapefile (.shp) ke Oracle Spatial

D:\BAYU\data\fix\shp>shp2sdo

shp2sdo - Shapefile(r) To Oracle Spatial Converter

Version 2.13 24-Apr-2002

Copyright 1997,1998,1999,2000,2001,2002 Oracle Corporation

For use with Oracle Spatial.

Input shapefile (no extension): kecamatan

Shape file kecamatan.shp contains 1555 polygons

Output table [kecamatan]:

Output data model [O]:

Geometry column [GEOM]:

ID column []: id

Starting number [1]:

Use a spatial reference system ID (SRID) ? [N]: y

Please enter an SRID value: 4326

Change tolerance value from the default (0.00000005) ? [N]:

Generate data inside control files ? [N]:

Target database Oracle8i? [N]:

Spatial Data requires more than 6 digits precision? [N]:

Bounds: X=[108.594556,114.556928] Y=[-8.776988,-6.398623]

Override ? [N]:

Processing shapefile kecamatan into spatial table KECAMATAN

Data model is object-relational

Geometry column is GEOM

Id column is ID

Numbered from 1

Points stored in SDO_POINT attributes

Data is in a separate file(s)

Control file generation for Oracle9i or higher

Spatial data loaded with 6 digits of precision

SRID set to 4326

Conversion complete : 1555 polygons processed

The following files have been created:

kecamatan.sql : SQL script to create the table

kecamatan.ctl : Control file for loading the table

kecamatan.dat : Data file

Buat table di Oracle dari hasil konversi (.sql)

– kecamatan.sql

– This script creates the spatial table.

– Execute this script before attempting to use SQL*Loader

– to load the kecamatan.ctl file.

– This script will also populate the USER_SDO_GEOM_METADATA table.

– Loading the .ctl file will populate the KECAMATAN table.

– To load the .ctl file, run SQL*Loader

– with these parameters:

– USERID=username/password CONTROL=kecamatan.ctl

– After the data is loaded in the KECAMATAN table, you should

– tune the dataset and create the spatial index

– Creation Date : Sat Dec 22 18:09:02 2007

– Copyright 1999, 2000, 2001, 2002 Oracle Corporation

– All rights reserved

DROP TABLE KECAMATAN;

CREATE TABLE KECAMATAN (

ID NUMBER(38)

PRIMARY KEY,

KECAMATAN VARCHAR2(50),

DISTRICT VARCHAR2(50),

PROVINCE VARCHAR2(50),

J_RW VARCHAR2(2),

J_RT VARCHAR2(3),

J_KK NUMBER,

J_LAKI2 NUMBER,

J_PEREM NUMBER,

P_BBM VARCHAR2(7),

K_LOGAM NUMBER,

K_GERABAH NUMBER,

MAKANAN NUMBER,

KEDAI NUMBER,

SMB_PENGHA VARCHAR2(15),

LETAKGEOGR VARCHAR2(13),

KELOMPOK NUMBER,

KODE_KECAM NUMBER,

KODE_KABUP NUMBER,

KODE_PROPI NUMBER,

GEOM MDSYS.SDO_GEOMETRY);

DELETE FROM USER_SDO_GEOM_METADATA

WHERE TABLE_NAME = ‘KECAMATAN’ AND COLUMN_NAME = ‘GEOM’ ;

INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)

VALUES (’KECAMATAN’, ‘GEOM’,

MDSYS.SDO_DIM_ARRAY

(MDSYS.SDO_DIM_ELEMENT(’X’, 108.594555840, 114.556928040, 0.000000050),

MDSYS.SDO_DIM_ELEMENT(’Y’, -8.776988010, -6.398622990, 0.000000050)

),4326

);

COMMIT;

Insert data menggunakan sql loader

D:\BAYU\data\fix\shp>sqlldr user/password

control = kecamatan

SQL*Loader: Release 10.2.0.1.0 - Production on Sat Dec 22 18:10:44 2007

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

Commit point reached - logical record count 41

Commit point reached - logical record count 82

Commit point reached - logical record count 123

Commit point reached - logical record count 164

Commit point reached - logical record count 205

Commit point reached - logical record count 246

Commit point reached - logical record count 287

Commit point reached - logical record count 328

Commit point reached - logical record count 369

Commit point reached - logical record count 410

Commit point reached - logical record count 451

Commit point reached - logical record count 492

Commit point reached - logical record count 533

Commit point reached - logical record count 574

Commit point reached - logical record count 615

Commit point reached - logical record count 656

Commit point reached - logical record count 697

Commit point reached - logical record count 738

Commit point reached - logical record count 779

Commit point reached - logical record count 820

Commit point reached - logical record count 861

Commit point reached - logical record count 875

Commit point reached - logical record count 916

Commit point reached - logical record count 957

Commit point reached - logical record count 998

Commit point reached - logical record count 1039

Commit point reached - logical record count 1080

Commit point reached - logical record count 1121

Commit point reached - logical record count 1162

Commit point reached - logical record count 1165

Commit point reached - logical record count 1206

Commit point reached - logical record count 1247

Commit point reached - logical record count 1288

Commit point reached - logical record count 1329

Commit point reached - logical record count 1370

Commit point reached - logical record count 1411

Commit point reached - logical record count 1452

Commit point reached - logical record count 1493

Commit point reached - logical record count 1534

Commit point reached - logical record count 1554

Commit point reached - logical record count 1555

Copy libmap.dll dari D:\ms4w\Apache\cgi-bin\ignored-libmap\oracle10g\ ke D:\ms4w\Apache\cgi-bin

Edit httpd.conf, tambahkan baris

SetEnv TNS_ADMIN “D:/oracle/product/10.2.0/client_2/NETWORK/ADMIN/”

Folder where the tnsnames.ora exist

SetEnv PATH “D:/oracle/product/10.2.0/client_2/BIN/”

SetEnv ORACLE_HOME “D:/oracle/product/10.2.0/client_2?

Pada mapfile :

CONNECTIONTYPE oraclespatial

CONNECTION “username/password@service”

DATA “GEOM FROM (SELECT ID, KECAMATAN, DISTRICT, PROVINCE, GEOM FROM KECAMATAN) USING UNIQUE ID SRID 4326?

Kalo pake OGR, koneksinya ya begini :

CONNECTIONTYPE OGR

CONNECTION “OCI:username/password@service”

DATA “tablename”

Jadi deh….