linux 靜默安裝 oracle 11
linux 版本
[root@oracle ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
環(huán)境檢查
top - 16:05:23 up 8:34, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 152 total, 1 running, 151 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1906556k total, 1094320k used, 812236k free, 58280k buffers
Swap: 2097144k total, 0k used, 2097144k free, 839620k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1654 oracle -2 0 1185m 14m 13m S 0.7 0.8 1:52.05 oracle
1799 oracle 20 0 1190m 49m 44m S 0.3 2.7 0:05.11 oracle
16699 root 20 0 15036 1268 948 R 0.3 0.1 0:00.02 top
1 root 20 0 19364 1540 1228 S 0.0 0.1 0:02.77 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.30 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:00.11 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
6 root RT 0 0 0 0 S 0.0 0.0 0:00.05 watchdog/0
7 root RT 0 0 0 0 S 0.0 0.0 0:00.01 migration/1
8 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
9 root 20 0 0 0 0 S 0.0 0.0 0:00.11 ksoftirqd/1
10 root RT 0 0 0 0 S 0.0 0.0 0:00.05 watchdog/1
11 root RT 0 0 0 0 S 0.0 0.0 0:00.25 migration/2
df -h
檢查 swap分區(qū)、內存、磁盤大小
安裝 jdk
下載 jdk-8u73-linux-x64.rpm
安裝
rpm -ivh jdk-8u91-linux-x64.rpm
配置環(huán)境變量
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_91
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
測試
source /etc/profile
java -version
使用 root 用戶配置環(huán)境變量
關閉 selinux
selinux 配置文件
[root@oracle ~]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
臨時關閉
setenforce 0
永久關閉
vim /etc/selinux/config
SELINUX=disabled
關閉防火墻
service iptables stop
systemctl stop firewalld
systemctl disable firewalld
修改主機名
hostname centos
在/etc/hosts文件中添加主機名
[root@centos ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.8.200 centos
ORA-00130: invalid listener address
添加與主機名與IP對應記錄,不然在安裝數(shù)據(jù)庫時會報錯
安裝依賴包
yum install gcc
yum install gcc-c++
yum install libaio-devel
yum install compat-gcc-34
yum install compat-gcc-34-c++
建立用戶和組
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
echo "oracle" | passwd --stdin oracle
id oracle
[root@oracle ~]# id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba),502(oper)
建立安裝目錄、設置文件權限
mkdir -p /u01/app/oracle /product/11.2.0/db_1
mkdir /u01/app/oracle/oradata
mkdir /u01/app/oracle/oraInventory
mkdir /u01/app/oracle/fast_recovery_area
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app
修改參數(shù)
內核參數(shù)
vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
改好后,使之生效
sysctl -p
注:kernel.shmmax = 1073741824(byte)為本機物理內存的一半
修改系統(tǒng)資源限制
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
修改用戶驗證選項
vim /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
修改用戶配置文件
vim /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
修改 oracle 用戶環(huán)境變量
vim ~oracle/.bash_profile
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
ORACLE_SID=orcl
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
準備安裝文件
上傳安裝包到 /tmp 目錄下解壓修改應答文件進行靜默安裝
oracle 安裝文件名
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
修改權限
chown -R oracle:oinstall ./linux.x64_11gR2_database_1of2.zip
chown -R oracle:oinstall ./linux.x64_11gR2_database_2of2.zip
切換 oracle 用戶、使修改的環(huán)境變量生效
su - oracle
source .bash_profile
解壓安裝包、復制應答文件到 oracle 用戶的目錄下
cd /tmp
unziap ./linux.x64_11gR2_database_1of2.zip
unziap ./linux.x64_11gR2_database_2of2.zip
cp -R /tmp/database/response/ /home/oracle/
cd /home/oracle/response/
應答文件
db_install.rsp:安裝應答
dbca.rsp:創(chuàng)建數(shù)據(jù)庫應答
netca.rsp:建立監(jiān)聽、本地服務名等網(wǎng)絡設置的應答
Oracle 11g 靜默安裝-db_install.rsp詳解
修改應答文件
vim ./db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME= localhost.localdomain
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
部分參數(shù)含義
各參數(shù)含義如下:
-silent 表示以靜默方式安裝,不會有任何提示
-force 允許安裝到一個非空目錄
-noconfig 表示不運行配置助手netca
-responseFile 表示使用哪個響應文件,必需使用絕對路徑
oracle.install.responseFileVersion 響應文件模板的版本,該參數(shù)不要更改
oracle.install.option 安裝選項,本例只安裝oracle軟件,該參數(shù)不要更改
DECLINE_SECURITY_UPDATES 是否需要在線安全更新,設置為false,該參數(shù)不要更改
ORACLE_HOSTNAME 安裝主機名
UNIX_GROUP_NAME oracle用戶用于安裝軟件的組名
INVENTORY_LOCATION oracle產(chǎn)品清單目錄
SELECTED_LANGUAGES oracle運行語言環(huán)境,一般包括引文和簡繁體中文
ORACLE_HOME Oracle安裝目錄
ORACLE_BASE oracle基礎目錄
oracle.install.db.InstallEdition 安裝版本類型,一般是企業(yè)版
oracle.install.db.isCustomInstall 是否定制安裝,默認Partitioning,OLAP,RAT都選上了
oracle.install.db.customComponents 定制安裝組件列表:除了以上默認的,可加上Label Security和Database Vault
oracle.install.db.DBA_GROUP oracle用戶用于授予OSDBA權限的組名
oracle.install.db.OPER_GROUP oracle用戶用于授予OSOPER權限的組名
靜默安裝
cd /tmp/database
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
.
.
.
#Root scripts to run
/u01/app/oracle/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
安裝完畢后會提示上述的信息,按照要求使用 root 用戶執(zhí)行上面的兩個腳本
靜默配置監(jiān)聽程序
使用 oracle 用戶
netca /silent /responsefile /home/oracle/response/netca.rsp
檢驗
1、在 /u01/app/oracle/product/11.2.0/db_1/network/admin/ 中生成 listener.ora 和 sqlnet.ora
ll /u01/app/oracle/product/11.2.0/db_1/network/admin/
2、通過netstat命令可以查看1521端口正在監(jiān)聽
netstat -tnul | grep 1521
靜默方式建庫
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK -memoryPercentage 30 -emConfiguration LOCAL
.
.
.
85% complete
96% complete
100% complete
Look at the log file "/opt/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log" for further details.
數(shù)據(jù)庫成功安裝之后默認是啟動狀態(tài)
參數(shù)說明
-silent 指以靜默方式執(zhí)行dbca命令
-createDatabase 指使用dbca
-templateName 指定用來創(chuàng)建數(shù)據(jù)庫的模板名稱,這里指定為General_Purposedbc,即一般用途的數(shù)據(jù)庫模板
-gdbname 指定創(chuàng)建的全局數(shù)據(jù)庫名稱,這里指定名稱為ocp11g
-sid 指定數(shù)據(jù)庫系統(tǒng)標識符,這里指定為ocp11g,與數(shù)據(jù)庫同名
-responseFile 指定安裝響應文件,NO_VALUE表示沒有指定響應文件
-characterSet 指定數(shù)據(jù)庫使用的字符集,這里指定為AL32UTF8
-memoryPercentage 指定用于oracle的物理內存的百分比,這里指定為30%
-emConfiguration 指定Enterprise Management的管理選項。LOCAL表示數(shù)據(jù)庫由Enterprise Manager本地管理
數(shù)據(jù)庫成功安裝之后默認是啟動狀態(tài)
檢驗
1、進行實例進程檢查
ps -ef | grep ora_ | grep -v grep
2、查看監(jiān)聽狀態(tài)
lsnrctl status
3、登錄查看實例狀態(tài)
sqlplus / as sysdba
設置Linux開機自啟動七、 設置Linux開機自啟動
修改ORACLE_HOME_LISTNER
將下面兩個文件的ORACLE_HOME_LISTNER=$1修改為ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /u01/app/oracle/product/11.2.0/db_1/bin/dbstart
vim /u01/app/oracle/product/11.2.0/db_1/bin/dbshut
配置oratab
vi /etc/oratab
找到testsid:/opt/oracle/102:N,改為testsid:/opt/oracle/102:Y
配置rc.local
vi /etc/rc.d/rc.local
添加如下行
su oracle -lc "/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"
su oracle -lc /u01/app/oracle/product/11.2.0/db_1/bin/dbstart
增加權限
chmod +x /etc/rc.d/rc.local
開放1521端口允許網(wǎng)絡連接
service iptables stop
vi /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Fri Dec 16 07:29:41 2016
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [10:892]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 1521 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Fri Dec 16 07:29:41 2016
service iptables save
service iptables restart
附
參考文檔
Oracle11gR2 for Linux 靜默安裝(推薦)
oracle11G靜默安裝過程——linux環(huán)境
CentOS 6.2 X64上64位Oracle11gR2 靜默安裝,靜默設置監(jiān)聽,靜默建庫
常用命令
lsnrctl start 啟動監(jiān)聽
lsnrctl stop 關閉監(jiān)聽
lsnrctl status 查看監(jiān)聽狀態(tài)
sqlplus /nolog 登陸 sqlplus
startup 啟動數(shù)據(jù)庫
conn /as sysdba 用 sysdba 登陸數(shù)據(jù)庫
iptables -L -n iptables當前規(guī)則
mkdir -p /u01/app/oracle /product/11.2.0/db_1 遞歸創(chuàng)建文件夾
chown -R oracle:oinstall /u01/app 修改文件或文件夾的所有者所屬組
chmod -R 775 /u01/app 修改文件或文件夾權限
vi /etc/sysconfig/iptables 修改文本文件
ps -ef | grep ora_ | grep -v grep
netstat -tnul | grep 1521
若有不正確的地方,望大神指教?。?!