阿裡雲centos安裝oracle

来源:https://www.cnblogs.com/zhijiancanxue/archive/2020/03/16/12507282.html
-Advertisement-
Play Games

[toc] 阿裡雲centos安裝oracle 阿裡雲預設沒有swap分區,oracle安裝需要 創建swap分區是為了彌補物理記憶體的不足,也就是虛擬記憶體的概念,把硬碟的一部分劃分作為虛擬記憶體,但這個空間不是越大越好,硬碟的速度遠低於記憶體,設置不當反而拖慢系統的速度。 阿裡雲的主機預設沒有swap分 ...


目錄

阿裡雲centos安裝oracle

阿裡雲預設沒有swap分區,oracle安裝需要

創建swap分區是為了彌補物理記憶體的不足,也就是虛擬記憶體的概念,把硬碟的一部分劃分作為虛擬記憶體,但這個空間不是越大越好,硬碟的速度遠低於記憶體,設置不當反而拖慢系統的速度。

阿裡雲的主機預設沒有swap分區,可以使用free命令查看。

  1. 使用dd命令創建一個swap分區: dd if=/dev/zero of=/home/swap bs=1024 count=1048576 (count的值是:size(多少M)* 1024,我這裡設置的1G虛擬記憶體,也就是count=1024000)

  2. 格式化swap分區: mkswap /home/swap

  3. 把格式化後的文件分區設置為swap分區: swapon /home/swap (關閉SWAP分區命令為:[root@localhost Desktop]#swapoff /home/swap)

  4. swap分區自動掛載:vi /etc/fstab 在文件末尾加上"/home/swap swap swap default 0 0"

安裝Oracle所需的依賴包

yum -y install  gcc gcc-c++ make binutils compat-libstdc++-33 glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel sysstat ksh

創建用戶和組

groupadd -g 200 oinstall  #添加oinstall組,組的id為200
groupadd -g 201 dba       #添加dba組,組的id為201
useradd -u 440 -g oinstall -G dba oracle #添加用戶oracle,並specified它的id為440.
passwd oracle             #輸入oracle用戶的密碼
id oracle                 #查看用戶id和所屬組。

關閉SELINUX(阿裡雲預設關閉)

vim /etc/selinux/config   #編輯配置文件,關閉SELINUX
setenforce 0              #立即關閉SELINUX

開始安裝

使用“su - u oracle”切換到oracle賬號下

把下麵兩個文件上傳到CentOS7-64bits伺服器的/app/oracle目錄下(我比較喜歡把軟體安裝在/app下)

linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.zip

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

在/app/oracle目錄下會出現database目錄。

vim /app/oracle/database/response/db_install.rsp

修改db_install.rsp文件

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=可以寫本機地址
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/app/oracle/oraInventory
SELECTED_LANGUAGES=zh_CN,en
ORACLE_HOME=/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=512
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle2018
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.automatedBackup.enable=false
DECLINE_SECURITY_UPDATES=true

安裝Oracle

oracle賬號登陸,在/app/oracle/database路徑下執行開始安裝

./runInstaller -silent -responseFile /app/oracle/database/response/db_install.rsp

安裝成功之後會出現如下:

The following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #Root scripts to run

/app/oracle/oraInventory/orainstRoot.sh
/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
 1. Open a terminal window
 2. Log in as "root"
 3. Run the scripts
 4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

按照提示以root身份登錄CentOS7系統執行如下命令

/app/oracle/oraInventory/orainstRoot.sh
/app/oracle/product/11.2.0/db_1/root.sh

以oracle身份登錄CentOS7系統,設置環境變數

vi ~/.bash_profile

export PATH
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
export TNS_ADMIN=$ORACLE_HOME/network/admin

使用下麵命令使環境變數生效:source ~/.bash_profile

為了使sqlplus能夠訪問遠程oracle資料庫,不但要配置“TNS_ADMIN”環境變數,還需要環境變數指向的地址(我這裡是/app/oracle/product/11.2.0/db_1/network/admin/)中放入tnsnames.ora文件

下麵是我tnsnames.ora的內容,其中orcl是資料庫名字。

localoracle =  
  (DESCRIPTION =  
    (ADDRESS_LIST =  
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))  
    )  
    (CONNECT_DATA =  
      (SERVICE_NAME = orcl)  
    )  
  )  

