一、安装Oracle 11G前环境搭建
本次实验是基于Linux(CentOS6.7_64)下搭建oracle 11g环境,这里选择CentOS安装oracle并不是最佳选择,可以根据需要选择不同的Linux发行版,如Oracle Linux、SuSE Linux、Red Hat、IBM AIX等。
VM或物理机的配置要求:
在实验环境安装oracle11g最少需要2G内存、2个cpu、2G交换分区、磁盘空间不低于20G。
生产环境中,要保证oracle的性能,建议最低配置为8G内存、4个cpu、8G交换分区,如果生产环境比较繁忙,则需要更高的配置。
二、安装Oracle 11G前准备工作
上传oracle11g安装包,解压
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4 ::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6 #eth0 10.11.12.88hm
创建oracle相关用户和组
[root@hm~]#groupadddba [root@hm~]#groupaddoinstall [root@hm~]#useradd-goinstall-Gdba-moracle [root@hm~]#idoracle uid=500(oracle)gid=501(oinstall)groups=501(oinstall),500(dba)
创建oracle软件安装目录
[root@hm~]#mkdir/u01/app/oracle-p [root@hm~]#chown-Roracle./u01/ [root@hm~]#chmod775-R/u01/ [root@hm~]#ls-ld/u01/ drwxr-xr-x.3oracleoinstall4096Oct1422:58/u01/
oracle用户环境变量设置,su进入oracle用户下,修改~/.bash_profile文件,添加以下内容
exportTMP=/tmp exportTMPDIR=$TMP exportORACLE_TERM=xterm exportORACLE_BASE=/u01/app/oracle exportORACLE_HOME=$ORACLE_BASE/db exportORACLE_SID=orcl exportPATH=$ORACLE_HOME/bin:$PATH exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/lib64 if[$USER="oracle"];then if[$SHELL="/bin/ksh"];then ulimit-p16384 ulimit-n65536 else ulimit-u16384-n65536 fi fi
修改内核参数,打开/etc/sysctl.conf文件,添加以下参数,并修改/etc/security/limits.conf文件
kernel.shmmax=68719476736 kernel.shmall=4294967296 net.core.rmem_default=262144 net.core.rmem_max=4194304 net.core.wmem_default=262144 net.core.wmem_max=1048576 fs.aio-max-nr=1048576 net.ipv4.ip_local_port_range=900065500 fs.file-max=6815744 kernel.sem=25032000100128 kernel.shmmni=4096 [root@hm~]#sysctl-p 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 kernel.msgmax=65536 kernel.shmmax=68719476736 kernel.shmall=4294967296 kernel.shmmax=68719476736 kernel.shmall=4294967296 net.core.rmem_default=262144 net.core.rmem_max=4194304 net.core.wmem_default=262144 net.core.wmem_max=1048576 fs.aio-max-nr=1048576 net.ipv4.ip_local_port_range=900065500 fs.file-max=6815744 kernel.sem=25032000100128 kernel.shmmni=4096 在/etc/security/limits.conf文件末尾添加如下内容 oraclesoftnproc2047 oraclehardnproc16384 oraclesoftnofile4096 oraclehardnofile65536 并同时修改/etc/pam.d/login文件,添加以下内容 sessionrequiredpam_limits.so
安装oracle依赖的软件包
[root@hm ~]# yum install gcc gcc-c++ libaio glibc compat-libstdc++-33 elfutils-libelf-devel libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel glibc-common ksh make sysstat pdksh [root@hm ~]# yum install glibc-2.12-1.192.el6.i686 检查是否安装 [root@hm ~]# for i in gcc gcc-c++ libaio glibc compat-libstdc++-33 elfutils-libelf-devel libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel glibc-common ksh make sysstat pdksh;do rpm -q $i;done |
三、安装oracle11g软件
解压oracle11g软件包
[root@hm oracle]# unzip linux.x64_11gR2_database_1of2.zip
[root@hm oracle]# unzip linux.x64_11gR2_database_2of2.zip
[root@hmoracle]#chown-Roracle.database/ [root@hmoracle]#ls-ldatabase/ total36 drwxr-xr-x.12oracleoinstall4096Aug172009doc drwxr-xr-x.4oracleoinstall4096Aug152009install drwxrwxr-x.2oracleoinstall4096Aug152009response drwxr-xr-x.2oracleoinstall4096Aug152009rpm -rwxr-xr-x.1oracleoinstall3226Aug152009runInstaller drwxrwxr-x.2oracleoinstall4096Aug152009sshsetup drwxr-xr-x.14oracleoinstall4096Aug152009stage -rw-r--r--.1oracleoinstall5402Aug182009welcome.html
以orcle用户登录图形界面安装oracle,也可以使用vnc远程安装。这里直接用Xshell远程调用linux图形界面进行安装
[root@hm~]#su-oracle [oracle@hm~]$exportDISPLAY=10.11.12.1:0.0 [oracle@hm~]$xhost+
进入database目录,执行runInstalle
[oracle@hm~]$cd/usr/local/src/oracle/database/ [oracle@hmdatabase]$./runInstaller StartingOracleUniversalInstaller... CheckingTempspace:mustbegreaterthan120MB.Actual21645MBPassed Checkingswapspace:mustbegreaterthan150MB.Actual4095MBPassed Checkingmonitor:mustbeconfiguredtodisplayatleast256colors.Actual16777216Passed PreparingtolaunchOracleUniversalInstallerfrom/tmp/OraInstall2016-10-15_12-48-55PM.Pleasewait...
进入图形界面安装
@L_301_10@
[root@hm~]#/u01/app/oraInventory/orainstRoot.sh Changingpermissionsof/u01/app/oraInventory. Addingread,writepermissionsforgroup. Removingread,write,executepermissionsforworld. Changinggroupnameof/u01/app/oraInventorytooinstall. Theexecutionofthescriptiscomplete. [root@hm~]#/u01/app/oracle/db/root.sh RunningOracle11groot.shscript... Thefollowingenvironmentvariablesaresetas: ORACLE_OWNER=oracle ORACLE_HOME=/u01/app/oracle/db Enterthefullpathnameofthelocalbindirectory:[/usr/local/bin]: Copyingdbhometo/usr/local/bin... Copyingoraenvto/usr/local/bin... Copyingcoraenvto/usr/local/bin... Creating/etc/oratabfile... Entrieswillbeaddedtothe/etc/oratabfileasneededby DatabaseConfigurationAssistantwhenadatabaseiscreated Finishedrunninggenericpartofroot.shscript. Nowproduct-specificrootactionswillbeperformed. Finishedproduct-specificrootactions.
启动监听
[oracle@hm~]$lsnrctlstart LSNRCTLforLinux:Version11.2.0.1.0-Productionon15-OCT-201623:30:07 Copyright(c)1991,2009,Oracle.Allrightsreserved. Starting/u01/app/oracle/db/bin/tnslsnr:pleasewait... TNSLSNRforLinux:Version11.2.0.1.0-Production Logmessageswrittento/u01/app/oracle/diag/tnslsnr/hm/listener/alert/log.xml Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hm)(PORT=1521))) Connectingto(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUSoftheLISTENER ------------------------ AliasLISTENER VersionTNSLSNRforLinux:Version11.2.0.1.0-Production StartDate15-OCT-201623:30:09 Uptime0days0hr.0min.1sec TraceLeveloff SecurityON:LocalOSAuthentication SNMPOFF ListenerLogFile/u01/app/oracle/diag/tnslsnr/hm/listener/alert/log.xml ListeningEndpointsSummary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hm)(PORT=1521))) Thelistenersupportsnoservices Thecommandcompletedsuccessfully
[oracle@hm ~]$ dbca
安装完成检查,查看oracle进程与监听状态
[oracle@hm~]$ps-ef|grepora_ oracle66361023:41?00:00:00ora_pmon_orcl oracle66381023:41?00:00:04ora_vktm_orcl oracle66421023:41?00:00:00ora_gen0_orcl oracle66441023:41?00:00:00ora_diag_orcl oracle66461023:41?00:00:00ora_dbrm_orcl oracle66481023:41?00:00:00ora_psp0_orcl oracle66501023:41?00:00:05ora_dia0_orcl oracle66521023:41?00:00:00ora_mman_orcl oracle66541023:41?00:00:00ora_dbw0_orcl oracle66561023:41?00:00:00ora_lgwr_orcl oracle66581023:41?00:00:00ora_ckpt_orcl oracle66601023:41?00:00:00ora_smon_orcl oracle66621023:41?00:00:00ora_reco_orcl oracle66641023:41?00:00:02ora_mmon_orcl oracle66661023:41?00:00:02ora_mmnl_orcl oracle66681023:41?00:00:00ora_d000_orcl oracle66701023:41?00:00:00ora_s000_orcl oracle67191023:41?00:00:00ora_qmnc_orcl oracle67391023:41?00:00:01ora_cjq0_orcl oracle68321023:41?00:00:00ora_q000_orcl oracle68341023:41?00:00:00ora_q001_orcl oracle68421023:42?00:00:00ora_smco_orcl oracle68441023:42?00:00:00ora_w000_orcl oracle158582208023:59pts/000:00:00grepora_ [oracle@hm~]$lsnrctlstatus LSNRCTLforLinux:Version11.2.0.1.0-Productionon15-OCT-201623:59:58 Copyright(c)1991,Oracle.Allrightsreserved. Connectingto(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUSoftheLISTENER ------------------------ AliasLISTENER VersionTNSLSNRforLinux:Version11.2.0.1.0-Production StartDate15-OCT-201623:30:09 Uptime0days0hr.29min.50sec TraceLeveloff SecurityON:LocalOSAuthentication SNMPOFF ListenerLogFile/u01/app/oracle/diag/tnslsnr/hm/listener/alert/log.xml ListeningEndpointsSummary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hm)(PORT=1521))) ServicesSummary... Service"orcl"has1instance(s). Instance"orcl",statusREADY,has1handler(s)forthisservice... Service"orclXDB"has1instance(s). Instance"orcl",has1handler(s)forthisservice... Thecommandcompletedsuccessfully
登录oracle数据库,查看数据库实例状态、实例名、数据库文件、日志文件
sql>selectstatusfromv$instance; STATUS ------------ OPEN sql>selectnamefromv$database; NAME --------- ORCL sql>selectnamefromv$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/orcl/users01.dbf sql>selectmemberfromv$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/redo03.log /u01/app/oracle/oradata/orcl/redo02.log /u01/app/oracle/oradata/orcl/redo01.log
查看oracle数据库版本
sql>select*fromv$version; BANNER -------------------------------------------------------------------------------- OracleDatabase11gEnterpriseEditionRelease11.2.0.1.0-64bitProduction PL/sqlRelease11.2.0.1.0-Production CORE11.2.0.1.0Production TNSforLinux:Version11.2.0.1.0-Production NLSRTLVersion11.2.0.1.0-Production
关闭与启动
sql>shutdownimmediate; Databaseclosed. Databasedismounted. ORACLEinstanceshutdown.
关闭监听
[oracle@hm~]$lsnrctlstop LSNRCTLforLinux:Version11.2.0.1.0-Productionon16-OCT-201600:16:41 Copyright(c)1991,Oracle.Allrightsreserved. Connectingto(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) Thecommandcompletedsuccessfully [oracle@hm~]$ps-ef|grepora_ oracle169872208000:17pts/000:00:00grepora_
启动监听
[oracle@hm~]$lsnrctlstart
启动实例
[oracle@hm~]$sqlplus/assysdba sql*Plus:Release11.2.0.1.0ProductiononSunOct1600:19:392016 Copyright(c)1982,Oracle.Allrightsreserved. Connectedtoanidleinstance. sql>startup; ORACLEinstancestarted. TotalSystemGlobalArea780824576bytes FixedSize2217424bytes VariableSize599788080bytes DatabaseBuffers171966464bytes RedoBuffers6852608bytes Databasemounted. DatabaSEOpened. sql>selectstatusfromv$instance; STATUS ------------ OPEN原文链接:https://www.f2er.com/centos/380355.html