8.安装完成后续工作
1.防火墙开放1521端口
[root@oel-01 ~]# iptables-I INPUT 1 -p tcp --dport 1521 -j ACCEPT
[root@oel-01 ~]# /etc/rc.d/init.d/iptablessave
Saving firewall rules to/etc/sysconfig/iptables: [ OK ]
[root@oel-01 ~]# services iptables restart
-bash: services: command not found
[root@oel-01 ~]# service iptablesrestart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT:filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_ns
2.配置LISTENER---如安装过程中已经正常配置完成可以不做。
安装完成后,启动LISTENER
[Oracle@oel-01 admin]$ lsnrctl start
输出的最后两句:
The listener supports no services
The command completed successfully
这样启动后远程连接会报错:
oracle ORA-12514:TNS:listener does notcurrently know of service requested in connect descriptor
原因:数据库实例没注册到listener
在listener.ora里面添加了如下内容:--配置为静态监听。
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
)
注:里面的orcl根据你安装的数据库实例名确定,我用此法解决了这个报错。
解决方法二:这个网上看的,我自己没使用,使用第一种就解决了。
这种应该是解决非动态注册问题的,要手动注册实例到listener
登录数据库:
$sqlplus / as sysdba
显示服务名:
SQL>show parameter service_names
强制注册服务:
SQL>alter system register;
查看监听状态:
$lsnrctl status
9.配置数据库开机自启动
安装好Oracle数据库后:执行 dbstart和dbshut会提示:
[oracle@oracle11g ~]$ dbstart
ORACLE_HOME_LISTNER is not SET, unable toauto-start Oracle Net Listener
Usage:/u01/app/oracle/oracle/product/10.2.0/db_1/bin/dbstart ORACLE_HOME
错误原因是:dbstart和dbshut脚本文件中ORACLE_HOME_LISTNER的设置有问题,
分别打开两个文件找到:ORACLE_HOME_LISTNER=$1,(在文件开头,比较好找)修改为
ORACLE_HOME_LISTNER=$ORACLE_HOME
修改后保存退出,问题已解决;
测试:
1.SQLPLUS能否启动,如不能,检查.bash_profile中环境变量 ORACLE_HOME PATH等,按我的方法做就可以。
2.使用SQLPLUS登陆测试
sqlplus / as sysdba
需要解锁SCOTT用户,并配置/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
[oracle@oel-01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File:/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
BYS001 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.212)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys001)
)
)
sqlplus scott/tiger@bys001
sqlplusscott/tiger@192.168.1.212:1521/bys001
3.正常情况下数据库实例未启动,此时用SYS登陆,启动数据库,看数据库能否启动
4.实现开机ORACLE自动启动监听和实例
第一步:修改/etc/oratab文件,命令如下:
格式如下:
--------------------------------------------------------------------------------
SID:ORACLE_HOME:AUTO
--------------------------------------------------------------------------------
[oracle@oracle11g ~]$ vi /etc/oratab
添加或修改成(默认好像是N)这一句:
bys001:/u01/app/oracle/product/11.2.0/dbhome_1/:Y
[root@oel-01 ~]# cat /etc/oratab
bys001:/u01/app/oracle/product/11.2.0/dbhome_1:Y
第二步:把lsnrctl start和dbstart添加到rc.local文件中,命令如下:
[oracle@oracle11g ~]$ vi /etc/rc.d/rc.local
添加如下内容:
su oracle -lc"/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"
su oracle -lc"/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart"
[root@oel-01 ~]# cat /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* allthe other init scripts.
# You can put your own initialization stuffin here if you don't
# want to do the full Sys V style initstuff.
touch /var/lock/subsys/local
su oracle -lc"/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"
su oracle -lc "/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart"
第三步,重启后直接用SQLPLUS登陆测试数据库是否已经打开哈哈。
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
