|
docker安装oracle12c记录
前置:系统是centos7.9
1.安装docker
yum -y install docker
systemctl start docker
systemctl restart docker.service
2.拉取oracle镜像
nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0 &
3.创建容器并运行
docker run -itd --name 12c -h lhrora1221 \
--privileged=true -p 1521:1521 -p 222:22 -p 5500:5500 -p 5501:5501 \
registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0 init
--加-itd参数是让docker启动后能一直运行,如果不加,则在容器启动后执行完就立刻退出了
--加-h 指定容器的hostname
--加–name为容器指定一个名称
--加--privileged=true container内的root拥有真正的root权限
查看镜像
[root@oracle12c ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES8a60370241ca registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0 "init" About an hour ago Up About an hour 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500-5501->5500-5501
/tcp, 0.0.0.0:222->22/tcp
[root@oracle12c ~]#
4.启动数据库
docker exec -it 12c bash
5.容器内操作
[root@lhrora1221 /]# su - oracle
Last login: Fri Aug 21 11:24:52 CST 2020 on pts/4
[oracle@lhrora1221 ~]$ sas
SQL*Plus: Release 12.2.0.1.0 Production on Mon Mar 8 14:11:52 2021
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
SYS@lhrcdb1> startup
ORACLE instance started.
Total System Global Area 805306368 bytes
Fixed Size 8797928 bytes
Variable Size 494928152 bytes
Database Buffers 293601280 bytes
Redo Buffers 7979008 bytes
Database mounted.
Database opened.
SYS@lhrcdb1> show con_name
CON_NAME
------------------------------
CDB$ROOT
SYS@lhrcdb1> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 LHRPDB1 MOUNTED
SYS@lhrcdb1> alter session set container=LHRPDB1;
Session altered.
SYS@lhrcdb1> startup
Pluggable Database opened.
SYS@lhrcdb1> show parameter service_name
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
service_names string lhrcdb1
5.启动监听,绑定数据库
lsnrctl start
6.客户端登录,遇到的小问题
ora_28040:没有匹配的验证协议
vi /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/
在末端添加SQLNET.ALLOWED_LOGON_VERSION=8
连接显示用户名或密码错误
原因是用了servicename
SYS@lhrcdb1> show parameter service_name;
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
service_names string lhrcdb1
SYS@lhrcdb1>
正确应该是使用show con_name;查看出来的名称
具体如下:
SQL*Plus: Release 12.2.0.1.0 Production on Mon Mar 8 15:46:37 2021
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SYS@lhrcdb1> show con_name;
CON_NAME
------------------------------
CDB$ROOT
SYS@lhrcdb1> alter session set container=LHRPDB1;
Session altered.
SYS@lhrcdb1> show con_name;
CON_NAME
------------------------------
LHRPDB1
SYS@lhrcdb1> startup
Pluggable Database opened.
SYS@lhrcdb1>
|