一.一些簡(jiǎn)單知識(shí):
1)
命令
操作系統(tǒng)型號(hào)
# cat /etc/issue
內(nèi)核型號(hào)
# uname -r
查詢安裝包
# rpm -q package_name
二:安裝前準(zhǔn)備:
1)
環(huán)境
內(nèi)存
2048M
,硬盤
146G
2)
分區(qū)
/ 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
重新啟動(dòng)
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用戶及設(shè)置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默認(rèn)啟動(dòng)文件
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環(huán)境變量
# 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)
創(chuàng)建需要的目錄
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
這里只有一塊硬盤,如果有多塊硬盤,你需要將其建立一個(gè)掛接點(diǎn),如
u01,
則目錄為
/u01/app/oracle
,這里只有一個(gè)硬盤,掛接點(diǎn)就是
/
6)
設(shè)置oracle用戶環(huán)境
a)
如果在遠(yuǎn)程系統(tǒng)上安裝
oracle,
在本地的
X-Windows
里顯示,要設(shè)置
xhost host_name
b)
用
oracle
登陸
X-windows
系統(tǒng)
,
或
su - oracle
c)
查看默認(rèn)
Shell
echo $SHELL
d)bash
vi .bash_profile
如果設(shè)置了
ORACLE_SID,ORACLE_HOME,ORACLE_BASE,
刪除相應(yīng)行
e)umask 022
f)
保存文件,執(zhí)行
. .bash_profile
g)
設(shè)置顯示變量
DISPLAY=localhost:0.0 ; export DISPLAY
如果在遠(yuǎn)程顯示界面,
localhost
就改成遠(yuǎn)程主機(jī)
h)
如果
/tmp
空間不夠,需要設(shè)置
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
沒(méi)有設(shè)置
$ unset ORACLE_HOME
$ unset TNS_ADMIN
j)
檢驗(yàn)是否設(shè)置正確
$ umask
$ env | more
7)
安裝Oracle
a)
取得
Oracle
安裝件
從
Oracle
網(wǎng)站上下載,是免費(fèi)的,只需要一個(gè)簡(jiǎn)單的注冊(cè)即可,得到的是
zip
文件
unzip 10201_database_linux32.zip
如果是安裝光盤,
mount
上介質(zhì)
b)
運(yùn)行
runInstaller
c)
安裝過(guò)程和
Windows
非常類似,要注意的是
在選擇
dba
組的時(shí)候選擇
oinstall
安裝之前程序會(huì)檢查一下系統(tǒng)配置,如果按照上面的設(shè)置,不會(huì)有任何問(wèn)題,
install
即可
這樣安裝的
oracle
的數(shù)據(jù)文件在默認(rèn)目錄下,如果要放到不同的盤上,
可以刪除數(shù)據(jù)庫(kù)重建,或者安裝的時(shí)候選擇高級(jí)安裝
安裝
Net 8
時(shí),系統(tǒng)提示以
root
用戶執(zhí)行兩個(gè)腳本,照做就可以了
8
)收尾,設(shè)置環(huán)境變量
1)
注意
ORACLE_HOME
變量,如果不存在,需要手工設(shè)置
ORACLE_HOME=/app/oracle/product/10.2.0/db_1
2)
建庫(kù)命令為
/app/oracle/product/10.2.0/db_1/bin/dbca &
注意設(shè)置字符集,因?yàn)榘惭b界面用中文沒(méi)法安裝,所以使用英文環(huán)境安裝,
所以不能使用默認(rèn)配置,要修改默認(rèn)字符集及默認(rèn)語(yǔ)言
3)Net 8
命令為
/app/oracle/product/10.2.0/db_1/bin/netca &
4)
在其它機(jī)器上遠(yuǎn)程用
Net8
連接
Oracle,
需要打開(kāi)
Linux
上的
1521
端口
配置如下
Applications->System Setting->Secuity Level
其它端口增加
1521:tcp
即可
5)
讓
oracle
隨機(jī)器啟動(dòng)而啟動(dòng)
在
.bash_profile
里設(shè)置
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
最后一個(gè)字母默認(rèn)是
N
,修改為
Y
,否則
dbstart,dbshut
都不會(huì)起作用
修改
/app/oracle/product/10.2.0/db_1/dbstart
中的相關(guān)行為
ORACLE_HOME_LISTNER=/app/oracle/product/10.2.0/db_1
然后修改
/etc/rc.local,
增加這樣的一行
su - oracle -c dbstart
這樣就可以了,但不能關(guān)機(jī)的時(shí)候自動(dòng)關(guān)閉,所以需要手工處理
su - oracle -c dbshut
如果是
oracle
用戶可以直接
dbshut
注:我曾經(jīng)嘗試過(guò)網(wǎng)上找到的如下方法,但系統(tǒng)沒(méi)法啟動(dòng),需要用恢復(fù)模式刪掉腳本才可以,
不知道是不是我的配置問(wèn)題,如果看出我的錯(cuò)誤請(qǐng)告訴我
開(kāi)機(jī)時(shí)讓
RedHat Linux
自動(dòng)啟動(dòng)
Oracle
,需要完成以下步驟:
運(yùn)行
$ORACLE_HOME
下的
root.sh
,會(huì)生成一個(gè)文件
/etc/oratab
。
編輯
/etc/oratab
,把所有的
instance
的重啟動(dòng)標(biāo)志設(shè)置成
'Y'
,如
:
ora10g:/home/oracle/OraHome_1:Y
做一個(gè)啟動(dòng)腳本
/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
?
賦予執(zhí)行權(quán)限
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
執(zhí)行以下命令
:
chkconfig --level 345 dbora on
?
修改操作系統(tǒng)版本標(biāo)識(shí)
# vi /etc/redhat-release
#CentOS release 5.2 (Final)
redhat-4
?
安裝oracle數(shù)據(jù)庫(kù)
# su - oracle
$ export DISPLAY=192.168.1.3:0.0
$ /home/oracle/database/runInstaller
*
為客戶機(jī)IP地址,xp下使用Xmanager 2.0連接遠(yuǎn)程服務(wù)器的桌面
1. Select Installation Method
選擇
Advanced Installation
2. Specify Inventory Directory and Credentials
3. Select Installation Type
選擇
Enterprise Edition
4. Specify Home Details
Name文本框中填寫(xiě)
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環(huán)境中執(zhí)行
# /home/oracle/oraInventory/orainstRoot.sh
# /home/oracle/product/10.2.0/db_1/root.sh
19. End Of Installation
恢復(fù)操作系統(tǒng)版本
# vi /etc/redhat-release
CentOS release 5.2 (Final)
設(shè)置數(shù)據(jù)庫(kù)開(kāi)機(jī)自動(dòng)啟動(dòng)
# /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/
數(shù)據(jù)庫(kù)相關(guān)命令
$ 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
啟動(dòng)EM
http://localhost:1158/em/
?