【實戰】靜默安裝-oracle11.2.0.3oncentos5.10
發現網上靜默安裝的文章很多,亂七八糟,五花八門!來個掃盲的!
centos 5.10 下安裝oracle 11g_r2
******************************************************************************
1.系統部分
******************************************************************************
------1.安裝系統
--applications
graphics
graphical internet
text-based internet
offce/productivity
editors
sound and video
--base system
Administration Tools
base
legacy software support: compat-libstdc- compat-db-
X Window System
system tools :sysstat-
---desktop envirements
gnome desktop environment
--development默認選項後添加下面選項
Development Libraries :libstdc-
development tools :gcc-
legacy software development
--languages
chinese support
---server
ftp server
legacy network server:rsh-server telnet-server
printing support
server configure tools
------2.配置xmanager連接linux
---2.1 centos 6.5
1).yum install xdm 安裝XDM
2).vi /etc/X11/xdm/Xaccess
49 * #any host can get a login window
3).修改/etc/gdm/custom.conf文件。
[xdmcp]
Enable=true
DisplaysPerHost=5
Port=177
[security]
AllowRemoteRoot=true
4).重啟gpm服務:
service gpm restart
chkconfig gpm on 確認GPM服務開機啟動
5).重啟gdm服務
/usr/sbin/gdm -restart
---2.2 centos 5.10
--1.編輯配置文件
ls -al /usr/share/gdm/defaults.conf
chmod 644 /usr/share/gdm/defaults.conf
vi /usr/share/gdm/defaults.conf
/****
/usr/share/gdm/defaults.conf 和/etc/gdm/custom.conf 內容一致,修改任意一個即可
****/
[xdmcp]
Enable=true
DisplaysPerHost=5
Port=177
[security]
AllowRemoteRoot=true
vi /usr/share/gdm/defaults.conf
214行 AllowRemoteRoot=true
263行 Enable=true
279行 DisplaysPerHost=2
284行 Port=177
--2.重啟gpm服務:
service gpm restart
chkconfig gpm on 確認GPM服務開機啟動
--2.重啟gdm服務
/usr/sbin/gdm-restart
-------1.3 配置yum源
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.old
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum makecache
檢查可更新的rpm包
#yum check-update
更新所有的rpm包
#yum update
yum -y groupinstall 'Development Libraries'
******************************************************************************
2.oracle安裝部分
******************************************************************************
1、檢查下列包是否安裝,若未安裝則要先安裝:
mount /dev/cdrom /mnt
cd /mnt/CentOS
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh compat-libstdc++-33*.i386.rpm
rpm -Uvh elfutils-libelf*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgomp-4.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh numactl-devel-*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
---使用yum安裝unixODBC
yum install unixODBC
yum install elfutils-libelf-devel
yum install pdksh
步驟4:配置系統
[root@ora ~]# grep MemTotal /proc/meminfo
MemTotal: 4946772 kB
[root@ora ~]# grep SwapTotal /proc/meminfo
SwapTotal: 12289716 kB
[root@ora ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 17G 2.8G 14G 18% /
/dev/sda1 1012M 40M 921M 5% /boot
none 891M 0 891M 0% /dev/shm
/dev/hdc 192M 192M 0 100% /media/cdrom
二、參數修改
1.設置需要的IP
2、修改host文件
在/etc/hosts文件中添加一個全限定域名,如:
vi /etc/hosts
192.168.5.199 ocpyang.sz.com ocpyang
3. 查看修改結果
hostname
cat /etc/hosts | grep `eval hostname`
4、設置核心參數
1、在/etc/sysctl.conf文件中加入下列行:
#vi /etc/sysctl.conf
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 2532755456
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
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
5、運行下列命令改變核心參數:
#/sbin/sysctl -p
6、在/etc/security/limits.conf文件中加入下列行:
# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle hard stack 10240
7、在/etc/pam.d/login文件中加入下列行:
# vi /etc/pam.d/login
session required pam_limits.so
8.關閉SELINUX的工作模式和防火牆
# vi /etc/selinux/config
# 設置SELINUX為disabled
SELINUX=disabled
# service iptables stop
三、創建下列組和用戶
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper -d /home/oracle oracle
passwd oracle
四、創建安裝oracle的目錄
mkdir -p /u01
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle.oinstall /u01
chmod -R 775 /u01
說明:/u01/app/oracle/product/11.2.0/db_1目錄是用於放置程序文件的位置。
五、設置oracle用戶的環境變量
用oracle登錄在:/home/oracle/.bash_profile文件末尾,注意把其中ORACLE_SID換成自己的實例名:
# vi /home/oracle/.bash_profile
也可以
#su - oracle
#vi .bash_profile
增加下列內容:
# Oracle Settings
TMP=/tmp;
export TMP
TMPDIR=$TMP;
export TMPDIR
ORACLE_BASE=/u01/app/oracle;
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1;
export ORACLE_HOME
ORACLE_SID=orcl;
export ORACLE_SID
ORACLE_TERM=xterm;
export ORACLE_TERM
PATH=/usr/sbin:$PATH;
export PATH
PATH=$ORACLE_HOME/bin:$PATH;
export PATH
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH
#LD_ASSUME_KERNEL=2.4.1;
export LD_ASSUME_KERNEL
#set language
NLS_LANG="SIMPLIFIED CHINESE"_CHINA.AL32UTF8
export NLS_LANG
EDITOR=vi
export EDITOR
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
alias oratrace="cat $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_orcl.log"
alias oradata="cd $ORACLE_BASE/oradata/$ORACLE_SID"
alias oranetwork="cd $ORACLE_HOME/network/admin"
六、安裝
$unzip 1.zip
$unzip 2.zip
$cd /soft/
chown -R oracle:oinstall /soft/database
$ cd database/
cp -R /soft/database/response /home/oracle
----方法1:
$ ./runInstaller -silent -debug -force \
FROM_LOCATION=/soft/database/stage/products.xml \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=ocpyang.sz.com \
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.EEOptionsSelection=false \
oracle.install.db.DBA_GROUP=dba \
oracle.install.db.OPER_GROUP=oper \
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE \
oracle.install.db.config.starterdb.memoryOption=false \
oracle.install.db.config.starterdb.installExampleSchemas=false \
oracle.install.db.config.starterdb.enableSecuritySettings=true \
oracle.install.db.config.starterdb.control=DB_CONTROL \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true \
oracle.installer.autoupdates.option=SKIP_UPDATES
---方法2:
vi /home/oracle/ocp.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=ocpyang.sz.com
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.EEOptionsSelection=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.memoryOption=false
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.control=DB_CONTROL
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
./runInstaller -ignoreSysPrereqs -force -silent -responseFile /home/oracle/response/ocp.rsp
[oracle@ocp ~]$ su -l root
Password:
#/u01/app/oraInventory/orainstRoot.sh
#/u01/app/oracle/product/11.2.0/db_1/root.sh
七、靜默建庫和靜默配置監聽:
---7.1 靜默建庫
$ cat /home/oracle/createdb.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "password"
SYSTEMPASSWORD = "password"
SYSMANPASSWORD = "password"
DBSNMPPASSWORD = "password"
DATAFILEDESTINATION ="/u01/app/oracle/oradata"
STORAGETYPE=FS
CHARACTERSET = "ZHS16GBK"
DATABASETYPE = "MULTIPURPOSE"
AUTOMATICMEMORYMANAGEMENT = "FALSE"
$ dbca -silent -responseFile /home/oracle/response/createdb.rsp
ps -ef | grep ora_ | grep -v grep | wc -l
----7.2靜默配置監聽
$ $ORACLE_HOME/bin/netca /silent /responsefile /home/oracle/response/netca.rsp
$ ll $ORACLE_HOME/network/admin/*.ora
$ lsnrctl status
執行完後, 監聽就已經啟
八、安裝後配置
修改oratab文件,在/etc/oratab文件中添加下面的一行,
vi /etc/oratab
orcl:/u01/app/oracle/product/11.2.0/db_1:Y
啟動和停止 Oracle Enterprise Manager 數據庫控制:
$ emctl start dbconsole
$ emctl stop dbconsole
啟動和停止 iSQL*Plus:
$ isqlplusctl start
$ isqlplusctl stop
啟動和停止監聽器:
監聽器接受客戶端的連接請求,並在驗證證書後創建數據庫連接。要使用 OEM 或 iSQL*Plus,必須先啟動監聽器。
$ lsnrctl start
$ lsnrctl stop
$cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
啟動和停止數據庫:
啟動:
$ sqlplus
SQL> startup
關閉:
$ sqlplus
SQL> shutdown immediate
九、設置開機oracle自動啟動
步驟1:
# vi /etc/oratab
ORCL:/u01/app/oracle/product/10.2.0/db_1:Y
/etc/oratab格式為:SID:ORACLE_HOME:AUTO把AUTO域設置為Y(大寫),只有這樣,
oracle 自帶的dbstart和dbshut才能夠發揮作用
步驟2:使用Oracle用戶修改$Oracle_HOME/bin/dbstart文件
$vi /u01/app/oracle/product/11.2.0/db_1/bin/dbstart
82行 ORACLE_HOME_LISTNER=$1
修改為
ORACLE_HOME_LISTNER=$ORACLE_HOME
步驟3:root新建oracle控制文件
#vi /etc/init.d/oracle11gr2
內容為oracle11gr2腳本
步驟4:讓linux服務控制
# chmod 774 /etc/init.d/oracle11gr2
# chkconfig --add oracle11gr2
這樣開機將隨機啟動。
同時也可以使用命令隨時啟動:
#service oracle11gr2 start
#service oracle11gr2 stop
#service oracle11gr2 restart
十、配置:(解決偵聽失敗,見文件)
安裝完成後,第一次啟動是沒有問題的,但是,重啟動計算機後,你必需通過手工或者腳本啟動數據庫。
1、手工啟動數據庫:以oracle用戶執行dbstart,這個命令在我安裝完成後,出現錯誤,我就把這個腳本修改了一下,
利用文本編輯器打開dbstart,
把78行的
vi /u01/app/oracle/product/11.2.0/db_1/bin/dbstart
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle換成你自己的路徑。
ORACLE_HOME_LISTNER=/u01/app/oracle/product/10.2.0/db_1/
關閉數據庫用dbshut就可以了。
如果你需要使用isqlplus管理數據庫,就要啟動isqlplus,運行命令:isqlplusctl start | stop
要使用基於web的企業管理器,就要運行命令:emctl start | stop dbconsole
-----十二、常見sql全局配置文件
vi /u01/app/oracle/product/11.2.0/db_1/sqlplus/admin/glogin.sql
--dba add for oracle
alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';
define _editor=vi
set serveroutput on size 1000000
set trimspool on
set long 5000
set linesize 100
set pagesize 9999
column plan_plus_exp format a80
column global_name new_value gname
set termout off
define gname=idle
column global_name new_value gname
select lower(user) || '@' || substr( global_name, 1,
decode( dot, 0, length(global_name), dot-1) ) global_name
from (select global_name, instr(global_name,'.') dot from global_name );
set time on
set sqlprompt '&gname>'
----中文表設置
create table t1
(
sid number,
sname varchar2(20)
);
insert into t1 values(101,'蘇州');
insert into t1 values(102,'oracle中文測試');