一、安装docker
yum install -y yum-utils
#配置阿里源
yum-config-manager \
> --add-repo \
> https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#更新源
[root@localhost ~]# yum makecache fast -q
#安装docker
[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io -y -q
#启动docker并开机自启
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
二、获取docker的Oracle镜像
docker pull jaspeen/oracle-11g
三、上传Oracle11g安装包
/install目录是默认安装目录,不然安装时会报错(Installation files not found. Unzip installation files into mounted(/install) folder)
#创建Oracle安装目录,
mkdir /install
#将两个Oracle安装目录上传到/install目录下
-rw-r--r--. 1 root root 1239269270 4月 29 15:52 linux.x64_11gR2_database_1of2.zip
-rw-r--r--. 1 root root 1111416131 4月 29 15:54 linux.x64_11gR2_database_2of2.zip
#解压
[root@localhost install]unzip linux.x64_11gR2_database_1of2.zip
[root@localhost install]unzip linux.x64_11gR2_database_2of2.zip
[root@localhost install]# ll
总用量 2295592
drwxr-xr-x. 8 root root 128 8月 21 2009 database
-rw-r--r--. 1 root root 1239269270 4月 29 15:52 linux.x64_11gR2_database_1of2.zip
-rw-r--r--. 1 root root 1111416131 4月 29 15:54 linux.x64_11gR2_database_2of2.zip
四、安装Oracle11g
[root@localhost install]# docker run -d --privileged --name oracle11g -p 1521:1521 -v /install/:/install jaspeen/oracle-11g
Database is not installed. Installing...
Installing Oracle Database 11g
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 29054 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2045 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2022-04-29_08-36-50AM. Please wait ...You can find the log of this install session at:
/opt/oracle/oraInventory/logs/installActions2022-04-29_08-36-50AM.log
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/opt/oracle/oraInventory/orainstRoot.sh
/opt/oracle/app/product/11.2.0/dbhome_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.
Changing permissions of /opt/oracle/oraInventory.
····································
······················
等它慢慢安装
五,初始化数据库
5.1,连接到容器,
docker exec -it oracle11g /bin/bash
3.2,切换到oracle用户,然后连接到sql控制台
su - oracle
sqlplus / as sysdba
#默认scott用户是被锁定的,需要解锁
SQL>
3.3,解锁账户
SQL> alter user scott account unlock;
User altered.
SQL> commit;
Commit complete.
SQL> conn scott/tiger
ERROR:
ORA-28001: the password has expired
Changing password for scott
New password:
Retype new password:
Password changed
Connected.
SQL>