Docker-Compose快速搭建Oracle-11G系统

Docker-Compose快速搭建Oracle-11G系统

 

前置条件

请先安装Docker 

 

脚本

version: '2'
services:
  oracle11g:
    image: filemon/oracle_11g
    environment:
      DBCA_TOTAL_MEMORY: 16192
    ports:
      - "3022:22"
      - "31521:1521"
    restart:
      always
networks:
  oracle11gnetwork:
    driver: 'local'

将以上文件保存为docker-compose.yml文件

 

启动docker-compose脚本

docker-compose up

启动docker-compose(后台模式-不打印日志)
docker-compose up -d

 

启动日志

/home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log 
Starting oracle11g1521_oracle_1 ... done                                                                                                                               

Attaching to oracle11g1521_oracle_1                                                                                                                                    
oracle_1  | /home/oracle/app/oracle/product/11.2.0/dbhome_2                                                                                                            
oracle_1  | Processing Database instance "orcl": log file /home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log                                                  
oracle_1  | tail: unrecognized file system type 0x794c7630 for `/home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log'. Reverting to polling.                    
oracle_1  | Fixed Size              2213776 bytes                                                                                                                      
oracle_1  | Variable Size                 402655344 bytes                                                                                                              
oracle_1  | Database Buffers     1191182336 bytes                                                                                                                      
oracle_1  | Redo Buffers                    7360512 bytes                                                                                                              
oracle_1  | Database mounted.                                                                                                                                          
oracle_1  | Database opened.                                                                                                                                           
oracle_1  | SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production                                                        
oracle_1  | With the Partitioning, OLAP, Data Mining and Real Application Testing options                                                                              
oracle_1  |                                                                                                                                                            
oracle_1  | /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/dbstart: Database instance "orcl" warm started.     

使用命令查看日志 docker logs [containerID]

[root@linux yunwisdom]# docker logs c640                                                                                                                        
/home/oracle/app/oracle/product/11.2.0/dbhome_2                                                                                                                        
Processing Database instance "orcl": log file /home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log                                                              
tail: unrecognized file system type 0x794c7630 for `/home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log'. Reverting to polling.                                
Fixed Size                  2213776 bytes                                                                                                                              
Variable Size             402655344 bytes                                                                                                                              
Database Buffers         1191182336 bytes                                                                                                                              
Redo Buffers                7360512 bytes                                                                                                                              
Database mounted.                                                                                                                                                      
Database opened.                                                                                                                                                       
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production                                                                    
With the Partitioning, OLAP, Data Mining and Real Application Testing options                                                                                          
/home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/dbstart: Database instance "orcl" warm started.                                                                    
[root@brc-linux-01 yunwisdom]#                                                                         

 

参数信息

Orale服务器连接参数:

hostname: localhost
port: 31521
sid: orcl
service name: orcl
username: system
password: admin

宿主机上,使用如下命令连接sqlplus:

# sqlplus system/admin@//localhost:31521/orcl

##没有配置环境变量
# $ORACLE_HOME/bin/sqlplus system/admin@127.0.0.1:1521/orcl

连接示例: 

[root@linux yunwisdom]# docker exec -it --user root c640 bash                                                                                                   
[root@c640bccb9359 /]# sqlplus system/admin@127.0.0.1/orcl                                                                                                             
bash: sqlplus: command not found                                                                                                                                       
[root@c640bccb9359 /]# $ORACLE_HOME/bin/sqlplus system/admin@127.0.0.1/orcl                                                                                            
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 20 07:52:20 2019                                                                                                    
Copyright (c) 1982, 2009, Oracle.  All rights reserved.                                                                                                                
ERROR:                                                                                                                                                                 
ORA-28002: the password will expire within 7 days                                                                                                                      
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>                                                                                                                                                                                                                                                                                                                                    
SQL> exit                                                                                                                                                              
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production       

Password for SYSTEM:

admin

宿主机上,可以使用下面命令进入oracle数据库,无需安装sqlplus

docker run -e URL=system/password@//10.24.12.132:1521/orcl -ti sflyr/sqlplus
docker run --rm -it loivis/sqlplus system/admin@//127.0.0.1:31521/orcl 

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值