建庫

確認並修改/app/oracle/database/response/dbca.rsp,其中修改的都是CREATEDATABASE操作的內容,其他的不動。

RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
CHARACTERSET="AL32UTF8"

用oracle賬號調用下麵的命令

dbca -silent -responseFile /app/oracle/database/response/dbca.rsp
#執行結束後需要輸入2次oracle設置的密碼

驗證Oracle安裝是否成功:

su - u oracle

sqlplus "/as sysdba"

select * from tabs;

如果成功運行,表示oracle已經啟來,否則需要運行“startup”命令啟動oracle.

添加listener.ora文件

位置:/app/oracle/product/11.2.0/db_1/network/admin

文件內容

# copyright (c) 1997 by the Oracle Corporation
# 
# NAME
#   listener.ora
# FUNCTION
#   Network Listener startup parameter file example
# NOTES
#   This file contains all the parameters for listener.ora,
#   and could be used to configure the listener by uncommenting
#   and changing values.  Multiple listeners can be configured
#   in one listener.ora, so listener.ora parameters take the form
#   of SID_LIST_<lsnr>, where <lsnr> is the name of the listener
#   this parameter refers to.  All parameters and values are
#   case-insensitive.

# <lsnr>
#   This parameter specifies both the name of the listener, and
#   it listening address(es). Other parameters for this listener
#   us this name in place of <lsnr>.  When not specified,
#   the name for <lsnr> defaults to "LISTENER", with the default
#   address value as shown below.
#
# LISTENER =
#  (ADDRESS_LIST=
#   (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
#   (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))   
LISTENER=(DESCRIPTION_LIST=(DESCRIPTION=
      (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))  
  )
)

# SID_LIST_<lsnr>
#   List of services the listener knows about and can connect 
#   clients to.  There is no default.  See the Net8 Administrator's
#   Guide for more information.
#
# SID_LIST_LISTENER=
#   (SID_LIST=
#   (SID_DESC=
#           #BEQUEATH CONFIG
#          (GLOBAL_DBNAME=salesdb.mycompany)
#          (SID_NAME=sid1)          
#          (ORACLE_HOME=/private/app/oracle/product/8.0.3)
#           #PRESPAWN CONFIG
#         (PRESPAWN_MAX=20)
#     (PRESPAWN_LIST=
#           (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
#         )
#        )
#       )

