Centos6.5静默安装Oracle 11g
环境:Centos 6.5 64
目的:无图形界面安装Oracle数据库
版本:11g 64
一、系统配置
1.安装相关依赖包,可通过挂载镜像或者阿里云、网易云等开源镜像站
yum install binutils -y yum install compat-libcap1 -y yum install compat-libstdc++-33 -y yum install gcc -y yum install gcc-c++ -y yum install glibc -y yum install glibc-devel -y yum install ksh -y yum install libgcc -y yum install libstdc++ -y yum install libstdc++-devel -y yum install libaio -y yum install libaio-devel -y yum install libXext -y yum install libXtst -y yum install libX11 -y yum install libXau -y yum install libxcb -y yum install libXi -y yum install make -y yum install sysstat -y yum install unixODBC -y yum install unixODBC-devel -y
2.配置hosts文件,请根据自身实际情况配置,我的测试机如下所示:
127.0.0.1 localhost oracle 192.168.11.92 oracle
3.添加用户和组设置用户密码,并配置orace用户环境变量
groupadd -g 501 oinstall groupadd -g 502 dba useradd -g oinstall -G dba oracle passwd oracle
环境变量,ORACLE_HOSTNAME即主机名
PS1="[`whoami`@`hostname`:"'$PWD]$' alias sqlplus="rlwrap sqlplus" #该工具可以自行下载,sql命令行记忆工具 alias rman="rlwrap rman" # export PS1 export TMP=/tmp export LANG=en_US export TMPDIR=$TMP export ORACLE_HOSTNAME=oracle export ORACLE_UNQNAME=orcl ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1; export ORACLE_HOME ORACLE_SID=orcl; export ORACLE_SID ORACLE_TERM=xterm; export ORACLE_TERM NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG PATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/11.2.0.4/db_1/bin:$ORACLE_HOME/bin; export PATH THREADS_FLAG=native; export THREADS_FLAG if [ $USER = "oracle" ] || [ $USER = "grid" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi
保存后刷新环境变量
source ~/.bash_profile
4.创建相关目录并授权
mkdir -p /u01/app/oracle mkdir -p /u01/app/oraInventory mkdir -p /u01/app/oracle/product/11.2.0.4/db_1 chown -R oracle:oinstall /u01/ chmod -R 755 /u01/ chown -R oracle:oinstall /oradata/ #存放数据文件目录也要授权 chmod -R 755 /oradata/
6.修改操作系统参数
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 oracle hard stack 32768
7.禁用selinux并关闭防火墙
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config setenforce 0 service iptables stop
8.修改内核参数
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = 2147483648
kernel.shmall = 2097152
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 = 1048586
使内核参数立即生效
让配置生效
sysctl -p
9.修改/etc/pam.d/login文件,在文件末尾追加
session required pam_limits.so
10.修改/etc/security/limits.d/90-nproc.conf文件内容
#* soft nproc 1024 #root soft nproc unlimited * - nproc 16384
二、开始静默安装数据库
上传数据库安装包以及解压包就不用写了,这里直接开始安装。
1.编辑db_install.rsp文件,文件在/database/response/db_install.rsp
[oracle@oracle:/u01/database/response]$grep -Ev "^$|^#" db_install.rsp 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=/u01/app/oraInventory SELECTED_LANGUAGES=en ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1 ORACLE_BASE=/u01/app/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= oracle.install.db.CLUSTER_NODES= oracle.install.db.isRACOneInstall= oracle.install.db.racOneServiceName= oracle.install.db.config.starterdb.type=GENERAL_PURPOSE oracle.install.db.config.starterdb.globalDBName=orcl oracle.install.db.config.starterdb.SID=orcl oracle.install.db.config.starterdb.characterSet=ZHS16GBK oracle.install.db.config.starterdb.memoryOption=true oracle.install.db.config.starterdb.memoryLimit=400 oracle.install.db.config.starterdb.installExampleSchemas=false oracle.install.db.config.starterdb.enableSecuritySettings=true oracle.install.db.config.starterdb.password.ALL=oracle 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=FILE_SYSTEM_STORAGE oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/oradata oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/fast_recovery_area 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=SKIP_UPDATES oracle.installer.autoupdates.downloadUpdatesLoc= AUTOUPDATES_MYORACLESUPPORT_USERNAME= AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
2.静默安装
查看runInstaller参数,根据自身需求进行设置
[oracle@oracle:/u01/database]$./runInstaller -help Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-12-25_09-10-18PM. Please wait ...[oracle@oracle:/u01/database]$Usage: runInstaller [-options] [(<CommandLineVariable=Value>)*] Where options include: -clusterware oracle.crs,<crs version> Version of Cluster ready services installed. -crsLocation <Path> Used only for cluster installs, specifies the path to the crs home location. Specifying this overrides CRS information obtained from central inventory. -invPtrLoc <full path of oraInst.loc> Unix only. To point to a different inventory location. The orainst.loc file contains: inventory_loc=<location of central inventory> inst_group=<> -jreLoc <location> Path where Java Runtime Environment is installed. OUI cannot be run without it. -logLevel <level> To filter log messages that have a lesser priority level than <level>. Valid options are: severe, warning, info, config, fine, finer, finest, basic, general, detailed, trace. The use of basic, general, detailed, trace is deprecated. -paramFile <location of file> Specify location of oraparam.ini file to be used by OUI. -responseFile <Path> Specifies the response file and path to use. -attachHome For attaching homes to the OUI inventory. -cfs Indicates that the Oracle home specified is on cluster file system (shared). This is mandatory when '-local' is specified so that Oracle Universal Installer can register the home appropriately into the inventory. -clone For making an Oracle Home copy match its current environment. -debug For getting the debug information from OUI. -detachHome For detaching homes from the OUI inventory without deleting inventory directory inside Oracle home. -enableRollingUpgrade Used in cluster environment, to enable upgrade of a product on a subset of nodes (on which the product was installed). -executeSysPrereqs Execute system pre-requisite checks and exit. -force Allowing silent mode installation into a non-empty directory. -help Displays above usage. -ignoreSysPrereqs For ignoring the results of the system pre-requisite checks. -local Performs the operation on the local node irrespective of the cluster nodes specified. -printdiskusage Log debug information for disk usage. -printmemory Log debug information for memory usage. -printtime Log debug information for time usage. -relink For performing relink actions on the oracle home Usage: -relink -maketargetsxml <location of maketargetsxml> [-makedepsxml <location of makedepsxml>] [name=value] -silent For silent mode operations, the inputs can be a response file or a list of command line variable value pairs. -waitforcompletion Installer will wait for completion instead of spawning the java engine and exiting. -suppressPreCopyScript Suppress the execution of precopy script. -acceptUntrustedCertificates Accept untrusted certificates from a secure site. -suppressPostCopyScript Suppress the execution of postcopy script. -noconfig Do not execute config tools. -noconsole For suppressing display of messages to console. Console is not allocated. -formCluster To install the Oracle clusterware in order to form the cluster. -remotecp <Path> Unix specific option. Used only for cluster installs, specifies the path to the remote copy program on the local cluster node. -remoteshell <Path> Unix specific option. Used only for cluster installs, specifies the path to the remote shell program on the local cluster node. -executePrereqs To execute only the prerequisite checks. -ignorePrereq To ignore running the prerequisite checks. -ignoreInternalDriverError To ignore any internal driver errors. -downloadUpdates To download updates only. -showProgress To show the installation progress on the console. This option is supported only in case of silent installation. Command Line Variables Usage Command line variables are specified using <name=value>; for example: [ session: | compName: | compName:version: ]variableName=" valueOfVariable"] Session/Installer variables are specified using: [session:]varName=value Ex 1: session:ORACLE_HOME_NAME="OraHome" Ex 2: ORACLE_HOME_NAME="OraHome" The lookup order is session:varName then just varName. The session prefix is used to avoid ambiguity. Component variables are specified using: [compInternalName:[Version:]]varName Ex 1: oracle.comp1:1.0.1:varName="VarValue" Ex 2: oracle.comp1:varName="VarValue" The lookup order is compInternalName:Version:varName, then compInternalName:varName, then just varName.
安装命令
[oracle@oracle:/u01/database]$./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /u01/database/response/db_install.rsp
参数解释
silent 静默安装 -ignorePrereq 忽略检查结果 showProgress 显示进度 responseFile db_install.rsp文件所在路径,绝对路径
安装结果
[oracle@oracle:/u01/database]$./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /u01/database/response/db_install.rsp Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 21612 MB Passed Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-12-25_07-38-34PM. Please wait ...[oracle@oracle:/u01/database]$[WARNING] [INS-13014] Target environment do not meet some optional requirements. CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2018-12-25_07-38-34PM/installActions2018-12-25_07-38-34PM.log ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2018-12-25_07-38-34PM/installActions2018-12-25_07-38-34PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually. You can find the log of this install session at: /u01/app/oraInventory/logs/installActions2018-12-25_07-38-34PM.log Prepare in progress. .................................................. 9% Done. Prepare successful. Copy files in progress. .................................................. 14% Done. .................................................. 20% Done. .................................................. 26% Done. .................................................. 31% Done. .................................................. 36% Done. .................................................. 41% Done. .................................................. 46% Done. .................................................. 51% Done. .................................................. 56% Done. .................................................. 63% Done. .................................................. 68% Done. .................................................. 73% Done. .................................................. 78% Done. .................................................. 83% Done. .............................. Copy files successful. Link binaries in progress. .......... Link binaries successful. Setup files in progress. .................................................. 88% Done. .................................................. 94% Done. Setup files successful. The installation of Oracle Database 11g was successful. Please check '/u01/app/oraInventory/logs/silentInstall2018-12-25_07-38-34PM.log' for more details. Execute Root Scripts in progress. As a root user, execute the following script(s): 1. /u01/app/oraInventory/orainstRoot.sh 2. /u01/app/oracle/product/11.2.0.4/db_1/root.sh .................................................. 100% Done. Execute Root Scripts successful. Successfully Setup Software.
在root用户下,手动执行以下脚本
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/11.2.0.4/db_1/root.sh
三、数据库创建
了解参数,如提示找不到dbca命令,请仔细检查oracle用户的环境变量
[oracle@oracle:/home/oracle]$dbca -help dbca [-silent | -progressOnly | -customCreate] {<command> <options> } | { [<command> [options] ] -responseFile <response file > } [-continueOnNonFatalErrors <true | false>] Please refer to the manual for details. You can enter one of the following command: Create a database by specifying the following parameters: -createDatabase -templateName <name of an existing template in default location or the complete template path> [-cloneTemplate] -gdbName <global database name> [-sid <database system identifier>] [-sysPassword <SYS user password>] [-systemPassword <SYSTEM user password>] [-emConfiguration <CENTRAL|LOCAL|ALL|NONE> -dbsnmpPassword <DBSNMP user password> -sysmanPassword <SYSMAN user password> [-hostUserName <Host user name for EM backup job> -hostUserPassword <Host user password for EM backup job> -backupSchedule <Daily backup schedule in the form of hh:mm>] [-centralAgent <Enterprise Manager central agent home>]] [-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE> [-datafileDestination <destination directory for all database files> | -datafileNames <a text file containing database objects such as controlfiles, tablespaces, redo log files and spfile to their corresponding raw device file names mappings in name=value format.>] [-redoLogFileSize <size of each redo log file in megabytes>] [-recoveryAreaDestination <destination directory for all recovery files>] [-datafileJarLocation <location of the data file jar, used only for clone database creation>] [-storageType < FS | ASM > [-asmsnmpPassword <ASMSNMP password for ASM monitoring>] -diskGroupName <database area disk group name> -recoveryGroupName <recovery area disk group name> [-characterSet <character set for the database>] [-nationalCharacterSet <national character set for the database>] [-registerWithDirService <true | false> -dirServiceUserName <user name for directory service> -dirServicePassword <password for directory service > -walletPassword <password for database wallet >] [-listeners <list of listeners to configure the database with>] [-variablesFile <file name for the variable-value pair for variables in the template>]] [-variables <comma separated list of name=value pairs>] [-initParams <comma separated list of name=value pairs>] [-sampleSchema <true | false> ] [-memoryPercentage <percentage of physical memory for Oracle>] [-automaticMemoryManagement ] [-totalMemory <memory allocated for Oracle in MB>] [-databaseType <MULTIPURPOSE|DATA_WAREHOUSING|OLTP>]] Configure a database by specifying the following parameters: -configureDatabase -sourceDB <source database sid> [-sysDBAUserName <user name with SYSDBA privileges> -sysDBAPassword <password for sysDBAUserName user name>] [-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword <true | false> -dirServiceUserName <user name for directory service> -dirServicePassword <password for directory service > -walletPassword <password for database wallet >] [-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE> [-enableSecurityConfiguration <true|false> [-emConfiguration <CENTRAL|LOCAL|ALL|NONE> -dbsnmpPassword <DBSNMP user password> -sysmanPassword <SYSMAN user password> [-hostUserName <Host user name for EM backup job> -hostUserPassword <Host user password for EM backup job> -backupSchedule <Daily backup schedule in the form of hh:mm>] [-centralAgent <Enterprise Manager central agent home>]] Create a template from an existing database by specifying the following parameters: -createTemplateFromDB -sourceDB <service in the form of <host>:<port>:<sid>> -templateName <new template name> -sysDBAUserName <user name with SYSDBA privileges> -sysDBAPassword <password for sysDBAUserName user name> [-maintainFileLocations <true | false>] Create a clone template from an existing database by specifying the following parameters: -createCloneTemplate -sourceSID <source database sid> -templateName <new template name> [-sysDBAUserName <user name with SYSDBA privileges> -sysDBAPassword <password for sysDBAUserName user name>] [-maintainFileLocations <true | false>] [-datafileJarLocation <directory to place the datafiles in a compressed format>] Generate scripts to create database by specifying the following parameters: -generateScripts -templateName <name of an existing template in default location or the complete template path> -gdbName <global database name> [-scriptDest <destination for all the scriptfiles>] Delete a database by specifying the following parameters: -deleteDatabase -sourceDB <source database sid> [-sysDBAUserName <user name with SYSDBA privileges> -sysDBAPassword <password for sysDBAUserName user name>]
数据库创建
[oracle@oracle:/home/oracle]$dbca -silent -createDatabase -characterset ZHS16GBK -templateName $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc -gdbName orcl -sid orcl -sysPassword oracle -systemPassword oracle -datafileDestination /u01/app/oradata/ Copying database files 1% complete 3% complete 11% complete 18% complete 26% complete 33% complete 37% complete Creating and starting Oracle instance 40% complete 45% complete 50% complete 55% complete 56% complete 60% complete 62% complete Completing Database Creation 66% complete 70% complete 73% complete 85% complete 96% complete 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
参数解释
-silent 静默 -createDatabase 创建数据库 -characterset 字符集 -templateName 模板 -gdbName 全局数据库名称 -sid 实例名称 -sysPassword sys 用户密码 -systemPassword system用户密码 -datafileDestination 指定数据文件存放路径,我这里忘记加了。不加默认是在ORACLE_BASE路径下
测试数据库是否正常
[oracle@oracle:/home/oracle]$sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 25 21:26:56 2018 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> alter system register; System altered. SQL> / System altered. SQL> exit
注意,密码需指定,不然会有以下提示
A value for the command line argument "systemPassword" is not provided. We cannot proceed without a value for this argument.
四、监听配置
了解参数
[oracle@oracle:/u01/app/oracle/product/11.2.0.4/db_1/network/admin]$netca -help Usage: netca [-silent] {<command> <options>} Perform network configuration by specifying the following arguments: [-silent] -responsefile <Response file name>] [-local {Perform configuration on only local node}] -instype <typical|custom> [-listener <Listener name (only for custom install)>] [-lisport <TCP/IP port number>] [-lps <Starting TCP/IP port number (only for typical install)>] [-lpe <Ending TCP/IP port number (only for typical install)>] [-netnum <Network resource number (only for RAC)>] [-nostartlsnr {Do not start listener}] [-crsupgrade {Upgrade default listener from lower version database home to Grid Infrastructure home (only for RAC)}] [-inscomp <Comma separated list of installed components>] [-insprtcl <Comma separated list of installed protocols>] [-orahome <Oracle home>] [-orahnam <Oracle home name>] [-log <Log file name>] [-h|-help {Print usage}]
配置监听
[oracle@oracle:/u01/database/response]$netca -silent -responseFile /u01/database/response/netca.rsp Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /u01/database/response/netca.rsp Done parsing command line arguments. Oracle Net Services Configuration: Profile configuration complete. Oracle Net Listener Startup: Running Listener Control: /u01/app/oracle/product/11.2.0.4/db_1/bin/lsnrctl start LISTENER Listener Control complete. Listener started successfully. Listener configuration complete. Oracle Net Services configuration successful. The exit code is 0
查看监听状态
[oracle@oracle:/u01/app/oracle/product/11.2.0.4/db_1/network/admin]$lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 25-DEC-2018 21:36:03 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 25-DEC-2018 21:33:07 Uptime 0 days 0 hr. 2 min. 57 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
至此,静默安装已完成