centos静默(命令行模式)安装oracle 11g,刚好公司之前oracle是在window的需要迁移到linux,oracle版本是 : Oracle Release 11.2.0.4.0 Production。
1、压缩包解压
unzip oracle-soft.zip
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
2、安装依赖包
yum install -y gcc make binutils gcc-c++ compat-libstdc++-33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel libXtst.so.6
yum install libXp*.x86_64 libXt*.x86_64 libxtst*.x86_64 -y
3、添加用户和用户组
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
4、修改内核参数文件 vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 8589934592
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
其中kernel.shmmax = 8589934592 为本机物理内存的一半,单位为byte
6. 修改文件/etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
7. 修改文件/etc/pam.d/login,添加
session required /lib64/security/pam_limits.so
session required pam_limits.so
8. 修改文件/etc/profile,添加
##ORACLE
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
9. 创建安装目录和设置目录权限
mkdir -p /data/oracle/product/11.2.0.4.0
mkdir /data/oracle/oradata //数据库文件,生产一般是放在存储上的
mkdir /data/oracle/inventory
mkdir /data/oracle/fast_recovery_area
chown -R oracle:oinstall /data/oracle
chmod -R 775 /data/oracle
chown -R oracle:oinstall /oradata //数据库文件,这里存储是挂在这个目录
10. 设置oracle用户变量,编辑文件.bash_profile,添加
ORACLE_BASE=/data/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
使用命令,让其生效
source /home/oracle/.bash_profile
11、编辑安装文件
grep -v '^#' /data/database/response/db_install.rsp | more
[oracle@oracle admin]$ grep -v '^#' /data/database/response/db_install.rsp | more
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/oracle/product/11.2.0.4.0
ORACLE_BASE=/data/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
12. 静默安装:
./runInstaller -silent -responseFile /data/database/response/db_install.rsp -ignorePrereq
安装成功后,切换root用户执行
#sh /data/oracle/inventory/orainstRoot.sh
#sh /data/oracle/product/11.2.0/root.sh
13. 以静默方式配置监听
su - oracle
export DISPLAY=ip:0.0 //根据输入实际IP
/data/oracle/product/11.2.0.4.0/bin.NETca -silent -responseFile /data/database/response/netca.rsp
运行成功后会生成配置文件
[oracle@oracle admin]$ cat listener.ora
# listener.ora Network Configuration File: /data/oracle/product/11.2.0.4.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
)
ADR_BASE_LISTENER = /data/oracle
使用命令查看服务状态
lsnrctl status
netstat -natp
14. 以静默方式建立新库,同时也建立一个对应的实例。
[oracle@oracle admin]$ grep -v '^#' /data/database/response/dbca.rsp | more
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "chenzm123"
SYSTEMPASSWORD = "chenzm123"
SYSMANPASSWORD = "chenzm123"
DBSNMPPASSWORD = "chenzm123"
DATAFILEDESTINATION =/oradata
RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
NATIONALCHARACTERSET= "UTF8"
[createTemplateFromDB]
SOURCEDB = "oracle:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl11.us.oracle.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
NODELIST=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
INSTANCENAME = "orcl11g"
SYSDBAUSERNAME = "sys"
dbca -silent -responseFile /data/database/response/dbca.rsp
15 . 设置oracle 开机启动
编辑配置文件/data/oracle/product/11.2.0/bin/dbshut
将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
修改/data/oracle/product/11.2.0/bin/dbstart
将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@oracle dbca]$ cat /data/oracle/product/11.2.0.4.0/bin/dbshut | grep 'ORACLE_HOME_LISTNER='
ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@oracle dbca]$ cat /data/oracle/product/11.2.0.4.0/bin/dbstart | grep 'ORACLE_HOME_LISTNER='
ORACLE_HOME_LISTNER=$ORACLE_HOME
修改/etc/oratab文件
将
orcl:/data/oracle/product/11.2.0.4.0:N中最后的N改为Y,成为orcl:/data/oracle/product/11.2.04.0:Y
dbshut //测试数据库关闭
dbstart // 测试数据库启动
16、设置启动脚本
cat /etc/init.d/oracle
#!/bin/bash
#oracle: Start/Stop Oracle Database 11g R2
#chkconfig: 345 90 10
#description: The Oracle Database is an Object-Relational Database ManagementSystem.
#
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/data/oracle/product/11.2.0.4.0
ORACLE_USER=oracle
case "$1" in
'start')
if [ -f $LOCKFILE ]; then
echo $0 already running.
else
echo -n $"StartingOracle Database:"
su - $ORACLE_USER -c"$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c"$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_USER -c"$ORACLE_HOME/bin/emctl start dbconsole"
touch $LOCKFILE
fi
;;
'stop')
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
else
echo -n $"StoppingOracle Database:"
su - $ORACLE_USER -c"$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c"$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c"$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE
fi
;;
'restart')
$0 stop
sleep 5
$0 start
;;
'status')
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "Usage: $0[start|stop|status]"
exit 1
esac
exit 0
▶安装过程错误处理
如监听文件没配置好
安装数据库实例的时候,报空指针异常
原因是文件,多了其他字符的原因,导致配置文件有问题