命令列下安裝oracle10g
安裝redhat5時要獨立分配磁碟給SWAP,空間大小應該是記憶體大小*2最好使用記憶體>1G的機器。
系統檢查命令:
# grep MemTotal /proc/meminfo ――檢查記憶體大小
# grep SwapTotal /proc/meminfo ――檢查交換分割槽大小swap
# df -k /tmp ――要求/tmp 400MB
# grep "model name" /proc/cpuinfo ――cpu檢查
# cat /etc/issue ――作業系統檢查
# uname –r ――系統核心檢查
當前為root超級使用者下進行操作:
1、由於orcale10不支援 redhat as5 需要修改/etc/redhat-release 將 Red
Hat Enterprise Linux Server release 5 (Tikanga) 改為Red Hat Enterprise
Linux Server release 4 (Tikanga) ,安裝完成後再將其修改回來
2、修改/etc/hosts 檔案將127.0.0.1改為本機IP地址 否則網路檢查通不過
3、檢查安裝所需的軟體包,如果提示依賴性錯誤,先按照提示內容安裝所需軟體包後繼續
所需核心版本:2.4.9-e.25(或更高版本)
通過執行以下命令檢查核心版本:
uname -r
例如:
# uname -r
2.4.9-e.27smp
其他所需程式包的版本(或更高版本):
gcc-3.2.3-2
make-3.79
binutils-2.11
openmotif-2.2.2-16
setarch-1.3-1
compat-gcc-7.3-2.96.122
compat-gcc-c++-7.3-2.96.122
compat-libstdc++-7.3-2.96.122
compat-libstdc++-devel-7.3-2.96.122
compat-db-4.0.14.5
要檢視系統上安裝了這些程式包的哪些版本,執行以下命令:
rpm -q gcc make binutils openmotif setarch compat-db compat-gcc /compat-gcc-c++ compat-libstdc++ compat-libstdc++-devel
例如:# rpm -q gcc make binutils openmotif setarch compat-db compat-gcc /> openmotif compat-gcc-c++ compat-libstdc++ compat-libstdc++-develgcc-3.2.3-20make-3.79.1-17binutils-2.14.90.0.4-26openmotif-2.2.2-16setarch-1.3-1package compat-db is not installedcompat-gcc-7.3-2.96.122compat-gcc-c++-7.3-2.96.122compat-libstdc++-7.3-2.96.122compat-libstdc++-devel-7.3-2.96.122請注意,尚未安裝 compat-db 程式包。安裝過程中可用的任何程式包組均不包含此程式包,因此必須在單獨的步驟中安裝。如果系統上缺少任何其他程式包版本,或版本比以上指定的版本舊(compat-db 除外),則可以從 Red Hat Network 下載並安裝更新。
rpm -Uvh compat-db-4*
rpm -Uvh libaio-0*
rpm -Uvh compat-libstdc++-33-3*
rpm -Uvh compat-gcc-34-3*
rpm -Uvh compat-gcc-34-c++-3*
rpm -Uvh libXp-1*
rpm -Uvh openmotif-2*
rpm -Uvh gcc-4*
第
4、修改 /etc/sysctl.conf 核心配置檔案,增加/修改以下專案,如沒有自己新增
kernel.shmall = 2097152 # 可以使用的共享記憶體的總量。
kernel.shmmax = 2147483648 # 最大共享記憶體段大小。Half the size of physical memory (in bytes)
kernel.shmmni = 4096 # 整個系統共享記憶體段的最大數目。
kernel.sem = 250 32000 100 128 # 每個訊號物件集的最大訊號物件數;系統範圍內最大訊號物件數;每個訊號物件支援的最大運算元;系統範圍內最大訊號物件集數。
fs.file-max = 65536 # 系統中所允許的檔案控制代碼最大數目。
net.ipv4.ip_local_port_range = 1024 65000 # 應用程式可使用的IPv4埠範圍。
net.core.rmem_default = 1048576 # 套接字接收緩衝區大小的預設值
net.core.rmem_max = 1048576 # 套接字接收緩衝區大小的最大值
net.core.wmem_default = 262144 # 套接字傳送緩衝區大小的預設值
net.core.wmem_max = 262144 # 套接字傳送緩衝區大小的最大值
執行下面的命令使得核心引數生效:
/sbin/sysctl –p
注:核心引數並非必須修改,可以根據自己實際情況而定。
5、增加下面的內容到檔案 /etc/security/limits.conf 檔案中:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
6、增加下面的內容到檔案 /etc/pam.d/login 中:
session required /lib/security/pam_limits.so
###session required pam_limits.so
*
For the Bourne, Bash, or Korn shell, add the following lines in the /etc/profile file (or the /etc/profile.local file on SUSE systems):
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
*
For the C shell, add the following lines in the /etc/csh.login file (or the /etc/csh.login.local file on SUSE systems):
if ( $USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
endif
7、因為SELINUX對oracle有影響,所以把secure linux設成無效,編輯檔案 /etc/selinux/config :
SELINUX=disabled
當然你也可以用圖形介面下的工具 (系統 > 管理 > 安全級別和防火牆). 選擇SELinux頁面並且設為無效.
8、新增組和使用者:
groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba oracle
passwd oracle 自行設定密碼
9、建立Oracle的安裝目錄,並把許可權付給oracle使用者:
例:
mkdir -p /u01/app/oracle/product/10.2.0/db_1
chown -R oracle.oinstall /u01
10、配置環境變數(/etc/profile或.bash_profile),增加一下內容
# Oracle Settings
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$PATH:$ORACLE_HOME/bin ; export PATH
修改後使用source /etc/profile或.bash_profile 命令使配置生效
11、設定安裝語言設定
登陸oracle使用者
因為中文安裝會有亂碼所以設定用英文安裝 export LC_ALL=en_US
12、開始安裝
進入oracle安裝目錄中,執行./runInstaller
如果提示……/.oui許可權不夠,進入install目錄,執行
chmod u+x .oui
chmod u+x unzip
===============================================
命令列安裝模式:
靜默模式(Silent)安裝必須指定一個應答檔案來完成安裝過程所須的各類引數。
1、建立oraInst.loc檔案
$ su - root
# ls /var/opt/oracle/oraInst.loc
/var/opt/oracle/oraInst.loc: No such file or directory
# mkdir -p /var/opt/oracle
# cd /var/opt/oracle
# vi oraInst.loc (加入或修改以下內容,其中/opt/oracle/oracle10是ORACLE_BASE)
inventory_loc=/opt/oracle/oracle10/oraInventory
inst_group=oinstall
# chown oracle10:oinstall oraInst.loc
# chmod 664 oraInst.loc
在Oracle安裝目錄的response子目錄裡有enterprise.rsp有enterprise.rsp、standard.rsp和custom.rsp三個應答檔案,分別對應企業版、標準版和定製的安裝。
以enterprise.rsp為例,用任意的文字編輯器打它,修改以下這些專案的值。
UNIX_GROUP_NAME="oinstall";
ORACLE_HOME Oracle伺服器的主目錄位置,必須是絕對路徑。
ORACLE_HOME_NAME Oracle伺服器的名稱,必須以字母開頭。
INSTALL_TYPE="Enterprise Edition"
SHOW_INSTALL_PROGRESS_PAGE= true
SHOW_END_OF_INSTALL_MSGS= true
COMPONENT_LANGUAGES Oracle伺服器支援的語言,預設只有英語,可以新增多個語言。
s_nameForDBAGrp 用於Oracle系統管理的linux使用者組名,該組的使用者擁有管理Oracle伺服器的許可權,在本例中設定為 oradba。
s_nameForOPERGrp 用於Oracle資料庫常規操作的linux使用者組名,該組的使用者擁有常規操作Oracle資料庫的許可權,在本例中設定為 oracle。
n_configurationOption 安裝型別(1為在安裝後建立資料庫,2為安裝後建立一個自動儲存管理例項,3為只安裝伺服器軟體),在本例中選擇3。
其它專案用預設值即可,也可以根據自己的須要進行修改。
現在萬事具備,可以安裝了。
用oracle使用者登入,然後在Oracle安裝目錄裡執行
./runInstaller -ignoreSysPrereqs -silent -responseFile <應答檔案的絕對路徑>
接下來就是等待安裝結束了。
各安裝引數的含義如下
ignoreSysPrereqs 讓Oracle忽略系統檢查,因為Oracle官方宣告只支援Linux伺服器產品,所以要在非伺服器產品的Linux上安裝就必須指定此引數。
silent 讓安裝程式以靜默模式執行。
responseFile 指定一個應答檔案。
安裝後要做的工作
3.1 Oracle系統初始化
用root使用者登入,然後執行$ORACLE_HOME/root.sh進行Oracle的系統初始化工作,通常一路按回車用預設值即可。
3.2 安裝網路監聽器
沒有網路監聽器,客戶端就無法通過網路連線Oralce伺服器。要在命令列安裝網路監聽器,也只能使用靜默模式。
編輯Oracle安裝目錄裡response子目錄下的應答檔案 netca.rsp,修改以下專案。
INSTALL_TYPE=""custom"" 安裝的型別
LISTENER_NUMBER=1 監聽器數量
LISTENER_NAMES={"LISTENER"} 監聽器的名稱列表
LISTENER_PROTOCOLS={"TCP;1521"} 監聽器使用的通訊協議列表
LISTENER_START=""LISTENER"" 監聽器啟動的名稱
NAMING_METHODS={"TNSNAMES"}
然後執行
$ORACLE_HOME/bin/netca /silent /responseFile <應答檔案的絕對路徑>
3.3 修改dbstart
用任意的文字編輯器開啟 $ORACLE_HOME/bin/dbstart,將
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
改為
ORACLE_HOME_LISTNER=$ORACLE_HOME
否則網路監聽器可能無法自動啟動。
3.4 安裝資料庫例項
編輯Oracle安裝目錄裡response子目錄下的應答檔案 dbca.rsp,修改以下專案。
GDBNAME 資料庫全域性名稱
SID 資料庫的SID
SYSPASSWORD SYS使用者的初始密碼
SYSTEMPASSWORD SYSTEM使用者的初始密碼
CHARACTERSET 資料庫字符集(中文為 ZHS16GBK)
NATIONALCHARACTERSET 資料庫國家字符集
然後執行
$ORACLE_HOME/bin/dbca -silent -cloneTemplate -responseFile <應答檔案的絕對路徑>
資料庫建立成功後須要註冊一些資訊,root使用者執行
$ORACLE_BASE/oraInventory/orainstRoot.sh
然後編輯 /etc/oratab
將
<Oracle的SID>:<Oracle的主目錄>:N
修改為
<Oracle的SID>:<Oracle的主目錄>:Y
使資料庫例項能夠自動啟動。
3.5 讓Oracle執行為服務
建立檔案 /etc/init.d/oracle,輸入下列內容
#!/bin/sh
#
export ORACLE_HOME=<Oracle伺服器主目錄的絕對路徑>
export ORACLE_HOME_LISTNER=$ORACLE_HOME
export ORACLE=oracle
. /etc/init.d/functions
export PATH=${PATH}:$ORACLE_HOME/bin
start()
{
daemon --user $ORACLE $ORACLE_HOME/bin/dbstart
daemon --user $ORACLE "$ORACLE_HOME_LISTNER/bin/lsnrctl start"
}
stop()
{
daemon --user $ORACLE "$ORACLE_HOME_LISTNER/bin/lsnrctl stop"
daemon --user $ORACLE $ORACLE_HOME/bin/dbshut
}
case $1 in
'start')
start
RETVAL=$?
;;
'stop')
stop
RETVAL=$?
;;
'restart')
stop
start
RETVAL=$?
;;
*)
echo "usage: $0 {start|stop|restart}"
exit
;;
esac
#
exit
然後將這個檔案賦予可執行的許可權,執行
chmod a+x /etc/init.d/oracle
讓Oracle的服務在Linux啟動時自動執行
ln -s /etc/init.d/oracle10g /etc/rc.d/rc3.d/S99oracle
ln -s /etc/init.d/oracle10g /etc/rc.d/rc5.d/S99oracle
這樣就可以用service來啟動和停止Oracle了。
$./runInstaller -silent -deinstall -removeallfiles -removeAllPatches "REMOVE_HOMES={$ORACLE_HOME}" -responseFile <安裝時使用的應答檔案>
./runInstaller -silent -deinstall -invPtrLoc /product/oracle/oraInventory/oraInst.loc -responseFile /mntoracle/distrib/linux/database/response/MyEnterprise.rsp