[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 #配置IP地址 DEVICE=eth0 HWADDR=00:0C:29:59:6E:BF TYPE=Ethernet ONBOOT=yes BOOTPROTO=no IPADDR=172.16.2.20 NETMASK=255.255.0.0 GATEWAY=172.16.1.1 DNS1=202.106.0.20 [root@localhost ~]# vim /etc/sysconfig/network NETWORKING=yes HOSTNAME=db [root@localhost ~]# vim /etc/hosts #添加域名解析 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 172.16.2.20 db [root@localhost ~]#reboot #重啟系統
第一步:解壓並安裝數據庫 [root@db ~]#tar -jxpvf /home/ora11.2.0.3.8_cluster.tgj -C / #解壓oracle數據庫到根目錄,大C指定文件解壓目錄 第二步:配置數據庫參數
[root@db ~]# su - oracle #切換到oracle用戶 [oracle@db ~]$ sqlplus / as sysdba #進入oracle數據庫 SQL*Plus: Release 11.2.0.3.0 Production on Wed Nov 18 15:40:15 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to an idle instance. SQL> create pfile from spfile; #創建pfile文件(pfile文件的作用是方便計算機可讀,也就是0和1),第一次進入數據庫時均需要創建此文件 File created. SQL> startup #啟動數據庫,若出現以下提示(需要給操作系統預留內存空間,不能讓數據庫獨占內存)請修改initgnnt.ora文件,方法如下 ORA-00845: MEMORY_TARGET not supported on this system SQL> ! #返回到oracle用戶 [oracle@db ~]$ vim /opt/ora11/product/11.2/dbs/initgnnt.ora #修改initgnnt.ora配置文件(大小視物理內存而定,一定不能等於物理內存) .................................................................. *.memory_max_target=8g *.memory_target=8g .................................................................. *.sga_max_size=8g .................................................................. [oracle@db ~]$sqlplus / as sysdba #再次進入oracle數據庫 SQL> create spfile from pfile; #創建spfile文件(spfile文件的作用是讀取pfile文件的內容並更新修改的內容,也就是更新initgnnt.ora配置文件的內容讓計算機可讀) SQL> startup #數據庫打開成功 ORACLE instance started. Total System Global Area 8551575552 bytes Fixed Size 2245480 bytes Variable Size 5066722456 bytes Database Buffers 3472883712 bytes Redo Buffers 9723904 bytes Database mounted. Database opened. SQL>select status from v$instance; #查看數據庫狀態,顯示‘open’代表正常 STATUS ------------ OPEN
第三步:監聽數據庫
SQL>!lsnrctl status 或[oracle@localhost ~]$ lsnrctl status #監聽數據庫,若提示以下內容,請修改listener.ora和tnsnames.ora文件 LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 18-NOV-2015 17:46:36 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) TNS-12541: TNS:no listener TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: 111: Connection refused Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbi)(PORT=1521))) TNS-12545: Connect failed because target host or object does not exist TNS-12560: TNS:protocol adapter error TNS-00515: Connect failed because target host or object does not exist Linux Error: 111: Connection refused SQL>! #返回到oracle用戶 [oracle@localhost admin]$ vim listener.ora # listener.ora Network Configuration File: /opt/ora11/product/11.2/network/admin/listener.ora # Generated by Oracle configuration tools. ......................................................................................... LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521)) #將HOST改為db ) ) [oracle@localhost admin]$ vim tnsnames.ora # tnsnames.ora Network Configuration File: /opt/ora11/product/11.2/network/admin/tnsnames.ora # Generated by Oracle configuration tools. GNNT = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521)) #將HOST改為db (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = gnnt) ) ) SQL>!lsnrctl status #最後一行顯示The command completed successfully,代表監聽成功 LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 18-NOV-2015 17:28:52 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 18-NOV-2015 12:41:04 Uptime 0 days 4 hr. 47 min. 47 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/ora11/product/11.2/network/admin/listener.ora Listener Log File /opt/ora11/diag/tnslsnr/db/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db)(PORT=1521))) Services Summary... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... Service "gnnt" has 2 instance(s). Instance "gnnt", status UNKNOWN, has 1 handler(s) for this service... Instance "gnnt", status READY, has 1 handler(s) for this service... Service "gnntXDB" has 1 instance(s). Instance "gnnt", status READY, has 1 handler(s) for this service... The command completed successfully
第四步:添加自動刪除日志文件腳本
[root@db ~]#su - oracle [oracle@db]$cp /media/linux/deletearchivelogs.sh /media/linux/rman_cmd /home/oracle #/media/linux/代表U盤中的目錄,粘貼的位置為/home/oracle [oracle@db]$chmod +x /home/oracle/deletearchivelogs.sh #給deletearchivelogs.sh文件添加可執行權限 [oracle@db]$ ll /home/oracle 總用量 8 -rwxr-xr-x 1 root root 439 11月 18 16:44 deletearchivelogs.sh -rwxr-xr-x 1 root root 118 11月 18 16:44 rman_cmd [oracle@db]$vim /home/oracle/deletearchivelogs.sh #修改IP地址為本地IP地址 /sbin/ip add show dev bond0 | grep -iq '172.16.2.20' [oracle@db ~]#crontab -e #添加自動刪除日志腳本,如果出現計劃任務無法保存時,則說明時間不同步,只需同步時間即可 0 5 * * * /home/oracle/deletearchivelogs.sh > /dev/null 2>&1 [root@db home]# crontab -l #查看計劃執行任務 0 5 * * * /home/oracle/deletearchivelogs.sh > /dev/null 2>&1
第五步:關閉數據庫 [root@db ~]# su - oracle #切換到oracle用戶 [oracle@db ~]$ sqlplus / as sysdba #進入oracle數據庫 SQL > shutdown immediate; #關閉數據庫 Database closed. Database dismounted. ORACLE instance shut down. 補充: 1、使用history查看之前所使用過的命令。 2、如果發現數據庫每隔一段時間就會重啟,這時候只需要關掉bmc-watchdog服務器 [root@localhost ~]#chkconfig bmc-watcgdog off