SID_LIST_LISTENER=
  (SID_LIST=
      (SID_DESC=
         (GLOBAL_DBNAME=orcl)
         (SID_NAME=orcl)
         (ORACLE_HOME=/app/oracle/product/11.2.0/db_1)
        (PRESPAWN_MAX=20)
        (PRESPAWN_LIST=
          (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
        )
       )
      )
    
# PASSWORDS_<lsnr>
#   Specifies a password to authenticate stopping the listener.
#   Both encrypted and plain-text values can be set.  Encrypted passwords
#   can be set and stored using lsnrctl.  
#     LSNRCTL> change_password
#       Will prompt for old and new passwords, and use encryption both
#       to match the old password and to set the new one.
#     LSNRCTL> set password
#   Will prompt for the new password, for authentication with 
#       the listener. The password must be set before running the next
#       command.
#     LSNRCTL> save_config
#       Will save the changed password to listener.ora. These last two
#       steps are not necessary if SAVE_CONFIG_ON_STOP_<lsnr> is ON.
#       See below.
#
# Default: NONE
#
# PASSWORDS_LISTENER = 20A22647832FB454      # "foobar"

# SAVE_CONFIG_ON_STOP_<lsnr>
#   Tells the listener to save configuration changes to listener.ora when
#   it shuts down.  Changed parameter values will be written to the file,
#   while preserving formatting and comments.
# Default: OFF
# Values: ON/OFF
#
# SAVE_CONFIG_ON_STOP_LISTENER = ON

# USE_PLUG_AND_PLAY_<lsnr>
#   Tells the listener to contact an Onames server and register itself
#   and its services with Onames.
# Values: ON/OFF
# Default: OFF
#
# USE_PLUG_AND_PLAY_LISTENER = ON

# LOG_FILE_<lsnr>
#   Sets the name of the listener's log file.  The .log extension
#   is added automatically.
# Default=<lsnr>
#
# LOG_FILE_LISTENER = lsnr

# LOG_DIRECTORY_<lsnr>
#   Sets the directory for the listener's log file.
# Default: <oracle_home>/network/log
#
# LOG_DIRECTORY_LISTENER = /private/app/oracle/product/8.0.3/network/log

# TRACE_LEVEL_<lsnr>
#   Specifies desired tracing level.
# Default: OFF
# Values: OFF/USER/ADMIN/SUPPORT/0-16
#
# TRACE_LEVEL_LISTENER = SUPPORT

# TRACE_FILE_<lsnr>
#   Sets the name of the listener's trace file. The .trc extension
#   is added automatically.
# Default: <lsnr>
#
# TRACE_FILE_LISTENER = lsnr

# TRACE_DIRECTORY_<lsnr>
#   Sets the directory for the listener's trace file.
# Default: <oracle_home>/network/trace
#
# TRACE_DIRECTORY_LISTENER=/private/app/oracle/product/8.0.3/network/trace
# CONNECT_TIMEOUT_<lsnr>
#   Sets the number of seconds that the listener waits to get a 
#   valid database query after it has been started.
# Default: 10
#
# CONNECT_TIMEOUT_LISTENER=10

使用lsnrctl start命令啟動偵聽器


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1) 如何向腳本傳遞參數 ? ./script argument 例子 : 顯示文件名稱腳本 ./show.sh file1.txt cat show.sh #!/bin/bash cat $1 2) 如何在腳本中使用參數 ? 第一個參數 : 1,第二個參數:1,第二個參數:2 例子 : 腳本會複製 ...
  • [20200316]dmesg與時間戳2.txt--//鏈接提到http://blog.itpub.net/267265/viewspace-2670625/=> 計算的時間戳有問題,一直沒仔細探究.--//網上找到鏈接 https://stackoverflow.com/questions/138 ...
  • 1、方法一(若此方法不行用方法二) 編輯sudoers文件有兩種辦法,一種是以root帳號執行vi sudo, 另一種是root帳號執行vi /etc/sudoers.其兩者都是修改/etc/sudoers。 我的用戶名是“ggc”,屬於“ggc”用戶組。此時此用戶是不在sudoers文件的列表中的 ...
  • [toc] oracle生產備份方案 crontab 配置 周末全量備份,其他日期增量備份,清除15天以前文件 rman_backup_0.sh !/bin/bash source ~/.bash_profile rq= rman target / log /backup/log/rmanbacku ...
  • [toc] oracle自定義splitstr 有時候我們需要將('a,b,c,d')字元分割開,這個時候就需要oracle自定義一個splitstr函數,操作起來非常簡單,執行下麵的function就可以了。 ...
  • [toc] oracle中wm_concat oracle中wm_concat標識符無效原因: 11gr2和12C上已經摒棄了wm\_concat函數,當時我們很多程式員在程式中確使用了該函數,導致程式出現錯誤,為了減輕程式員修改程式的工作量,只有通過手工創建個wm\_concat函數,來臨時解決該 ...
  • [toc] oracle加密encrypt,解密decrypt 有的oracle版本沒有加解密函數,以下操作可以手動添加 oracle數據使用加密解密,我們首先要先賦予dbms_crypto許可權給用戶。 加密 解密 ...
  • 在測試環境中我們需要每天備份oracle中的數據,以便錯誤的操作、測試或者覆蓋其中有價值的數據,暫時不考慮生產環境的全量增量備份策略,本文只是簡單的oracle資料庫使用expdp命令設置定時任務備份數據。 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...