溫馨提示×

Ubuntu Oracle存儲配置技巧

小樊
42
2025-06-17 15:38:12
欄目: 云計算

在Ubuntu上配置Oracle數據庫可以通過手動安裝和使用Docker容器兩種主要方法實現。以下是詳細的步驟和技巧:

通過命令行靜默安裝Oracle 19C

  1. 系統要求
  • Ubuntu 16.04或更高版本
  • 至少2GB內存,多核處理器,足夠的磁盤空間
  • 能夠訪問Internet
  1. 安裝依賴項
sudo apt update
sudo apt install alien libaio1 unixODBC build-essential
  1. 創建用戶和用戶組
sudo groupadd -g 503 dba
sudo groupadd -g 504 oper
sudo useradd -u 501 -g oinstall -G dba,oper -s /bin/bash -m oracle
sudo passwd oracle
  1. 創建安裝目錄并設置權限
sudo mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
sudo chown -R oracle:oinstall /u01
sudo chmod -R 775 /u01
  1. 配置環境變量

編輯 ~/.bashrc 文件,添加以下內容:

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH

然后執行:

source ~/.bashrc
  1. 下載并解壓Oracle軟件包

訪問Oracle官方網站,下載適合Ubuntu版本的Oracle軟件包,然后解壓到指定目錄。

  1. 運行安裝程序
cd /path/to/oracle/database/install/dir
./runInstaller
  1. 完成安裝

按照屏幕上的指示進行操作,選擇適當的選項和配置,并完成安裝過程。

通過Docker容器安裝Oracle 11g

  1. 安裝Docker
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
  1. 下載Oracle數據庫容器鏡像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
  1. 創建并啟動容器
docker run -d -p 1521:1521 --name oracle registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
  1. 進入容器進行設置
sudo docker exec -it oracle bash
  1. 加載環境變量
source /home/oracle/.bash_profile
  1. 配置環境變量

編輯 /etc/profile 文件,添加以下內容:

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

使配置生效:

source /etc/profile
  1. 創建軟連接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin/sqlplus
  1. 修改默認密碼
sqlplus /nolog
#如果沒有該命令,切換root用戶
su root
#密碼:helowin
  1. 配置數據庫
sqlplus sys as sysdba

在SQL*Plus中執行以下命令:

create user sys identified by password;
grant connect, resource to sys;
exit;

退出SQL*Plus模式:

exit;
  1. 切換用戶并登錄
su oracle
sqlplus sys/password@helowin as sysdba

請注意,以上步驟可能需要根據您的具體情況進行調整。在安裝過程中,請確保遵循Oracle的官方文檔和指南,以確保安裝的兼容性和穩定性。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女