CentOS 7 安裝 Oracle

1.安裝centos7

  虛擬機配置如下:


   安裝時必須安裝GHOME桌面

   安裝完成後,以root用戶登錄,然後執行

    

#需要聯網
yum update 
yum upgrade

2.安裝java 環境

#查詢出默認安裝java
rpm -qa | grep java
#刪除查詢出結果
rpm -e --nodeps <?>
#安裝java
rpm -ivh  jdk-7u80-linux-x64.rpm
#配置環境變量
vim /etc/profile
#在末尾添加
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_80
JRE_HOME=/usr/java/jdk1.7.0_80/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:/usr/local/mysql/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH


3.安裝 Oracle 11R2 

    首先下載Oracle 11R2 安裝包

linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
  
創建用戶和用戶組
  groupadd oinstall #用戶組
  groupadd dba #用戶組
  useradd -g dba -g oinstall -m oracle #創建用戶oracle,並加入dba,oinstall
  passwd oracle #設置密碼
創建Oracle安裝目錄
  mkdir -p /oracle/oraInventory #oracle 數據庫配置目錄
chown -R oracle:oinstall /oracle #設置目錄所有者爲 oinstall 用戶組的 oracle 用戶
chown -R oracle:oinstall /oracle/oraInventory
修改系統標識
  vim /etc/redhat-release #編輯
  把
CentOS Linux release 7.0.1406 (Core)
修改爲
#CentOS Linux release 7.0.1406 (Core)
Red Hat Enterprise Linux 6

修改系統內核
vim /etc/sysctl.conf #編輯,在最後添加以下代碼
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.icmp_echo_ignore_broadcasts = 1

vim /etc/security/limits.conf #在末尾添加以下代碼

oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile          65536

配置Oracle用戶環境變量

vim /home/oracle/.bash_profile #在最後添加以下代碼

export ORACLE_BASE=/oracle #oracle 數據庫安裝目錄 
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle 數據庫路徑 
export ORACLE_SID=orcl #oracle 啓動數據庫實例名 
export ORACLE_UNQNAME=$ORACLE_SID
export PATH=$ORACLE_HOME/bin:/user/sbin:$PATH #添加系統環境變量 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH #添加系統環境變量




  安裝Oracle數據庫所需要的軟件包

yum install gcc* gcc-* gcc-c++-* glibc-devel-* glibc-headers-* compat-libstdc* libstdc* elfutilslibelf-devel* libaio-devel* sysstat* unixODBC-* pdksh-*

4.重啓下系統,以oracle身份登錄系統

5.解壓oracle安裝包

unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip

6.

cd database

7.

export LANG=en_US  #防止亂碼

8.運行安裝程序(不要使用XShell操作,直接在桌面打開終端操作)

./runInstaller

等待......


取消默認選擇,點擊next


點擊yes


點擊next


選擇server class ,點擊next


點擊next


選擇 Advanced install 點擊 next



添加簡體中文,點擊next


點擊next


設置好環境變量了,這裏會自動填充路徑,點擊 next



默認Inventory Directory爲/oraInventory,修改爲/oracle/oraInventory 點擊next


點擊yes,彈框可能顯示不出來,按方向鍵左鍵,按ENTER



點擊next


點擊next


配置字符集,點擊 next



點擊next


點擊next


點擊next


選擇統一設置密碼,點擊 next


點擊yes,彈框可能顯示不出來,按方向鍵左鍵,按ENTER


點擊next


勾選Ignore All,點擊next


點擊finish


進入安裝過程


安裝到 68%的時候會有如下提示,直接點擊 continue,彈框可能無法展示,直接按ENTER




點擊ok

以下窗口可能被縮成一條豎線在中間,用鼠標拉開即可看到,安裝過程如出現窗口變暗,但是沒有彈框彈出,即爲此類情況



9.打開命令行窗口 

su
輸入 root 帳號密碼,運行
/oracle/oraInvertory/orainstRoot.sh
/oracle/product/11.2.0/dbhome_1/root.sh

10.安裝完成後,把系統標識修改回來

vim /etc/redhat-release #編輯
把
#CentOS Linux release 7.0.1406 (Core)
Red Hat Enterprise Linux 6
修改爲:
CentOS Linux release 7.0.1406 (Core)

