2008年10月9日星期四

Archlinux 上安装 Oracle 10g

Archlinux 上安装 Oracle 10g

环境:
Archlinux 2.6.26-ARCH
Oracle Database 10.2.01

Section I 准备工作

##### 创建oracle用户和组
sudo groupadd oinstall
sudo groupadd dba
sudo useradd -m -g oinstall -G dba oracle

id oracle
uid=1004(oracle) gid=1004(oinstall) groups=1004(oinstall),1005(dba)

#host_id
确认你的 /etc/hosts 里面有 hostname 的解析。

# 设置 oracle 帐户的口令:
passwd oracle

##### 创建目录
sudo mkdir /u01/oracle/base
sudo mkdir /u01/oracle/home
sudo chown oracle:dba /u01/oracle -fR
sudo chmod 775 /u01/oracle -fR

##### 配置环境变量

# /home/oracle/.bash_profile
export ORACLE_BASE=/u01/oracle/base
export ORACLE_HOME=/u01/oracle/home
export ORACLE_SID=TEST
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:/usr/sbin:$ORACLE_HOME/bin

export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$CLASSPATH:$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export THREADS_FLAG=native


##### 准备所需的库

到一下地址下载libaio-0.3.106.tar.gz
#http://packages.gentoo.org/packages/?category=dev-libs;name=libaio
#http://download.chinaunix.net/download/0006000/5732.shtml

tar -xvzf libaio-0.3.106.tar.gz
cd libaio-0.3.106
make prefix=`pwd`/usr install

sudo ln -s /usr/lib/libstdc++.so.6.0.3 /usr/lib/libstdc++.so.5
sudo ln -s /usr/lib/libgcc_s.so.1 /lib/libgcc_s.so.1
cd /usr/bin
sudo ln -s ../../bin/awk awk
sudo ln -s ../../bin/tr tr


##### 配置 Linux 内核参数

# /etc/sysctl.conf
kernel.shmall = 2097152
kernel.shmmax = 2147483648
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=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
## execute /sbin/sysctl -p

#/etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

#/etc/pam.d/login
session required /lib/security/pam_limits.so




##### 修改 Archlinux 的版本以“ 欺骗” Oracle安装程序,使之能正常安装。
sudo echo Red Hat Enterprise Linux AS rlease 3 (Taroon) > /etc/redhat-release




Section II 安装

###### 下载Oracle Database 10g
http://www.oracle.com/technology/software/products/database/index.html

Oracle Database 10g Release 2
Standard Edition, Standard Edition One, and Enterprise Edition
Oracle Database 10g Release 2 (10.2.0.1.0) for Linux x86

http://download.oracle.com/otn/linux/oracle10g/10201/10201_database_linux32.zip

10201_database_linux32.zip

很奇怪这是个zip文件,不过可以把ark把它打开,解压到/tmp下, 注意,/tmp 重启后会被清理,安装过程中不要重启计算机。

##### 切换到oracle用户
su - oracle

#####
export LANG=C
/tmp/database/runInstaller

用英文界面安装,如果想要配置中文,请google 一下java 1.4的中文问题.


##### oracle 安装到29%时,
vi $ORACLE_HOME/bin/gennttab


# Change this...
LIB=`$ECHO ${TtoLIB} | $SED 's/ /\\
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
INI=`$ECHO ${TtoINI} | $SED 's/ /\\
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
BAS=`$ECHO ${TtoBAS} | $SED 's/ /\\
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`


# To this...
LIB=`$ECHO ${TtoLIB} | $SED 's/ /\n/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
INI=`$ECHO ${TtoINI} | $SED 's/ /\n/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
BAS=`$ECHO ${TtoBAS} | $SED 's/ /\n/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`

主要把回车删除,把一个/换成n

###### 安装选项
按照自己的需求吧,可以参考这篇文章
http://www.souzz.net/html/database/ORACLE/12246.html


###### 错误处理
http://hi.baidu.com/edeed/blog/item/18cf87d6294cc72c07088b1f.html


Section III 调试

##### 配置文件
sudo vi /etc/hosts
xxx.xxx.xxx.xxx(本机IP) oracle-server

#listener.ora @ $ORACLE_HOME/network/admin

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/home)
(PROGRAM = extproc)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC2))
(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE-SERVER)(PORT = 1521))
)
)

#tnsnames.ora @ $ORACLE_HOME/network/admin

LISTENER_TEST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE-SERVER)(PORT = 1521))


TEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE-SERVER)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TEST)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC2))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)


#


##### startup
$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Oct 10 11:08:33 2008

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

Enter user-name: / as sysdba
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 83887720 bytes
Database Buffers 192937984 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.

SQL>shutdown
Database closed.
Database dismounted.


ORACLE instance shut down.
SQL>


##### 用脚本启动

#dbstart @ $ORACLE_HOME/bin
#change
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
#to
ORACLE_HOME_LISTNER=$ORACLE_HOME

#允许用dbstart 启动
#oratab @ /etc
#change
TEST:/media/udata/oracle/home:N
#to
TEST:/media/udata/oracle/home:Y

#启动
$ORACLE_HOME/bin/dbstart
Processing Database instance "TEST": log file /media/udata/oracle/home/startup.log

#检验
sudo netstat -a |grep 1521
密码:
tcp 0 0 ORACLE-SERVER:1521 *:* LISTEN
tcp 104 0 ORACLE-SERVER:1521 ORACLE-SERVER:20328 ESTABLISHED
tcp 0 0 ORACLE-SERVER:20328 ORACLE-SERVER:1521 ESTABLISHED


#关闭
$ORACLE_HOME/bin/dbshut
lsnrctl stop #关闭侦听器


参考文档:
http://hi.baidu.com/sneeze/blog/item/4e0db0777f29c51bb051b9d8.html
http://www.blogger.com/post-create.g?blogID=3560048731273076746

没有评论: