centos7靜默安裝oracle11gR2 文章目錄 [TOC] 一、檢查硬體要求 1、記憶體要求: 要求:記憶體最小1G,推薦2G或者更高。 PS:還有其他硬體要求可以直接去官網( "傳送門" )查看,這裡不再敘述。 2、安裝包: linux.x64_11gR2_database_1of2.zip ...
目錄
- centos7靜默安裝oracle11gR2
- 文章目錄
- 一、檢查硬體要求
- 二、環境準備
- 三、安裝前配置
- 四、開始安裝
- 1、運行安裝程式
- 2、反選I wish to receive security updates via My Oracle Support
- 4、確定點擊==yes==
- 5、選擇創建並配置資料庫(create and configure a database)
- 6、選擇server class
- 7、選擇單實例安裝
- 8、可以選擇 典型安裝 也可以選擇 高級安裝
- 9、以下是預設生成的安裝路徑,如果不會配置只需配置密碼即可
- 10、生成響應文件
- 11、開始安裝顯示安裝進度
- 12、如果安裝過程中,在link binaries階段出現2個錯誤
- 13、如果沒有配置==hosts==會出現如下錯誤
- 14、接下來會自動創建資料庫
- 15、最後點擊finish即可
- 16、查看監聽狀態
- 五、安裝及連接遇到的問題解決
- 六、設置資料庫自啟動
- 七、資料庫字元集修改
centos7靜默安裝oracle11gR2
文章目錄
一、檢查硬體要求
1、記憶體要求:
要求:記憶體最小1G,推薦2G或者更高。
#查看命令,下列是我的記憶體
[root@centos7-minimal opt]# grep MemTotal /proc/meminfo
MemTotal: 995924 kB
PS:還有其他硬體要求可以直接去官網(傳送門)查看,這裡不再敘述。
2、安裝包:
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
PS:官方下載地址:傳送門;
https://pan.baidu.com/s/1JsCmtzGlv_QvLBVNxXkDmw
二、環境準備
1、安裝必要的工具
#wget:下載工具;zip:打包工具;unzip:解壓工具
[root@centos7-minimal ~]# yum -y install wget zip unzip xterm xorg-x11-xauth
- PS:如果已經有了就不需重覆安裝
2、關閉防火牆
#查看防火牆狀態
[root@centos7-minimal ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 一 2019-03-04 14:31:15 CST; 4min 32s ago
Docs: man:firewalld(1)
Main PID: 693 (firewalld)
CGroup: /system.slice/firewalld.service
└─693 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
3月 04 14:31:15 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
3月 04 14:31:15 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
#關閉防火牆
[root@centos7-minimal ~]# systemctl stop firewalld
#禁用防火牆
[root@centos7-minimal ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
#確認防火牆狀態
[root@centos7-minimal ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
3月 04 14:31:15 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
3月 04 14:31:15 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
3月 04 14:36:34 centos7-minimal.micserver systemd[1]: Stopping firewalld - dynamic firewall daemon...
3月 04 14:36:35 centos7-minimal.micserver systemd[1]: Stopped firewalld - dynamic firewall daemon.
- PS:不關閉防火牆,遠程連接會提示連接超時,也可以通過開放對應埠如下
firewall-cmd --permanent --zone=public --add-port=1521/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
3、關閉Selinux
[root@centos7-minimal ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
[root@centos7-minimal ~]# setenforce 0
#查看Selinux狀態
[root@centos7-minimal ~]# /usr/sbin/sestatus -v
4、安裝Oracle依賴包
#通過安裝Oracle YUM 源來安裝所依賴的包
[root@centos7-minimal ~]# cd /etc/yum.repos.d
[root@centos7-minimal yum.repos.d]# wget http://public-yum.oracle.com/public-yum-ol7.repo
#導入RPM-GPG-KEY-oracle
[root@centos7-minimal yum.repos.d]# wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
#安裝oracle-rdbms-server-11gR2-preinstall快速配置Oracle安裝環境
[root@centos7-minimal yum.repos.d]# yum install oracle-rdbms-server-11gR2-preinstall -y
#安裝完後查看後臺日誌內容
[root@centos7-minimal yum.repos.d]# more /var/log/oracle-rdbms-server-11gR2-preinstall/results/orakernel.log
#離線安裝方式
[root@centos7-minimal oracle-rdbms-server-11gR2-preinstall]# yum localinstall *.rpm
- PS:#oracle-rdbms-server-11gR2-preinstall包所乾的事情
(1)自動安裝oracle所需的RPM包
(2)自動創建oracle用戶和group組
(3)自動配置/etc/sysctl.conf內核參數
(4)自動配置/etc/security/limits.conf參數
三、安裝前配置
1、修改oracle用戶密碼
#修改oracl用戶密碼
[root@centos7-minimal oracle-rdbms-server-11gR2-preinstall]# passwd oracle
更改用戶 oracle 的密碼 。
新的 密碼:
無效的密碼: 密碼少於 8 個字元
重新輸入新的 密碼:
passwd:所有的身份驗證令牌已經成功更新。
2、用Oracle登錄用戶
#重新打開一個bash切換為Oracle用戶登錄系統
[oracle@centos7-minimal ~]$
3、上傳安裝包到伺服器
#上傳安裝包到伺服器
[oracle@centos7-minimal ~]$ ll
總用量 2295592
-rw-r--r-- 1 oracle oinstall 1239269270 9月 29 15:48 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 oracle oinstall 1111416131 9月 29 15:49 linux.x64_11gR2_database_2of2.zip
4、解壓oracle安裝包
#解壓安裝包
[oracle@centos7-minimal ~]$ unzip linux.x64_11gR2_database_1of2.zip
[oracle@centos7-minimal ~]$ unzip linux.x64_11gR2_database_2of2.zip
[oracle@centos7-minimal ~]$ ll
總用量 2295592
drwxr-xr-x 8 oracle oinstall 128 8月 21 2009 database
-rw-r--r-- 1 oracle oinstall 1239269270 9月 29 15:48 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 oracle oinstall 1111416131 9月 29 15:49 linux.x64_11gR2_database_2of2.zip
[oracle@centos7-minimal ~]$
5、配置oracle用戶環境變數
#配置環境變數
[oracle@centos7-minimal ~]$ vim .bash_profile
#立即生效配置文件
[oracle@centos7-minimal ~]$ source .bash_profile
#增加
export ORACLE_BASE=/home/oracle/app/oracle
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
export LANG=en_US.utf8
四、開始安裝
1、運行安裝程式
#運行安裝程式
[oracle@centos7-minimal ~]$ cd database/
[oracle@centos7-minimal database]$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 11210 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-09-29_04-00-57PM. Please wait ...[oracle@centos7-minimal database]$
#確保全裝x11才能出現視窗
2、反選I wish to receive security updates via My Oracle Support
==點擊next==
4、確定點擊==yes==
5、選擇創建並配置資料庫(create and configure a database)
==點擊next==
6、選擇server class
點擊==next==
7、選擇單實例安裝
點擊==next==
8、可以選擇 典型安裝 也可以選擇 高級安裝
我這裡選擇的是==典型安裝==
點擊==next==
9、以下是預設生成的安裝路徑,如果不會配置只需配置密碼即可
點擊==next==
密碼不符合規範點擊==yes==即可
預設路徑即可
- 點擊==next==
10、生成響應文件
- 有檢測失敗的==忽略==即可
- 勾選 ==ignore all==
- 可選保存==響應文件==
11、開始安裝顯示安裝進度
12、如果安裝過程中,在link binaries階段出現2個錯誤
#第一個是關於ins_ctx.mk,log顯示:
/lib64/libstdc++.so.5: undefined reference to `memcpy@GLIBC_2.14'
#原因據說是由於本機的glibc版本高於2.14(實際為2.17)。解決方法:
yum install glibc-static
#該軟體包包含一個靜態鏈接庫:/usr/lib64/libc.a
#修改/home/oracle/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ins_ctx.mk,
[root@centos7-minimal oracle-rdbms-server-11gR2-preinstall]# vim /home/oracle/app/oracle/product/11.2.0/dbhome_1/ctx/lib/ins_ctx.mk
#將
ctxhx: $(CTXHXOBJ)
$(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK)
#修改為:
ctxhx: $(CTXHXOBJ)
-static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib64/stdc.a
#點擊Retry即可。
#第二個錯誤是”Error in invoking target 'agent nmhs' of makefile'/app/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk.'
#解決方法,在makefile中添加鏈接libnnz11庫的參數:
#修改/home/oracle/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk,
[root@centos7-minimal oracle-rdbms-server-11gR2-preinstall]# vim /home/oracle/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk
#將
$(MK_EMAGENT_NMECTL)
#修改為:
$(MK_EMAGENT_NMECTL) -lnnz11
#點擊Retry即可。
- 按上述修改完相關文件==retry==即可
- 繼續安裝
13、如果沒有配置==hosts==會出現如下錯誤
#只需修改hosts文件retry即可
[root@centos7-minimal oracle-rdbms-server-11gR2-preinstall]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.131.7 centos7-minimal
- 繼續安裝
14、接下來會自動創建資料庫
- 安裝成功點擊==ok==即可
- 接下來會出現要你使用root賬戶執行兩個文件,新打開一個視窗登錄root賬戶執行即可
15、最後點擊finish即可
16、查看監聽狀態
#查看監聽狀態,監聽安裝完預設是啟動的
[oracle@centos7-minimal database]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 29-SEP-2019 16:40:50
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: Version 11.2.0.1.0 - Production
Start Date 29-SEP-2019 16:20:15
Uptime 0 days 0 hr. 20 min. 34 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/centos7-minimal/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.131.7)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
#如果監聽沒有啟動,可以通過下列命令啟動
[oracle@centos7-minimal ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 29-SEP-2019 21:52:32
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/diag/tnslsnr/centos7-minimal/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.131.7)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 29-SEP-2019 21:52:34
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/centos7-minimal/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.131.7)(PORT=1521)))
The listener supports no services
The command completed successfully
五、安裝及連接遇到的問題解決
ORA-12170:TNS:連接超時
查看linux系統的防火牆是否關閉,或者資料庫埠是否開放
firewall-cmd --permanent --zone=public --add-port=1521/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
ORA-12514 TNS 監聽程式當前無法識別連接描述符中請求服務
#打開文件夾
[oracle@centos7-minimal database]$ cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin
[oracle@centos7-minimal admin]$ ls
listener.ora samples shrept.lst shellnet.ora tnsnames.ora
#修改listener.ora,這是修改前的
[oracle@centos7-minimal admin]$ vi listener.ora
# listener.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = centos7-minimal)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /home/oracle/app/oracle
#修改後的,192.168.211.42是我虛擬機的ip
[oracle@centos7-minimal admin]$ cat listener.ora
# listener.ora Network Configuration File:/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = centos7-minimal)(PORT = 1521)))
ADR_BASE_LISTENER = /home/oracle/app/oracle
#修改tnsnames.ora,這是修改前的
[oracle@centos7-minimal admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = centos7-minimal)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
#修改後的
[oracle@centos7-minimal admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = centos7-minimal)(PORT = 1521))
)
(CONNECT_DATA =
(SID = orcl)
)
)
#關閉監聽服務,有時候關閉不了,提示沒有許可權操作監聽服務,解決方法下一個問題
[oracle@centos7-minimal admin]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-MAR-2019 16:25:32
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.211.42)(PORT=1521)))
The command completed successfully
#開啟監聽服務
[oracle@centos7-minimal admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-MAR-2019 16:27:20
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/diag/tnslsnr/centos7-minimal/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.211.42)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.211.42)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 04-MAR-2019 16:27:20
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/centos7-minimal/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.211.42)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
#登入
[oracle@centos7-minimal admin]$ shellplus / as sysdba
shell*Plus: Release 11.2.0.1.0 Production on Mon Mar 4 16:27:54 2019
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
shell>
#立即關閉資料庫服務
shell> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down
#開啟資料庫服務
shell> startup
ORACLE instance started.
Total System Global Area 764121088 bytes
Fixed Size 2217264 bytes
Variable Size 452987600 bytes
Database Buffers 301989888 bytes
Redo Buffers 6926336 bytes
Database mounted.
Database opened.
#註冊
shell> alter system register;
System altered.
PS:一步都不要少,其實對於修改的這兩個文件內容,我猜在配置應答文件的時候配錯了,應該直接將我們修改的這些在配置應答文件就配置到對應的地方,不過沒有實驗,我也是按照別人的博文一步一步來,怕出錯不知道怎麼修改,到此本地window可以連接資料庫了。
- TNS-01190: The user is not authorized to execute the requested listener command
在執行lsnrctl stop 命令時,提示沒有許可權操作監聽服務,原因時當前用戶不是啟動監聽的用戶,切換到啟動監聽服務的用戶下執行lsnrctl stop 命令就可以了,因為啟動監聽服務的用戶擁有所有權,其他用戶不能操作
- 執行lsnrctl stop或者lsnrctl stop,提示lsnrctl: 未找到命令
切換到oracle用戶的時候執行的是 su oracle,正確的是su - oracle
- ORA-01031: insufficient privileges
執行shellplus / as sysdba命令時提示該錯誤,可以先先切換到別的用戶環境下,再切換回來試試。
- 本地window連接沒有問題,但是其他人無法連接
檢查以下是否能ping通,網路用橋接模式,不然別人ping不通,我用的是NAT模式,導致只能本地連接,別人連接不了我虛擬機的資料庫。這種模式下如何ping通我沒有查。
- ora-01950:對錶空間XXX無許可權
在創建表的時候,插入數據提示無許可權
#username 換成沒有許可權的用戶
grant resource to username
六、設置資料庫自啟動
1、使用Oracle用戶修改兩個文件
vim $ORACLE_HOME/bin/dbstart
ORACLE_HOME_LISTNER=$1
#修改為:
ORACLE_HOME_LISTNER=$ORACLE_HOME
vim $ORACLE_HOME/bin/dbshut
ORACLE_HOME_LISTNER=$1
#修改為:
ORACLE_HOME_LISTNER=$ORACLE_HOME
2、修改/etc/oratab文件
[oracle@centos7-minimal ~]# vi /etc/oratab
找到: orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:N
修改為: orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:Y
3、新建Oracle服務自啟動腳本
[oracle@centos7-minimal ~]# vi /etc/init.d/oracle
- 將以下腳本複製到文件中,保存退出
#!/bin/sh
# chkconfig: 2345 61 61
# description: Oracle 11g R2 AutoRun Servimces
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_BASE=/home/oracle/app/oracle #根據個人情況修改路徑
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl #改成自己的ORACLE_SID:testsid
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
echo "Oracle Start Succesful!OK."
;;
stop)
# Oracle listener and instance shutdown
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
echo "Oracle Stop Succesful!OK."
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo $"Usage: `basename $0` {start|stop|restart|reload}"
exit 1
esac
exit 0
4、更改oracle腳本的執行許可權
[root@localhost oracle]# chmod a+x /etc/init.d/oracle
5、檢查腳本能否執行
[root@localhost oracle]# /etc/init.d/oracle start #啟動oracle腳本
[root@localhost oracle]# /etc/init.d/oracle stop #關閉oracle腳本
[root@localhost oracle]# /etc/init.d/oracle restart #重啟oracle腳本
6、添加執行許可權並建立鏈接
建立鏈接將啟動腳本添加到系統服務並設置自啟動
[root@localhost oracle]# chkconfig --add oracle
#ps 找不到命令的系統請安裝chkconfig
yum install chkconfig
ps:當這個命令被執行的時候,會去腳本文件oracle中尋找# chkconfig: 2345 61 61這行註釋,並解析這行註釋,根據解析結果分別在
/etc/rc.d/rc2.d
/etc/rc.d/rc3.d
/etc/rc.d/rc4.d
/etc/rc.d/rc5.d
中創建符號連接文件S61oracle,此文件在系統啟動時根據運行級別執行,此文件是指向/etc/init.d/oracle文件。啟動時系統向此文件發送一個start參數,執行oracle文件中的start分支。另外還會在
/etc/rc.d/rc0.d
/etc/rc.d/rc1.d
/etc/rc.d/rc6.d
中創建符號連接文件K61oracle,此文件在系統關閉時執行,此文件也指向/etc/init.d/oracle文件,關閉時系統向此文件發送一個stop參數,執行oracle文件中的stop分支。
chkconfig: 2345 61 61
表明腳本應該在運行級 2, 3, 4, 5 啟動,啟動優先權為61,停止優先權為 61。
修改服務運行等級(雖然腳本里寫過,但還是重新設置一下),可以自行設置oracle腳本的運行級別
root@localhost oracle]# chkconfig --level 2345 oracle on
說明:設置oracle腳本在運行級別為2、3、4、5時,都是on(開啟)狀態,off為關閉
7、查看oracle自動啟動設置
[root@localhost oracle]# chkconfig --list oracle
oracle 0:關 1:關 2:開 3:開 4:開 5:開 6:關
#等級0表示:表示關機
#等級1表示:單用戶模式
#等級2表示:無網路連接的多用戶命令行模式
#等級3表示:有網路連接的多用戶命令行模式
#等級4表示:不可用
#等級5表示:帶圖形界面的多用戶模式
#等級6表示:重新啟動
8、手動創建符號鏈接文件
- (執行效果和執行chkconfig --add oracle是一樣,作為知識筆記記錄,可以不執行)
[root@localhost oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc0.d/K61oracle
[root@localhost oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc1.d/K61oracle
[root@localhost oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc2.d/S61oracle
[root@localhost oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc3.d/S61oracle
[root@localhost oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc4.d/S61oracle
[root@localhost oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc5.d/S61oracle
[root@localhost oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc6.d/K61oracle
9、oracle的啟動或關閉管理
#啟動
[root@localhost oracle]# service oracle start
#停止
[root@localhost oracle]# service oracle stop
#重啟
[root@localhost oracle]# service oracle restart
七、資料庫字元集修改
PS:沒有操作過,從參考文檔摘過來的
註意事項:修改字元集前先將資料庫進行備份
此處演示將ZHS16GBK字元集修改為AL32UTF8
1、修改server端字元集
登錄shellpus查看字元集設置
[oracle@localhost ~]$ shellplus /nolog
shell*Plus: Release 11.2.0.1.0 Production on Wed Jan 24 13:55:51 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
shell> conn /as sysdba
Connected to an idle instance. #資料庫未啟動,先啟動資料庫。最好將資料庫設未開機啟動
shell> startup
shell> conn /as sysdba
Connected. #連接成功
shell> select userenv('language') from dual; #server端字元集查詢
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
依次執行如下命令
shell>SHUTDOWN IMMEDIATE;
shell>STARTUP MOUNT;
shell>ALTER SYSTEM ENABLE RESTRICTED SESSION;
shell>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
shell>ALTER SYSTEM SET AQ_TM_PROCESSES=0;
shell>ALTER DATABASE OPEN;
shell>ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;
shell>SHUTDOWN IMMEDIATE;
shell>STARTUP;
shell> select userenv('language') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.AL32UTF8
shell>
2、修改client端字元集
查看系統環境變數設置的字元集(client端字元集)
[oracle@localhost ~]$ cat /home/oracle/.bash_profile
...
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/usr/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=C
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #客戶端字元集
進入編輯界面,將ZHS16GBK改為AL32UTF8,保存退出
[oracle@localhost ~]$ vim /home/oracle/.bash_profile
使配置生效
[oracle@localhost ~]$ source /home/oracle/.bash_profile
[參考文檔]
https://docs.oracle.com/cd/E11882_01/install.112/e47689/toc.htm(官網)
https://blog.csdn.net/lqdyx/article/details/78999761
https://www.cnblogs.com/nichoc/p/6417505.html
https://www.cnblogs.com/VoiceOfDreams/p/8308601.html