<b>針對</b><b> Oracle </b><b>配置</b><b> Linux</b>
Linux 軟體現已安裝完畢,您需要針對 Oracle 對其進行配置。本部分将逐漸講解針對 Oracle 資料庫 11g 第 1 版配置 Linux 的過程。
<b>建立</b><b> Oracle </b><b>組和使用者帳戶</b>
接下來,建立用于安裝和維護 Oracle 資料庫 11g 第 1 版軟體的 Linux 組和使用者帳戶。使用者帳戶将稱為 oracle,而組将稱為 oinstall 和 dba。以 root 使用者身份執行以下指令:
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -m -g oinstall -G dba oracle
id oracle
Ex:
# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/useradd -m -g oinstall -G dba oracle
# id oracle
uid=501(oracle) gid=502(oinstall) groups=502(oinstall),503(dba)
設定 oracle 帳戶的密碼:
passwd oracle
# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
<b>建立目錄</b>
現在建立目錄來存放 Oracle 資料庫 11g 第 1 版軟體及資料庫檔案。本指南在建立目錄結構時所用的命名慣例符合最佳靈活結構 (OFA) 規範。有關 OFA 标準的更多資訊,請參閱針對 Linux 的 Oracle 資料庫安裝指南 11g 第 1 版 (11.1) 的附錄 D。
以下假設在根檔案系統中建立目錄。這樣做是為了簡便起見,不建議将其作為通用做法。這些目錄通常被建立為單獨的檔案系統。
以 root 使用者身份執行以下指令:
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app
<b>配置</b><b> Linux </b><b>核心參數</b>
Oracle 資料庫 11g 第 1 版需要以下所示的核心參數設定。給出的值都為最小值,是以如果您的系統使用一個更大的值,則不要進行更改。Linux 允許在系統啟動并運作時修改大多數核心參數,是以無需在修改核心參數後重新開機系統。
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
注意,OEL 5 已經為 kernel.shmall 和 kernel.shmmax 定義了值。如果預設值等于或大于要求值,則使用預設值。
如果您按照以上說明安裝了 Linux,且核心參數全部采用預設值,則隻需在以 root 使用者身份登入後執行下指令。
cat >> /etc/sysctl.conf <<EOF
EOF
/sbin/sysctl -p
# cat >> /etc/sysctl.conf <<EOF
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
# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 262144
以 root 使用者身份運作以下指令來驗證您的設定:
/sbin/sysctl -a | grep shm
/sbin/sysctl -a | grep sem
/sbin/sysctl -a | grep file-max
/sbin/sysctl -a | grep ip_local_port_range
/sbin/sysctl -a | grep rmem_default
/sbin/sysctl -a | grep rmem_max
/sbin/sysctl -a | grep wmem_default
/sbin/sysctl -a | grep wmem_max
# /sbin/sysctl -a | grep shm
kernel.shm-use-bigpages = 0
# /sbin/sysctl -a | grep sem
# /sbin/sysctl -a | grep file-max
# /sbin/sysctl -a | grep ip_local_port_range
# /sbin/sysctl -a | grep rmem_default
# /sbin/sysctl -a | grep rmem_max
# /sbin/sysctl -a | grep wmem_default
# /sbin/sysctl -a | grep wmem_max
<b>為</b><b> oracle </b><b>使用者設定</b><b> Shell </b><b>限制</b>
Oracle 建議對每個 Linux 帳戶可以使用的程序數和打開的檔案數設定限制。要進行這些更改,以 root 使用者的身份執行下列指令:
cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
cat >> /etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
修改 bash 和 ksh 的預設配置檔案以及 cshell 的預設登入腳本。
cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
cat >> /etc/csh.login <<EOF
if ( \$USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
endif
<b>附錄</b>
<b>使用</b><b> SQL*Plus </b><b>通路資料庫</b>
以 oracle 身份登入到 Linux。設定環境。
設定 Oracle 環境變量:
$ . oraenv
ORACLE_SID = [demo1] ? demo1
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
運作 SQL*Plus:
$ sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Nov 4 23:56:47 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
<b>使用</b><b> Oracle Enterprise Manager 11g </b><b>資料庫控制</b>
在 Web 浏覽器中,連接配接到安裝過程中提供的 URL。
例如:
https://ds1.orademo.org:1158/em(如果資料庫伺服器不在 DNS 中,則必須使用 IP 位址代替主機名。)
User Name:SYSTEM
Password:<安裝過程中選擇的密碼>
Connect As:Normal
單擊 <Login>

歡迎使用 Oracle Enterprise Manager 11g 資料庫控制。
啟動和停止 Oracle 企業管理器資料庫控制:
$ emctl start dbconsole
$ emctl stop dbconsole
啟動和停止監聽器:
監聽器接受用戶端的連接配接請求,并在驗證證書後建立資料庫連接配接。要使用 OEM,必須先啟動監聽器。
$ lsnrctl start
$ lsnrctl stop
啟動和停止資料庫:
啟動和停止資料庫的最簡單方法是從 OEM 控制台啟動和停止。要從指令行執行此操作,請在以 oracle 身份登入後使用 SQL*Plus,如下所示:
啟動:
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Nov 5 00:00:31 2007
SQL> startup
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size 1303216 bytes
Variable Size 377490768 bytes
Database Buffers 465567744 bytes
Redo Buffers 5169152 bytes
Database mounted.
Database opened.
SQL> exit
停止:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.