系统要求:
内存:1G(官方最低要求1G)
硬盘:40G(企业版安装所需4.29G和1.7G数据文件)
检查的命令
内存
# grep MemTotal /proc/meminfo
交换空间
# grep SwapTotal /proc/meminfo
磁盘空间
# df -ah
安装前系统准备:
1、修改主机名
# sed -i "s/HOSTNAME=localhost.localdomain/HOSTNAME=DB_2/g" /etc/sysconfig/network
# hostname DB_2
2、添加主机名与IP对应记录
#vi /etc/hosts
10.10.0.48 DB_2
3、关闭Selinux
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/"/etc/selinux/config
# setenforce 0
创建用户和组(root用户:创建Oracle安装组oinstall,数据库管理员组dba,及oracle用户):
# groupadd-g 200 oinstall
# groupadd -g 201 dba
# useradd -u 440 -g oinstall -G dba oracle (主组oinstall,其它组:dba)
# passwd oracle #(P)
修改内核参数(root用户:修改 /etc/sysctl.conf 文件,加上如下参数):
#vi/etc/sysctl.conf #末尾添加如下
net.ipv4.ip_local_port_range= 9000 65500
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100128
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=1048576
fs.aio-max-nr = 1048576
# sysctl -p #使配置生效
修改系统资源限制(root用户:修改 /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 soft stack 10240
修改用户验证选项(root用户下:修改/etc/pam.d/login文件加上如下参数):
# vi /etc/pam.d/login
session required pam_namespace.so #下面添加一条pam_limits.so
session required pam_limits.so
修改用户配置文件(root用户下:修改/etc/profile文件加入如下参数):
# vi/etc/profile #(如果做了第6步的limits.conf设置,这个设置就不需要了)
if [ $USER ="oracle" ]; then
if [ $SHELL = "/bin/ksh" ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
创建安装目录及设置权限:
# mkdir -p /opt/app/oracle/
# chmod 755 /opt/app/oracle/
# chown oracle.oinstall -R /opt/app/oracle/
设置oracle环境变量:
使用oracle账户
#su - oracle
$ vi ~/.bash_profile
#设置oracle
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
#export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=ora11g
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
保存退出
source ~/.bash_profile
完成后执行:
$ env | grep ORA #查看环境变量是否完成
$ env | grep ORA
ORACLE_BASE=/opt/app/oracle
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
安装Oracle:
1、安装依赖包
# yum -y install gcc gcc-c++ make binutilscompat-libstdc++-33 elfutils-libelf elfutils-libelf-develglibc glibc-commonglibc-devel libaio libaio-devel libgcclibstdc++libstdc++-devel unixODBC unixODBC-devel ksh
或
# yum -y installbinutils compat-libstdc++-33 compat-libstdc++-33.i686
elfutils-libelfelfutils-libelf-devel gcc gcc-c++ glibc glibc.i686 glibc-common
glibc-devel glibc-devel.i686glibc-headers ksh libaio libaio.i686 libaio-devel
libaio-devel.i686 libgcclibgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel make
sysstat unixODBC unixODBC-devel
2、 解压oracle
# unzip linux.x64_11gR2_database_1of2.zip
# unzip linux.x64_11gR2_database_1of2.zip
3、图形界面安装(略,通常的生产环境是不安装图形界面的)
# xhost + #使所有用户都能访问图形桌面
# su �oracle
#.~/database/runInstaller
输入接受一些安全问题的邮件地址
4、字符界面下安装oracle
在/opt目录下 解压oracle软件
$ unzip linux.x64_11gR2_database_1of2.zip
$ unzip linux.x64_11gR2_database_2of2.zip
解压后得到database目录,其中包含response目录,该目录中有三个rsp文件,用来作为静默安装时的应答文件的模板。
三个文件作用分别是:
db_install.rsp:安装应答
dbca.rsp: 创建数据库应答
netca.rsp:建立监听、本地服务名等网络设置的应答
将db_install.rsp备份一份,在其基础上修改内容, 将create database段中内容设置好即可。
修改静默安装的配置文件
$ less/opt/database/response/db_install.rsp |grep -v "#"|grep -v"^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=DB_m2
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/opt/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=ora11g
oracle.install.db.config.starterdb.SID=ora11g
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1500
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.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
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=
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 //一定要设为true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
开始静默安装:
以oracle用户身份登录系统安装Oracle,为避免出现中文乱码,装装前可以执行export LANG="",显示英文,
[root@DB_m2database]# su - oracle
[oracle@DB_m2~]$ cd /opt
[oracle@DB_m2opt]$ cd database/
[oracle@DB_m2opt]$ export LANG=""
[oracle@DB_m2 opt]$ ./runInstaller-silent -force -responseFile /home/oracle/etc/db_install.rsp
如果出现:
$ Exception in thread "main" java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at java.awt.Toolkit$2.run(Toolkit.java:821) ...
这些错误提示,可能是环境变量还没有完全变为oracle下的,那么最好断开与主机的连接,然后重新使用oracle身份连接:ssh [email protected];
如果出现:
Preparing to launch Oracle Universal Installer from/tmp/OraInstall2015-07-29_03-58-41PM. Please wait ... [oracle@localhost database]$You can find the log ofthis install session at: //则表示安装顺利
如果出现:
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-07-29_03-58-41PM. Please wait ... [oracle@localhost database]$ //之后就没有反应
或者报错[FATAL] [INS-13013] Target environment do not meet some mandatoryrequirements
则需要按下面步骤进行:
安装命令中加入选项-ignorePrereq,详情请见
安装中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了。
大约需要五分钟左右......
如果需要查看安装日志信息了解安装进度,可以:
cd $ORACLE_BASE/oraInventory/logs
tail -100f installActions*.log
加上-ignorePrereq,再次尝试静默安装:
[oracle@DB_m2database]$ ./runInstaller -silent -force -ignorePrereq -responseFile/opt/database/response/db_install.rsp
说明:
-silent 必须要有
-ignorePrereq 如果哪块没有符合要求,不添加可能就安装不过去了
-force 软件可以安装在一个非空目录中
-responseFile 指定响应文件
StartingOracle Universal Installer...
CheckingTemp space: must be greater than 120 MB. Actual 6843 MB Passed
Checkingswap space: must be greater than 150 MB. Actual 929 MB Passed
Preparingto launch Oracle Universal Installer from /tmp/OraInstall2016-03-06_02-24-49PM.Please wait ...[oracle@DB_m2 database]$ You can find the log of this installsession at:
/opt/app/oracle/oraInventory/logs/installActions2016-03-06_02-24-49PM.log
Thefollowing configuration scripts need to be executed as the "root"user.
#!/bin/sh
#Root scripts to run
/opt/app/oracle/product/11.2.0/db_1/root.sh
Toexecute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit"Enter" key to continue
SuccessfullySetup Software.
安装完毕后会提示上述的信息,整个执行过程大部分时间都是在后台完成的,而且可能等待好一会儿才会有响应,所以需要耐心等待,通过监控/opt/app/oracle目录的大小可以确定完成的情况,按照以上的配置完成安装后/opt/app/oracle目录的大小为4.1GB左右。
在最后会提示执行root.sh脚本,在新的会话窗口执行root.sh脚本,使用root用户执行root.sh:
[root@DB_m2 ~]#/opt/app/oracle/product/11.2.0/db_1/root.sh
Check/opt/app/oracle/product/11.2.0/db_1/install/root_DB_m2_2016-03-06_14-49-29.logfor the output of root script
执行结果也是没有前台显示出来。
配置监听程序:
$ORACLE_HOME/bin/netca /silent/responseFile /opt/database/response/netca.rsp
可能会出现以下错误:
UnsatisfiedLinkError excepti native library: njni11
java.lang.UnsatisfiedLinkError:/soft/u01/app/oracle/product/11.2.0/db_1/lib/libnjni11.so: libclntsh.so.11.1: cannot open shared objectfile: No such file or directory
可能是有些oracle依赖包没有安装:
检查以下RPM包是否安装(官方推荐必装包):
binutils-2.20.51.0.2-5.11.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6.i686
gcc-4.4.4-13.el6 (x86_64)
gcc-c++-4.4.4-13.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6.i686 ksh
libgcc-4.4.4-13.el6 (i686)
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6.i686
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6.i686
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6.i686
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6.i686
make-3.81-19.el6
sysstat-9.0.4-11.el6 (x86_64)
使用rpm -qa|grep XX 查看是否安这些依赖包,这些依赖包缺一不可
yum -y install binutils compat-libstdc++-33compat-libstdc++-33.i686 elfutils-libelf elfutils-libelf-devel gcc gcc-c++glibc glibc.i686 glibc-common glibc-devel glibc-devel.i686 glibc-headers ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++libstdc++.i686 libstdc++-devel make sysstat unixODBC unixODBC-devel
如果没有直接在google搜索,下载对应版本就可以了
最后别忘了:
$ORACLE_HOME/bin/relink all
然后重新执行网络配置
[oracle@DB_m2 database]$ $ORACLE_HOME/bin/netca/silent /responseFile /opt/database/response/netca.rsp
Parsing command line arguments:
Parameter "silent" =true
Parameter"responsefile" = /opt/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/opt/app/oracle/product/11.2.0/db_1/bin/lsnrctlstart LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
启动监听程序:
$ /opt/app/oracle/product/11.2.0/db_1/bin/lsnrctlstart LISTENER
或$ORACLE_BASE//opt/app/oracle/product/11.2.0/db_1/bin/lsnrctlstart LISTENER
[oracle@DB_m2database]$ /opt/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
LSNRCTLfor Linux: Version 11.2.0.1.0 - Production on 06-MAR-2016 15:18:49
Copyright(c) 1991, 2009, Oracle. All rightsreserved.
Starting/opt/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNRfor Linux: Version 11.2.0.1.0 - Production
Systemparameter file is /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Logmessages written to /opt/app/oracle/diag/tnslsnr/DB_m2/listener/alert/log.xml
Listeningon: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listeningon: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB_m2)(PORT=1521)))
Connectingto (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS ofthe LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version11.2.0.1.0 - Production
StartDate 06-MAR-2016 15:18:51
Uptime 0 days 0 hr. 0 min. 0 sec
TraceLevel off
Security ON: Local OS Authentication
SNMP OFF
ListenerParameter File /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
ListenerLog File /opt/app/oracle/diag/tnslsnr/DB_m2/listener/alert/log.xml
ListeningEndpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB_m2)(PORT=1521)))
Thelistener supports no services
Thecommand completed successfully
启动成功
静默dbca建库:
[oracle@DB_m2~]# vi /opt/database/response/dbca.rsp
GDBNAME = " ora11g.DB_m2" //78行全局数据库的名字=SID+主机域名
SID = "ora11g" //149行 SID
CHARACTERSET = "AL32UTF8" //415行编码
NATIONALCHARACTERSET= "UTF8" //425行编码
SYSPASSWORD="sys" //190行 密码可自己设置
SYSTEMPASSWORE="system" //200行 密码可自己设置
[oracle@DB_m2 database]$ $ORACLE_HOME/bin/dbca -silent -responseFile /opt/database/response/dbca.rsp
EnterSYSTEM user password:
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
Copyingdatabase files
1%complete
3%complete
11%complete
18%complete
26%complete
37%complete
Creatingand starting Oracle instance
40%complete
45%complete
50%complete
55%complete
56%complete
60%complete
62%complete
CompletingDatabase Creation
66%complete
70%complete
73%complete
85%complete
96%complete
100%complete
Look atthe log file "/opt/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log" forfurther details.
建库后实例检查:
ps -ef | grep ora_ | grep -v grep| wc -l
21
[oracle@DB_m2 database]$ ps -ef | grep ora_ |grep -v grep
oracle 15924 1 0 15:50 ? 00:00:00 ora_pmon_ora11g
oracle 15926 1 0 15:50 ? 00:00:01 ora_vktm_ora11g
oracle 15930 1 0 15:50 ? 00:00:00 ora_gen0_ora11g
oracle 15932 1 0 15:50 ? 00:00:00 ora_diag_ora11g
oracle 15934 1 0 15:50 ? 00:00:00 ora_dbrm_ora11g
oracle 15936 1 0 15:50 ? 00:00:00 ora_psp0_ora11g
oracle 15938 1 0 15:50 ? 00:00:00 ora_dia0_ora11g
oracle 15940 1 0 15:50 ? 00:00:00 ora_mman_ora11g
oracle 15942 1 0 15:50 ? 00:00:00 ora_dbw0_ora11g
oracle 15944 1 0 15:50 ? 00:00:00 ora_lgwr_ora11g
oracle 15946 1 0 15:50 ? 00:00:00 ora_ckpt_ora11g
oracle 15948 1 0 15:50 ? 00:00:00 ora_smon_ora11g
oracle 15950 1 0 15:50 ? 00:00:00 ora_reco_ora11g
oracle 15952 1 0 15:50 ? 00:00:00 ora_mmon_ora11g
oracle 15954 1 0 15:50 ? 00:00:00 ora_mmnl_ora11g
oracle 15956 1 0 15:50 ? 00:00:00 ora_d000_ora11g
oracle 15958 1 0 15:50 ? 00:00:00 ora_s000_ora11g
oracle 15966 1 0 15:50 ? 00:00:00 ora_qmnc_ora11g
oracle 15980 1 0 15:50 ? 00:00:00 ora_cjq0_ora11g
oracle 15982 1 0 15:50 ? 00:00:00 ora_q000_ora11g
oracle 15984 1 0 15:50 ? 00:00:00 ora_q001_ora11g
建库后监听检查:
lsnrctl status
[oracle@DB_m2 database]$ lsnrctl status
LSNRCTL for Linux: Version11.2.0.1.0 - Production on 06-MAR-2016 15:55:31
Copyright (c) 1991, 2009,Oracle. All rights reserved.
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version11.2.0.1.0 - Production
Start Date 06-MAR-2016 15:36:22
Uptime 0 days 0 hr. 19 min. 8 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/app/oracle/diag/tnslsnr/DB_m2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB_m2)(PORT=1521)))
Services Summary...
Service "ora11g.DB_m2"has 1 instance(s).
Instance "ora11g", status READY, has 1 handler(s) for thisservice...
Service"ora11gXDB.DB_m2" has 1 instance(s).
Instance "ora11g", status READY, has 1 handler(s) for thisservice...
The command completedsuccessfully
如果出现以下错误:
lsnrctl: error while loading shared libraries:/u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1: cannotrestoresegment prot after reloc: Permission denied
或者
ORA-12547: TNS:lost contact
解决办法:在root用户下执行以下命令
su - root
setenforce 0 不需要重启
修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,需要重启
注意:如果在没有将依赖包全部安装完成后强行安装数据库,那么登录数据库时将会出现:ORA-12547: TNS:lost contact错误,出现这个错误,就重新安装吧
修改oracle启动配置文件:
su - oracle
vi /etc/oratab
orcl:/soft/u01/app/oracle/product/11.2.0/db_1:Y //把“N”改成“Y”
这样就可以通过dbstart 启动此实例,监听器。
dbstart $ORACLE_HOME
此时所有oracle的进程关闭,监听器也停止。
dbshut $ORACLE_HOME
再次查看监听器状态。
lsnrctl status
启动数据库:
$ sqlplus / as sysdba //as前有个空格
[oracle@DB_m2 database]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 616:22:55 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:netservice name is incorrectly specified
Enter user-name:
登录出现以上错误,诡异的故障背后的原因竟然是那样的基础:ORACLE_SID没有指定!
确认系统当前的ORACLE_HOME和ORACLE_SID环境变量
[oracle@DB_m2 database]$ echo$ORACLE_HOME
/opt/app/oracle/product/11.2.0/db_1
[oracle@DB_m2 database]$ echo$ORACLE_SID
[oracle@DB_m2 database]$
可见,此时只设置了ORACLE_HOME环境变量,但ORACLE_SID此时为空,这就是该问题的真实原因。
解决方法如下:
[oracle@DB_m2 database]$ cd
[oracle@DB_m2 ~]$ pwd
/home/oracle
[oracle@DB_m2 ~]$ vi .bash
.bash_history .bash_profile
.bash_logout .bashrc
[oracle@DB_m2 ~]$ vi .bash_
.bash_history .bash_logout .bash_profile
[oracle@DB_m2 ~]$ vi .bash_profile
在最后面加入如下内容:
export ORACLE_SID=ora11g 后保存退出!
[oracle@DB_m2 ~]$ source.bash_profile
[oracle@DB_m2 ~]$ echo $ORACLE_SID
ora11g
[oracle@DB_m2 ~]$ sqlplus / assysdba
SQL*Plus: Release 11.2.0.1.0Production on Sun Mar 6 16:31:46 2016
Copyright (c) 1982, 2009,Oracle. All rights reserved.
Connected to:
Oracle Database 11g EnterpriseEdition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, DataMining and Real Application Testing options
SQL>start
SQL>startup
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 113249288 bytes
Database Buffers 184549376 bytes
Redo Buffers 4796416 bytes
Database mounted.
Database opened.
SQL>
使用show parameter;或者select table_name from dba_tables;看看是否正常
启动监听:lsnrctl start
查看监听:lsnrctl status
停止监听:lsnrctl stop
报错排除:
[oracle@oracledb database]$./runInstaller -silent -force -responseFile/opt/database/response/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must begreater than 120 MB. Actual 161383 MB Passed
Checking swap space: must be greater than 150 MB. Actual 16383MB Passed
Preparing to launch Oracle Universal Installer from/tmp/OraInstall2015-01-26_01-34-45PM. Please wait ...[oracle@oracledbdatabase]$ [FATAL] [INS-32012] Unable to create directory.
CAUSE: Either proper permissions were not granted to create thedirectory or there was no space left in the volume.
ACTION: Check your permission on the selected directory or choose anotherdirectory.
[FATAL] [INS-32012] Unable to create directory.
CAUSE: Either proper permissions were not granted to create thedirectory or there was no space left in the volume.
ACTION: Check your permission on the selected directory or chooseanother directory.
error
[oracle@oracledb database]$./runInstaller -silent -force -responseFile/opt/database/response/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must begreater than 120 MB. Actual 165989 MB Passed
Checking swap space: must be greater than 150 MB. Actual 16383MB Passed
Preparing to launch Oracle Universal Installer from/tmp/OraInstall2015-01-26_03-18-11PM. Please wait ...[oracle@oracledbdatabase]$ [FATAL] [INS-32015] The location specified for Oracle home Locationis invalid.
CAUSE: The specified location cannot be used for Oracle homeLocation. Either the specified location is not found on the system or isdetected to be a file.
ACTION: Specify a valid location for Oracle home Location.
[WARNING] [INS-32018] The selected Oracle home is outside of Oracle base.
CAUSE: The Oracle home selected was outside of Oracle base.
ACTION: Oracle recommends installing Oracle software within theOracle base directory. Adjust the Oracle home or Oracle base accordingly.
[FATAL] [INS-32021] Insufficient disk space on this volume for the selectedOracle home.
CAUSE: The selected Oracle home was on a volume without enoughdisk space.
ACTION: Choose a location for Oracle home that has enough space(minimum of 4,397MB) or free up space on the existing volume.
解决办法:
检查了环境变量$ORACLE_BASE和$ORACLE_HOME发现两个路径均正常,没有发现任何异常
逐步从头排查,发现在文件./response/db_install.rsp中INVENTORY_LOCATION、ORACLE_BASE和ORACLE_HOME三个字段被配置成了相对路径
umask 022
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=ora11g
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=$ORACLE_HOME/bin :$PATH:$HOME/bin
[oracle@oracledb database]$./runInstaller -silent -force -responseFile/opt/database/response/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must begreater than 120 MB. Actual 165989 MB Passed
Checking swap space: must be greater than 150 MB. Actual 16383MB Passed
Preparing to launch Oracle Universal Installer from/tmp/OraInstall2015-01-26_05-56-45PM. Please wait ...[oracle@oracledbdatabase]$ [FATAL] [INS-32015] The location specified for Oracle home Locationis invalid.
CAUSE: The specified location cannot be used for Oracle homeLocation. Either the specified location is not found on the system or isdetected to be a file.
ACTION: Specify a valid location for Oracle home Location.
[WARNING] [INS-32018] The selected Oracle home is outside of Oracle base.
CAUSE: The Oracle home selected was outside of Oracle base.
ACTION: Oracle recommends installing Oracle software within theOracle base directory. Adjust the Oracle home or Oracle base accordingly.
[FATAL] [INS-32021] Insufficient disk space on this volume for the selectedOracle home.
CAUSE: The selected Oracle home was on a volume without enoughdisk space.
ACTION: Choose a location for Oracle home that has enough space(minimum of 4,397MB) or free up space on the existing volume.
A log of this session is currently saved as:/tmp/OraInstall2015-01-26_05-56-45PM/installActions2015-01-26_05-56-45PM.log.Oracle recommends that if you want to keep this log, you should move it fromthe temporary location to a more permanent location.
解决方法
1.检查了环境变量$ORACLE_BASE和$ORACLE_HOME发现两个路径均正常,没有异常
2.查看./response/db_install.rsp文件
中INVENTORY_LOCATION、ORACLE_BASE和ORACLE_HOME三个字段被配置成了相对路径了,应该配置如下:
[oracle@oracledb ~]$ less /opt/database/response/db_install.rsp |grep-v "#"|grep -v "^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=DB_m2
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/opt/app/oracle
$ sqlplus / as sysdba 报错如下:
[oracle@oracledb ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 16 14:21:24 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
*****解决办法
[oracle@oracledb ~]$ echo $ORACLE_HOME
/opt/app/oracle/product/11.2.0/db_1
[oracle@oracledb ~]$ echo $ORACLE_SID
oracle_SID 为空
添加SID
[oracle@oracledb ~]$ export ORACLE_SID=ora11g
确认添加成功
[oracle@oracledb ~]$ echo $ORACLE_SID
ora11g
测试是否启动
[oracle@oracledb~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0Production on Mon Feb 16 14:26:57 2015
Copyright (c) 1982, 2009,Oracle. All rights reserved.
Connected to an idle instance.
SQL> start
SP2-1506: START, @ or @@ command has no arguments
SQL> startup
ORACLE instance started.
Total System Global Area3290345472 bytes
FixedSize 2217832 bytes
Variable Size 1795164312 bytes
Database Buffers 1476395008bytes
RedoBuffers 16568320 bytes
Database mounted.
Database opened.
SQL>
正常,问题得到解决
还可以将ORACLE_SID等环境变量写入到系统profile中,但需要确保系统profile文件内容的有效
修改linux数据库字符集以及客户端相关问题:
如果linux能够利用sqlplus / as sysdba 显示SQL> 表示数据库已经安装成功,但是由于安装的时候使用的是 AL32UTF8需要改为ZHS16GBK
SQL> conn /as sysdba (sqlplus / assysdba)
SQL> shutdown immediate; (如果无反应 shutdown abort)
SQL> startup mount
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;
SQL> alter database open;
SQL> ALTER DATABASE CHARACTER SET AL32UTF8;
ORA-12712: new character set must be a superset of old character set
提示我们的字符集:新字符集必须为旧字符集的超集,这时我们可以跳过超集的检查做更改:
SQL> ALTER DATABASE character set INTERNAL_USE AL32UTF8;
--我们看到这个过程和之前ALTER DATABASE CHARACTER SET操作的内部过程是完全相同的,也就是说 INTERNAL_USE提供的帮助就是使Oracle数据库绕过了子集与超集的校验.
SQL> shutdown immediate;
SQL> startup
以后安装oracle的时候记得选择自定义安装,把这个字符集的事情事先弄好。
涉及三方面的字符集,
1. oracel server端的字符集;
2. oracle client端的字符集;
3. dmp文件的字符集。
在做数据导入的时候,需要这三个字符集都一致才能正确导入。
查询oracle server端的字符集
SQL> select userenv('language') from dual;
客户端添加环境变量NLS_LANG。
AMERICAN_AMERICA.ZHS16GBK
五、导入数据
六、配置监听
若PLSQL无法远程连接数据库,可修改监听文件,
oracle账户下,修改监听文件/opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
HOST="192.168.118.118" //第8行,HOST默认是主机名,改为本机的ip地址
然后增加以下内容:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = ora11g)
(ORACLE_HOME =/opt/app/oracle/product/11.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBANAME = ora11g)
(ORACLE_HOME =/opt/app/oracle/product/11.2.0/db_1)
(SID_NAME = ora11g)
)
)
oracle账户下,继续修改文件/opt/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
HOST="192.168.118.118" // 第六行,同上将HOST主机名该为本机的IP地址
具体查看listener.ora和tnsnames.ora两个文件。