环境:Centos 6.5 64
目的:无图形界面安装Oracle数据库
版本:11g 64
一、系统配置
1.安装相关依赖包,可通过挂载镜像或者阿里云、网易云等开源镜像站
yum install binutils -yyum install compat-libcap1 -yyum install compat-libstdc++-33 -yyum install gcc -yyum install gcc-c++ -yyum install glibc -yyum install glibc-devel -yyum install ksh -yyum install libgcc -yyum install libstdc++ -yyum install libstdc++-devel -yyum install libaio -yyum install libaio-devel -yyum install libXext -yyum install libXtst -yyum install libX11 -yyum install libXau -yyum install libxcb -yyum install libXi -yyum install make -yyum install sysstat -yyum install unixODBC -yyum install unixODBC-devel -y
2.配置hosts文件,请根据自身实际情况配置,我的测试机如下所示:
127.0.0.1 localhost oracle192.168.11.92 oracle
3.添加用户和组设置用户密码,并配置orace用户环境变量
groupadd -g 501 oinstallgroupadd -g 502 dbauseradd -g oinstall -G dba oraclepasswd oracle
环境变量,ORACLE_HOSTNAME即主机名
PS1="[`whoami`@`hostname`:"'$PWD]$'alias sqlplus="rlwrap sqlplus" #该工具可以自行下载,sql命令行记忆工具alias rman="rlwrap rman" #export PS1export TMP=/tmpexport LANG=en_USexport TMPDIR=$TMPexport ORACLE_HOSTNAME=oracleexport ORACLE_UNQNAME=orclORACLE_BASE=/u01/app/oracle; export ORACLE_BASEORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1; export ORACLE_HOMEORACLE_SID=orcl; export ORACLE_SIDORACLE_TERM=xterm; export ORACLE_TERMNLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMATNLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANGPATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/11.2.0.4/db_1/bin:$ORACLE_HOME/bin; export PATHTHREADS_FLAG=native; export THREADS_FLAGif [ $USER = "oracle" ] || [ $USER = "grid" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022fi
保存后刷新环境变量
source ~/.bash_profile
4.创建相关目录并授权
mkdir -p /u01/app/oraclemkdir -p /u01/app/oraInventorymkdir -p /u01/app/oracle/product/11.2.0.4/db_1chown -R oracle:oinstall /u01/chmod -R 755 /u01/chown -R oracle:oinstall /oradata/ #存放数据文件目录也要授权chmod -R 755 /oradata/
6.修改操作系统参数
oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240oracle hard stack 32768
7.禁用selinux并关闭防火墙
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/configsetenforce 0service iptables stop
8.修改内核参数
fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmmax = 2147483648#kernel.shmall = 524288 #shmall和shmmni用系统自带的就好,自己设置会有警告。根据实际情况而定#kernel.shmmni = 4096 #kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048586
使内核参数立即生效
让配置生效sysctl -p
9.修改/etc/pam.d/login文件,在文件末尾追加
session required pam_limits.so
二、开始静默安装数据库
上传数据库安装包以及解压包就不用写了,这里直接开始安装。
1.编辑db_install.rsp文件,文件在/database/response/db_install.rsp
[oracle@oracle:/u01/database/response]$grep -Ev "^$|^#" db_install.rsporacle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME=oracleUNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/u01/app/oraInventorySELECTED_LANGUAGES=enORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1ORACLE_BASE=/u01/app/oracleoracle.install.db.InstallEdition=EEoracle.install.db.EEOptionsSelection=falseoracle.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.0oracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=oracle.install.db.CLUSTER_NODES=oracle.install.db.isRACOneInstall=oracle.install.db.racOneServiceName=oracle.install.db.config.starterdb.type=GENERAL_PURPOSEoracle.install.db.config.starterdb.globalDBName=orcloracle.install.db.config.starterdb.SID=orcloracle.install.db.config.starterdb.characterSet=ZHS16GBKoracle.install.db.config.starterdb.memoryOption=trueoracle.install.db.config.starterdb.memoryLimit=400oracle.install.db.config.starterdb.installExampleSchemas=falseoracle.install.db.config.starterdb.enableSecuritySettings=trueoracle.install.db.config.starterdb.password.ALL=oracleoracle.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_CONTROLoracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=oracle.install.db.config.starterdb.automatedBackup.enable=falseoracle.install.db.config.starterdb.automatedBackup.osuid=oracle.install.db.config.starterdb.automatedBackup.ospwd=oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGEoracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/oradataoracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/fast_recovery_areaoracle.install.db.config.asm.diskGroup=oracle.install.db.config.asm.ASMSNMPPassword=MYORACLESUPPORT_USERNAME=MYORACLESUPPORT_PASSWORD=SECURITY_UPDATES_VIA_MYORACLESUPPORT=DECLINE_SECURITY_UPDATES=truePROXY_HOST=PROXY_PORT=PROXY_USER=PROXY_PWD=PROXY_REALM=COLLECTOR_SUPPORTHUB_URL=oracle.installer.autoupdates.option=SKIP_UPDATESoracle.installer.autoupdates.downloadUpdatesLoc=AUTOUPDATES_MYORACLESUPPORT_USERNAME=AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
2.静默安装
查看runInstaller参数,根据自身需求进行设置
[oracle@oracle:/u01/database]$./runInstaller -helpPreparing to launch Oracle Universal Installer from /tmp/OraInstall2018-12-25_09-10-18PM. Please wait ...[oracle@oracle:/u01/database]$Usage: runInstaller [-options] [()*]Where options include: -clusterware oracle.crs, Version of Cluster ready services installed. -crsLocation Used only for cluster installs, specifies the path to the crs home location. Specifying this overrides CRS information obtained from central inventory. -invPtrLoc Unix only. To point to a different inventory location. The orainst.loc file contains:inventory_loc= inst_group=<> -jreLoc Path where Java Runtime Environment is installed. OUI cannot be run without it. -logLevel To filter log messages that have a lesser priority level than . Valid options are: severe, warning, info, config, fine, finer, finest, basic, general, detailed, trace. The use of basic, general, detailed, trace is deprecated. -paramFile Specify location of oraparam.ini file to be used by OUI. -responseFile 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 [-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 Unix specific option. Used only for cluster installs, specifies the path to the remote copy program on the local cluster node. -remoteshell 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 ; 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 PassedChecking swap space: must be greater than 150 MB. Actual 4095 MB PassedPreparing 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.logPrepare 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 -helpdbca [-silent | -progressOnly | -customCreate] {} | { [ [options] ] -responseFile } [-continueOnNonFatalErrors ]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 [-cloneTemplate] -gdbName [-sid ] [-sysPassword ] [-systemPassword ] [-emConfiguration -dbsnmpPassword -sysmanPassword [-hostUserName -hostUserPassword -backupSchedule ] [-centralAgent ]] [-disableSecurityConfiguration [-datafileDestination | -datafileNames ] [-redoLogFileSize ] [-recoveryAreaDestination ] [-datafileJarLocation ] [-storageType < FS | ASM > [-asmsnmpPassword ] -diskGroupName -recoveryGroupName [-characterSet ] [-nationalCharacterSet ] [-registerWithDirService -dirServiceUserName -dirServicePassword -walletPassword ] [-listeners ] [-variablesFile
]] [-variables ] [-initParams ] [-sampleSchema ] [-memoryPercentage ] [-automaticMemoryManagement ] [-totalMemory ] [-databaseType ]]Configure a database by specifying the following parameters: -configureDatabase -sourceDB
数据库创建
[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 oracleCopying database files1% complete3% complete11% complete18% complete26% complete33% complete37% completeCreating and starting Oracle instance40% complete45% complete50% complete55% complete56% complete60% complete62% completeCompleting Database Creation66% complete70% complete73% complete85% complete96% complete100% completeLook 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 sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 25 21:26:56 2018Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> 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 -helpUsage: netca [-silent] {}Perform network configuration by specifying the following arguments: [-silent] -responsefile ] [-local {Perform configuration on only local node}] -instype [-listener ] [-lisport ] [-lps ] [-lpe ] [-netnum ] [-nostartlsnr {Do not start listener}] [-crsupgrade {Upgrade default listener from lower version database home to Grid Infrastructure home (only for RAC)}] [-inscomp ] [-insprtcl ] [-orahome ] [-orahnam ] [-log ] [-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.rspDone 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 statusLSNRCTL for Linux: Version 11.2.0.4.0 - Production on 25-DEC-2018 21:36:03Copyright (c) 1991, 2013, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.4.0 - ProductionStart Date 25-DEC-2018 21:33:07Uptime 0 days 0 hr. 2 min. 57 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.oraListener Log File /u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xmlListening 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
至此,静默安装已完成