在Ubuntu上配置Oracle数据库可以通过手动安装和使用Docker容器两种主要方法实现。以下是详细的步骤和技巧:
sudo apt update sudo apt install alien libaio1 unixODBC build-essential
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
sudo mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1 sudo chown -R oracle:oinstall /u01 sudo chmod -R 775 /u01
编辑 ~/.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
访问Oracle官方网站,下载适合Ubuntu版本的Oracle软件包,然后解压到指定目录。
cd /path/to/oracle/database/install/dir ./runInstaller
按照屏幕上的指示进行操作,选择适当的选项和配置,并完成安装过程。
sudo apt update sudo apt install docker.io sudo systemctl start docker sudo systemctl enable docker
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
docker run -d -p 1521:1521 --name oracle registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
sudo docker exec -it oracle bash
source /home/oracle/.bash_profile
编辑 /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
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin/sqlplus
sqlplus /nolog #如果没有该命令,切换root用户 su root #密码:helowin
sqlplus sys as sysdba
在SQL*Plus中执行以下命令:
create user sys identified by password; grant connect, resource to sys; exit;
退出SQL*Plus模式:
exit;
su oracle sqlplus sys/password@helowin as sysdba
请注意,以上步骤可能需要根据您的具体情况进行调整。在安装过程中,请确保遵循Oracle的官方文档和指南,以确保安装的兼容性和稳定性。