Linux下的啟動oracle服務 啟動監聽 開放端口操作


嘗試登錄oracle
使用root用戶將沒有sqlplus命令
[root@localhost ~]# sqlplus /nolog
bash: sqlplus: 未找到命令...
 
 
[root@localhost ~]# su oracle
[oracle@localhost root]$ sqlplus /nolog
bash: sqlplus: 未找到命令...
 
 
切換為oracle賬戶嘗試登錄oracle 此處的/和as之間要有空格 而且只有用oracle賬戶登錄才能生效 否則會提示輸入賬號密碼。
[oracle@localhost ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.1.0 Production on Fri May 26 22:56:08 2017
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
Connected to an idle instance.
 
發現oracle沒有啟動
SQL> select 1 from dual;
select 1 from dual
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
 
啟動oracle
SQL> startup
ORACLE instance started.
 
Total System Global Area  839282688 bytes
Fixed Size    2217992 bytes
Variable Size  494929912 bytes
Database Buffers  335544320 bytes
Redo Buffers    6590464 bytes
Database mounted.
Database opened.
SQL> select 1 from dual;
 
1
----------
1
 
查看開放的端口沒有1521
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ nmap 127.0.0.1
 
Starting Nmap 6.40 ( http://nmap.org ) at 2017-05-26 22:57 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0011s latency).
Not shown: 996 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
25/tcp  open  smtp
111/tcp open  rpcbind
631/tcp open  ipp
 
Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
 
查看oracle監聽的狀態發現監聽沒有開啟
[oracle@localhost ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-MAY-2017 22:58:03
 
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
 
開啟監聽
[oracle@localhost ~]$ lsnrctl start  
 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-MAY-2017 22:58:11
 
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 
Starting /u01/oracle/bin/tnslsnr: please wait...
 
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/oracle/network/admin/listener.ora
Log messages written to /u01/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                26-MAY-2017 22:58:11
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/network/admin/listener.ora
Listener Log File         /u01/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
 
再次查看端口已經有了1521
[root@localhost oracle]# nmap 127.0.0.1
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000043s latency).
Not shown: 995 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
111/tcp  open  rpcbind
631/tcp  open  ipp
1521/tcp open  oracle
 
但是在虛擬機外部仍然無法聯通,telnet 1521端口失敗,懷疑是防火牆,然后修改防火牆的配置文件解決。修改防火牆參考:http://blog.csdn.net/barryxt/article/details/18040335
 
 
在修改防火牆配置的時候,發現了一個問題。即使在/etc/sysconfig/iptables里配置了防火牆規則,在系統啟動的時候是不生效的,要執行重啟命令service iptables restart才能生效,否則讀取的不是/etc/sysconfig/iptables的配置,而是系統的默認配置,如下:

 

此時是默認化配置吧?只有22.

[root@localhost oracle]#  iptables -nL
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
INPUT_direct  all  --  0.0.0.0/0            0.0.0.0/0          
INPUT_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0          
INPUT_ZONES  all  --  0.0.0.0/0            0.0.0.0/0          
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0          
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
FORWARD_direct  all  --  0.0.0.0/0            0.0.0.0/0          
FORWARD_IN_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0          
FORWARD_IN_ZONES  all  --  0.0.0.0/0            0.0.0.0/0          
FORWARD_OUT_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0          
FORWARD_OUT_ZONES  all  --  0.0.0.0/0            0.0.0.0/0          
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0          
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        
OUTPUT_direct  all  --  0.0.0.0/0            0.0.0.0/0          

Chain FORWARD_IN_ZONES (1 references)
target     prot opt source               destination        
FWDI_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]
FWDI_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]

Chain FORWARD_IN_ZONES_SOURCE (1 references)
target     prot opt source               destination        

Chain FORWARD_OUT_ZONES (1 references)
target     prot opt source               destination        
FWDO_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]
FWDO_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]

Chain FORWARD_OUT_ZONES_SOURCE (1 references)
target     prot opt source               destination        

Chain FORWARD_direct (1 references)
target     prot opt source               destination        

Chain FWDI_public (2 references)
target     prot opt source               destination        
FWDI_public_log  all  --  0.0.0.0/0            0.0.0.0/0          
FWDI_public_deny  all  --  0.0.0.0/0            0.0.0.0/0          
FWDI_public_allow  all  --  0.0.0.0/0            0.0.0.0/0          

Chain FWDI_public_allow (1 references)
target     prot opt source               destination        

Chain FWDI_public_deny (1 references)
target     prot opt source               destination        

Chain FWDI_public_log (1 references)
target     prot opt source               destination        

Chain FWDO_public (2 references)
target     prot opt source               destination        
FWDO_public_log  all  --  0.0.0.0/0            0.0.0.0/0          
FWDO_public_deny  all  --  0.0.0.0/0            0.0.0.0/0          
FWDO_public_allow  all  --  0.0.0.0/0            0.0.0.0/0          

Chain FWDO_public_allow (1 references)
target     prot opt source               destination        

Chain FWDO_public_deny (1 references)
target     prot opt source               destination        

Chain FWDO_public_log (1 references)
target     prot opt source               destination        

Chain INPUT_ZONES (1 references)
target     prot opt source               destination        
IN_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]
IN_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]

Chain INPUT_ZONES_SOURCE (1 references)
target     prot opt source               destination        

Chain INPUT_direct (1 references)
target     prot opt source               destination        

Chain IN_public (2 references)
target     prot opt source               destination        
IN_public_log  all  --  0.0.0.0/0            0.0.0.0/0          
IN_public_deny  all  --  0.0.0.0/0            0.0.0.0/0          
IN_public_allow  all  --  0.0.0.0/0            0.0.0.0/0          

Chain IN_public_allow (1 references)
target     prot opt source               destination        
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22 ctstate NEW

Chain IN_public_deny (1 references)
target     prot opt source               destination        

Chain IN_public_log (1 references)
target     prot opt source               destination        

Chain OUTPUT_direct (1 references)
target     prot opt source               destination        

重啟一下:

[root@localhost oracle]# service iptables restart

此處就是配置文件里的配置了:
Redirecting to /bin/systemctl restart  iptables.service
[root@localhost oracle]#  iptables -n -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0          
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:1521
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM