纯净的linux安装过程
- 安装docker
yum update
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce-18.06.3.ce-3.el7
- 设置docker为系统自动启动
systemctl start docker
systemctl enable docker.service
- 查找安装oracle镜像
-
- 查询可用的oracle镜像
docker search oracle
-
- 选择安装oracle镜像
docker pull jaspeen/oracle-11g
-
- 查看已安装的镜像
docker images
- 下载oracle安装文件
注意,windows的电脑或者虚机安装11.2.0.1.0的Linux x86-64版本,如果是服务器,安装11.2.0.2.0的zLinux64版本。
- 安装zip、unzip
yum install zip unzip
- 解压文件
注意,下载的两个文件都需要解压一下,windows上是会自动两个解压,但是linux不会
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
- 安装JAVA
-
- 官网下载linux包
-
- ftp上传linux服务器
-
- 创建安装目录
mkdir /usr/local/java/
-
- 解压至安装目录
tar -zxvf jdk-8u101-linux-x64.tar.gz -C /usr/local/java/
-
- 打开文件
vim /etc/profile
-
- 在末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_101
export CLASSPATH=.:${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
-
- 使环境变量生效
source /etc/profile
-
- 检查Java版本
java -version
- 安装oracle
运行命令,等待安装完成
docker run --privileged --name oracle11g -p 1521:1521 -v /home:/install jaspeen/oracle-11g
- 查看docker状态
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c69bfc906f17 jaspeen/oracle-11g "/assets/entrypoint.…" 2 hours ago Up 2 hours 0.0.0.0:1521->1521/tcp, 8080/tcp oracle11g
如上表示安装成功,启动正常,如果容器没有启动(如虚机重启后),则用命令(xxx为上面的CONTAINER_ID):
docker start xxx
- 进入容器
docker exec -it oracle11g /bin/bash
- 切换到oracle用户,然后连接到sql控制台
[root@c69bfc906f17 /]# su - oracle
Last login: Sun Nov 3 08:12:33 UTC 2019
[oracle@c69bfc906f17 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Nov 3 10:19:23 2019
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>
- 解锁SCOTT账号
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>
- 通过PL/SQL或者navicat就可以登录oracle
IP:虚机的ip
账号:SCOTT
密码:解锁SCOTT账号时输入的密码
异常
- 安装oracle异常
[root@localhost home]# docker run --privileged --name oracle11g -p 1521:1521 -v /home:/install jaspeen/oracle-11g
Database is not installed. Installing...
Installing Oracle Database 11g
/install/database/runInstaller: line 254: /install/database/install/.oui: cannot execute binary file
原因:oracle版本错误,应该安装X86的11.2.0.1.0,但是安装了IBM的11.2.0.2.0。重新下载版本即可