11.登錄Oracle

[oracle@localhost ~]$ lsnrctl stop                #先關閉監聽服務

 [oracle@localhost ~]$ lsnrctl start                    #開啓監聽服務

 [oracle@localhost ~]$ sqlplus / as sysdba     #登入

SQL> shutdown immediate             #立即關閉數據庫服務(一般是關閉狀態)
SQL> startup                                    #開啓數據庫服務(重要,必輸)

SQL> exit                                 #退出

SQL> sqlplus scott/[email protected]/orcl    #連接scott用戶

SQL> select * from tab;                  #test查詢表

12,使用PL/SQL連接時,可能會“ORA-12514 TNS 監聽程序當前無法識別連接描述符中請求服務

解決辦法簡述:

1.修改\oracle\product\11.2.0\db_1\network\admin\listener.ora中的(host)bt-199-039.bta.net.cn改爲192.168.47.131

2.修改\oracle\product\11.2.0\db_1\network\admin\tnsnames.ora中的(host)bt-199-039.bta.net.cn 改爲 192.168.47.131

3.修改後,重啓oracle,監聽,並註冊,主win10上的plsql就可以遠程連接虛擬機上的數據庫了.

具體操作步驟如下:

一、修改數據庫服務器中listener.ora文件內容

[oracle@localhost admin]$ vim /oracle/product/11.2.0/db_1/network/admin/listener.ora
原始內容:


# listener.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = bt-199-039.bta.net.cn)(PORT = 1521))

    )

  )

ADR_BASE_LISTENER = /oracle


修改爲
# listener.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /oracle/product/11.2.0/db_1)
(SID_NAME = orcl)
)
)
LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.47.131)(PORT = 1521)))
ADR_BASE_LISTENER = /oracle

修改數據庫服務器中tnsnames.ora文件內容

 

[oracle@localhost admin]$ vim /oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

原始內容:


# tnsnames.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )


修改後的內容:

# tnsnames.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

orcl =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.47.131)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SID = orcl)

    )

  )

數據庫服務器中啓動監聽並更新註冊

1、命令:

[oracle@localhost ~]$ lsnrctl stop                #先關閉監聽服務

輸出:

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-FEB-2017 21:19:42

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.78.130)(PORT=1521)))

The command completed successfully

[oracle@localhost ~]$

 

2、命令:

[oracle@localhost ~]$ lsnrctl start                    #開啓監聽服務
輸出:


LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-FEB-2017 21:24:22

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /data/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production

System parameter file is /data/oracle/product/11.2.0/db_1/network/admin/listener.ora

Log messages written to /data/oracle/diag/tnslsnr/localhost/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.78.130)(PORT=1521)))

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.78.130)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                19-FEB-2017 21:24:22

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /data/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File         /data/oracle/diag/tnslsnr/localhost/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.78.130)(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@localhost ~]$

 



 

3、命令:

[oracle@localhost ~]$ sqlplus / as sysdba     #登入

輸出:

SQL*Plus: Release 11.2.0.1.0 Production on Sun Feb 19 21:27:40 2017

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

SQL>    

命令:

SQL> shutdown immediate             #立即關閉數據庫服務

輸出:

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

 

命令:
SQL> startup                                    #開啓數據庫服務

輸出:

ORACLE instance started.

Total System Global Area 1586708480 bytes

Fixed Size                2213736 bytes

Variable Size                  939526296 bytes

Database Buffers           637534208 bytes

Redo Buffers                    7434240 bytes

Database mounted.

Database opened.

SQL>

 

命令:
SQL> alter system register;        #註冊

輸出:

System altered.

SQL>
命令:

SQL> quit         #登出

輸出:

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 ~]$



 

命令:
[oracle@localhost ~]$ lsnrctl status        #查看監聽狀態

輸出:

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-FEB-2017 21:37:20

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.78.130)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                19-FEB-2017 21:24:22

Uptime                    0 days 0 hr. 12 min. 57 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /data/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File         /data/oracle/diag/tnslsnr/localhost/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.78.130)(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@localhost ~]$


 

發佈了3 篇原創文章 · 獲贊 3 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章