一.一些簡單知識:
1)
命令
操作系統型號
# cat /etc/issue
內核型號
# uname -r
查詢安裝包
# rpm -q package_name
二:安裝前準備:
1)
環境
內存
2048M
,硬盤
146G
2)
分區
/ 30G
/tmp 2G
/var 3G
/app 20G
/app/oradata 60G
/app/oraBP 20G
3
)修改配置文件/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 = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
重新啟動
4
)安裝必須的編譯安裝包
# yum -y install setarch-2*
# yum -y install make-3*
# yum -y install glibc-2*
# yum -y install libaio-0*
# yum -y install compat-libstdc++-33-3*
# yum -y install compat-gcc-34-3*
# yum -y install compat-gcc-34-c++-3*
# yum -y install gcc-4*
# yum -y install libXp-1*
# yum -y install openmotif-2*
# yum -y install compat-db-4*
5)
增加Oracle用戶及設置oracle用戶的shell
a)
建立oracle用戶及組
# groupadd oinstall
# groupadd dba
# groupadd oper
# useradd -g oinstall -G dba oracle
# passwd oracle
?
b)
增加如下行到/etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
c)
增加下列行到/etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
d)
修改Shell默認啟動文件
Bourne,Bash,Korm shell
下增加下列行到
/etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
e)
修改ORACLE環境變量
# su - oracle
$ vi .bash_profile
export TMP=/tmp;
export TMPDIR=$TMP;
export ORACLE_BASE=/home/oracle;
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;
?export ORACLE_SID=orcl;
export ?ORACLE_TERM=xterm;
export PATH=/usr/sbin:$PATH;
export ?PATH=$ORACLE_HOME/bin:$PATH;
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
?
5)
創建需要的目錄
mkdir /app/oracle
chown -R oracle:oinstall /app/oracle
chmod -R 775 /app/oracle
chown -R oracle:oinstall /app/oradata
chmod -R 775 /app/oradata
chown -R oracle:oinstall /app/orabp
chmod -R 775 /app/orabp
這里只有一塊硬盤,如果有多塊硬盤,你需要將其建立一個掛接點,如
u01,
則目錄為
/u01/app/oracle
,這里只有一個硬盤,掛接點就是
/
6)
設置oracle用戶環境
a)
如果在遠程系統上安裝
oracle,
在本地的
X-Windows
里顯示,要設置
xhost host_name
b)
用
oracle
登陸
X-windows
系統
,
或
su - oracle
c)
查看默認
Shell
echo $SHELL
d)bash
vi .bash_profile
如果設置了
ORACLE_SID,ORACLE_HOME,ORACLE_BASE,
刪除相應行
e)umask 022
f)
保存文件,執行
. .bash_profile
g)
設置顯示變量
DISPLAY=localhost:0.0 ; export DISPLAY
如果在遠程顯示界面,
localhost
就改成遠程主機
h)
如果
/tmp
空間不夠,需要設置
TMP,TMPDIR
變量
$ su - root
# mkdir /mount_point/tmp
# chmod a+wr /mount_point/tmp
# exit
bash
下
$ TMP=/mount_point/tmp
$ TMPDIR=/mount_point/tmp
$ export TMP TMPDIR
i)
確定
ORACLE_HOME,TNS_ADMIN
沒有設置
$ unset ORACLE_HOME
$ unset TNS_ADMIN
j)
檢驗是否設置正確
$ umask
$ env | more
7)
安裝Oracle
a)
取得
Oracle
安裝件
從
Oracle
網站上下載,是免費的,只需要一個簡單的注冊即可,得到的是
zip
文件
unzip 10201_database_linux32.zip
如果是安裝光盤,
mount
上介質
b)
運行
runInstaller
c)
安裝過程和
Windows
非常類似,要注意的是
在選擇
dba
組的時候選擇
oinstall
安裝之前程序會檢查一下系統配置,如果按照上面的設置,不會有任何問題,
install
即可
這樣安裝的
oracle
的數據文件在默認目錄下,如果要放到不同的盤上,
可以刪除數據庫重建,或者安裝的時候選擇高級安裝
安裝
Net 8
時,系統提示以
root
用戶執行兩個腳本,照做就可以了
8
)收尾,設置環境變量
1)
注意
ORACLE_HOME
變量,如果不存在,需要手工設置
ORACLE_HOME=/app/oracle/product/10.2.0/db_1
2)
建庫命令為
/app/oracle/product/10.2.0/db_1/bin/dbca &
注意設置字符集,因為安裝界面用中文沒法安裝,所以使用英文環境安裝,
所以不能使用默認配置,要修改默認字符集及默認語言
3)Net 8
命令為
/app/oracle/product/10.2.0/db_1/bin/netca &
4)
在其它機器上遠程用
Net8
連接
Oracle,
需要打開
Linux
上的
1521
端口
配置如下
Applications->System Setting->Secuity Level
其它端口增加
1521:tcp
即可
5)
讓
oracle
隨機器啟動而啟動
在
.bash_profile
里設置
ORACLE_SID=orcl
ORACLE_HOME=/app/oracle/product/10.2.0/db_1
export ORACLE_SID
export ORACLE_HOME
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
修改
/etc/oratab,
orcl:/app/oracle/product/10.2.0/db_1:Y
最后一個字母默認是
N
,修改為
Y
,否則
dbstart,dbshut
都不會起作用
修改
/app/oracle/product/10.2.0/db_1/dbstart
中的相關行為
ORACLE_HOME_LISTNER=/app/oracle/product/10.2.0/db_1
然后修改
/etc/rc.local,
增加這樣的一行
su - oracle -c dbstart
這樣就可以了,但不能關機的時候自動關閉,所以需要手工處理
su - oracle -c dbshut
如果是
oracle
用戶可以直接
dbshut
注:我曾經嘗試過網上找到的如下方法,但系統沒法啟動,需要用恢復模式刪掉腳本才可以,
不知道是不是我的配置問題,如果看出我的錯誤請告訴我
開機時讓
RedHat Linux
自動啟動
Oracle
,需要完成以下步驟:
運行
$ORACLE_HOME
下的
root.sh
,會生成一個文件
/etc/oratab
。
編輯
/etc/oratab
,把所有的
instance
的重啟動標志設置成
'Y'
,如
:
ora10g:/home/oracle/OraHome_1:Y
做一個啟動腳本
/etc/init.d/dbora
,如下所示
:
#!/bin/sh
# description: Oracle auto start-stop script.
# chkconfig: - 20 80
#
# 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=/app/oracle/product/10.2.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
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
;;
'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/lsnrctl stop"
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
;;
'restart')
$0 stop
$0 start
;;
esac
?
賦予執行權限
chmod 750 /etc/init.d/dbora
作成以下鏈接
:
ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
執行以下命令
:
chkconfig --level 345 dbora on
?
修改操作系統版本標識
# vi /etc/redhat-release
#CentOS release 5.2 (Final)
redhat-4
?
安裝oracle數據庫
# su - oracle
$ export DISPLAY=192.168.1.3:0.0
$ /home/oracle/database/runInstaller
*
為客戶機IP地址,xp下使用Xmanager 2.0連接遠程服務器的桌面
1. Select Installation Method
選擇
Advanced Installation
2. Specify Inventory Directory and Credentials
3. Select Installation Type
選擇
Enterprise Edition
4. Specify Home Details
Name文本框中填寫
db_1
5. Product-Specific Prerequisite Checks
6. Select Configuration Option
選擇
create a database
7. Select Database Configuration
選擇
General Purpose
8. Specify Database Configuration Options
選擇
Select Database character set : UTF-8
9. Select Database Management Option
選擇
Use Database Control Database Management
10. Specify Database Storage Option
選擇
File System
11. Specify Backup and Recovery Options
選擇
Do not enable Automated backups
12. Specify Database Schema Passwords
選擇
Use the same password for all the accounts
13. Summary
14. Install
15. Configuration Assistants
16. Database Configuration Assistant
17. Database Configuration Assistant Password Management
選擇Password Management,除system以外全部鎖定
18. Execute Configuration Scripts
在root環境中執行
# /home/oracle/oraInventory/orainstRoot.sh
# /home/oracle/product/10.2.0/db_1/root.sh
19. End Of Installation
恢復操作系統版本
# vi /etc/redhat-release
CentOS release 5.2 (Final)
設置數據庫開機自動啟動
# /etc/oratab
orcl:/home/oracle/product/10.2.0/db_1:Y
# vi /etc/rc.local
su - oracle -c ‘dbstart’
# su - oracle
$ vi /home/oracle/product/10.2.0/db_1/bin/dbstart
第78行修改為
ORACLE_HOME_LISTNER=$ORACLE_HOME/
數據庫相關命令
$ dbstart [ start | status | stop ]
$ lsnrctl [ start | status | stop ]
$ emctl [ start | status | stop ] console
$ sqlplus /nolog
>connect system/passwd as sysdba
DBCA - Database Configuration Assistant
$ dbca
啟動EM
http://localhost:1158/em/
?