1. 程式人生 > 其它 >centos7下使用x11遠端帶視窗安裝Oracle

centos7下使用x11遠端帶視窗安裝Oracle

技術標籤:技術

centos7靜默安裝oracle11gR2

文章目錄

目錄

一、檢查硬體要求

1、記憶體要求:

要求:記憶體最小1G,推薦2G或者更高。

#檢視命令,下列是我的記憶體
[[email protected] opt]# grep MemTotal /proc/meminfo
MemTotal:         995924 kB

PS:還有其他硬體要求可以直接去官網(傳送門)檢視,這裡不再敘述。

2、安裝包:

二、環境準備

1、安裝必要的工具

#wget:下載工具;zip:打包工具;unzip:解壓工具
[[email protected] ~]# yum -y install wget zip unzip xterm xorg-x11-xauth
  • PS:如果已經有了就不需重複安裝

2、關閉防火牆

#檢視防火牆狀態
[[email protected] ~]# 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.

#關閉防火牆
[[email protected] ~]# systemctl stop firewalld

#禁用防火牆
[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

#確認防火牆狀態
[[email protected] ~]# 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

[[email protected] ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
[[email protected] ~]# setenforce 0
#檢視Selinux狀態
[[email protected] ~]# /usr/sbin/sestatus -v

4、安裝Oracle依賴包

#通過安裝Oracle YUM 源來安裝所依賴的包
[[email protected] ~]# cd /etc/yum.repos.d 
[[email protected] yum.repos.d]# wget http://public-yum.oracle.com/public-yum-ol7.repo

#匯入RPM-GPG-KEY-oracle
[[email protected] 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安裝環境
[[email protected] yum.repos.d]# yum install oracle-rdbms-server-11gR2-preinstall -y

#安裝完後檢視後臺日誌內容
[[email protected] yum.repos.d]# more /var/log/oracle-rdbms-server-11gR2-preinstall/results/orakernel.log
#離線安裝方式
[[email protected] 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使用者密碼
[[email protected] oracle-rdbms-server-11gR2-preinstall]# passwd oracle
更改使用者 oracle 的密碼 。
新的 密碼:
無效的密碼: 密碼少於 8 個字元
重新輸入新的 密碼:
passwd:所有的身份驗證令牌已經成功更新。

2、用Oracle登入使用者

#重新開啟一個bash切換為Oracle使用者登入系統
[[email protected] ~]$

3、上傳安裝包到伺服器

#上傳安裝包到伺服器
[[email protected] ~]$ 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安裝包

#解壓安裝包
[[email protected] ~]$ unzip linux.x64_11gR2_database_1of2.zip
[[email protected] ~]$ unzip linux.x64_11gR2_database_2of2.zip
[[email protected] ~]$ 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
[[email protected] ~]$

5、配置oracle使用者環境變數

#配置環境變數
[[email protected] ~]$ vim .bash_profile
#立即生效配置檔案
[[email protected] ~]$ 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、執行安裝程式

#執行安裝程式
[[email protected] ~]$ cd database/
[[email protected] 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 ...[[email protected] database]$
#確保安裝x11才能出現視窗

2、反選I wish to receive security updates via My Oracle Support

點選next

1569744199491

4、確定點選yes

1569744234616

5、選擇建立並配置資料庫(create and configure a database)

點選next

1569744241449

6、選擇server class

點選next

1569744247600

7、選擇單例項安裝

點選next

1569744253104

8、可以選擇 典型安裝 也可以選擇 高階安裝

我這裡選擇的是典型安裝

點選next

1569744257569

9、以下是預設生成的安裝路徑,如果不會配置只需配置密碼即可

點選next

1569744274048

密碼不符合規範點選yes即可

1569744293816

預設路徑即可

  • 點選next

1569744301489

10、生成響應檔案

1569744317848

  • 有檢測失敗的忽略即可

1569744360244

  • 勾選 ignore all

1569744374847

  • 可選儲存響應檔案

1569744414528

11、開始安裝顯示安裝進度

1569744420605

#第一個是關於ins_ctx.mk,log顯示:
/lib64/libstdc++.so.5: undefined reference to `[email protected]_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,
[[email protected] 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,
[[email protected] 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即可

1569744874105

  • 繼續安裝

1569744888725

13、如果沒有配置hosts會出現如下錯誤

1569745082872

#只需修改hosts檔案retry即可
[[email protected] 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
  • 繼續安裝

1569745216134

14、接下來會自動建立資料庫

15697452832071569745564001

  • 安裝成功點選ok即可

1569745958600

  • 接下來會出現要你使用root賬戶執行兩個檔案,新開啟一個視窗登入root賬戶執行即可

1569745991431

15、最後點選finish即可

1569746121936

16、檢視監聽狀態

#檢視監聽狀態,監聽安裝完預設是啟動的
[[email protected] 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

#如果監聽沒有啟動,可以通過下列命令啟動
[[email protected] ~]$ 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 監聽程式當前無法識別連線描述符中請求服務

#開啟資料夾
[[email protected] database]$ cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin
[[email protected] admin]$ ls
listener.ora  samples  shrept.lst  shellnet.ora  tnsnames.ora

#修改listener.ora,這是修改前的
[[email protected] 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
[[email protected] 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,這是修改前的
[[email protected] 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)
    )
  )

#修改後的
[[email protected] 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)
    )
  )
  
  #關閉監聽服務,有時候關閉不了,提示沒有許可權操作監聽服務,解決方法下一個問題
  [[email protected] 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

#開啟監聽服務
[[email protected] 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

#登入
[[email protected] 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檔案

[[email protected] ~]# 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服務自啟動指令碼

[[email protected] ~]# 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指令碼的執行許可權

    [[email protected] oracle]# chmod a+x /etc/init.d/oracle

5、檢查指令碼能否執行

    [[email protected] oracle]# /etc/init.d/oracle start            #啟動oracle指令碼
    [[email protected] oracle]# /etc/init.d/oracle stop             #關閉oracle指令碼
    [[email protected] oracle]# /etc/init.d/oracle restart          #重啟oracle指令碼

6、新增執行許可權並建立連結

建立連結將啟動指令碼新增到系統服務並設定自啟動

    [[email protected] 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指令碼的執行級別

[email protected]calhost oracle]# chkconfig --level 2345 oracle on

說明:設定oracle指令碼在執行級別為2、3、4、5時,都是on(開啟)狀態,off為關閉

7、檢視oracle自動啟動設定

[[email protected] oracle]# chkconfig --list oracle
oracle          0:關    1:關    2:開    3:開    4:開    5:開    6:關
#等級0表示:表示關機
#等級1表示:單使用者模式
#等級2表示:無網路連線的多使用者命令列模式
#等級3表示:有網路連線的多使用者命令列模式
#等級4表示:不可用
#等級5表示:帶圖形介面的多使用者模式
#等級6表示:重新啟動

8、手動建立符號連結檔案

  • (執行效果和執行chkconfig --add oracle是一樣,作為知識筆記記錄,可以不執行)
[[email protected] oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc0.d/K61oracle
[[email protected] oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc1.d/K61oracle
[[email protected] oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc2.d/S61oracle
[[email protected] oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc3.d/S61oracle
[[email protected] oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc4.d/S61oracle
[[email protected] oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc5.d/S61oracle
[[email protected] oracle]# ln –s /etc/rc.d/init.d/oracle /etc/rc6.d/K61oracle

9、oracle的啟動或關閉管理

#啟動
[[email protected] oracle]# service oracle start
#停止
[[email protected] oracle]# service oracle stop
#重啟
[[email protected] oracle]# service oracle restart

七、資料庫字符集修改

PS:沒有操作過,從參考文件摘過來的

注意事項:修改字符集前先將資料庫進行備份

此處演示將ZHS16GBK字符集修改為AL32UTF8

1、修改server端字符集

登入shellpus檢視字符集設定

[[email protected] ~]$ 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端字符集)

[[email protected] ~]$ 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,儲存退出
[[email protected] ~]$ vim /home/oracle/.bash_profile
使配置生效
[[email protected] ~]$ 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