拉取镜像
https://cr.console.aliyun.com/images/cn-hangzhou/oracle11-helowin/oracle11-helowin/detail?accounttraceid=24cfa63bff0f483db7d63268686a7a32yabl
| 12
 3
 
 | docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11gdocker tag  registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g oracle_11g
 docker rmi  registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11
 
 | 
启动容器
| 1
 | docker run -d -p 1521:1521 --name oracle_11g oracle_11g
 | 
数据持久化
| 12
 
 | docker volume create oracle-11gdocker run -d -p 1521:1521 --name oracle_11g -v oracle-11g:/home/oracle/app/oracle/oradata/ oracle_11g
 
 | 
oracle默认参数
| 12
 3
 4
 5
 
 | hostname: localhostport: 1521
 sid: helowin
 username: system
 password: helowin
 
 | 
修改默认参数
进入容器
| 1
 | docker exec -it oracle_11g  bash -c "su - root"
 | 
修改 /etc/profile
vi /etc/profile
| 12
 3
 4
 
 | export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
 export ORACLE_SID=helowin
 export PATH=$ORACLE_HOME/bin:$PATH
 
 | 
| 12
 3
 
 | source /etc/profile
 ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
 
 | 
登录oracle数据库,修改密码
| 12
 3
 
 | su oraclesqlplus /nolog
 conn /as sysdba
 
 | 
| 12
 3
 
 | alter user system identified by password;alter user sys identified by password;
 ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
 
 | 
修改字符集
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 
 | # 默认字符集 AL32UTF8 
 SQL> conn /as sysdba
 SQL> shutdown immediate;
 SQL> startup mount
 
 SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
 SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;
 SQL> alter database open;
 SQL> ALTER DATABASE CHARACTER SET ZHS16GBK;
 ERROR at line 1:
 ORA-12712: new character set must be a superset of old character set
 提示我们的字符集:新字符集必须为旧字符集的超集,这时我们可以跳过超集的检查做更改(但是已有数据这样做会乱码):
 SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK;
 
 SQL> select * from v$nls_parameters;
 
 SQL> shutdown immediate;
 SQL> startup
 
 至此,字符集的修改就完成了,我们可以通过输入命令验证一下,其结果已经变成了ZHS16GBK了。
 SQL> select userenv('language') from dual;
 
 | 
创建普通用户
用system登录
| 12
 
 | create user test identified by 123456;grant connect, resource, dba to test;
 
 | 
使用普通用户登陆
| 12
 3
 
 | select name from v$database;
 select table_name from all_tables
 
 | 
配置nginx: 反向代理oracle服务
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 
 | stream {
 upstream oracle{
 hash $remote_addr consistent;
 server 192.168.99.101:1521 max_fails=3 fail_timeout=30s;
 }
 
 server {
 listen 1521;
 proxy_connect_timeout 3000s;
 proxy_timeout 6000s;
 proxy_pass oracle;
 }
 }
 
 | 
- 1、网上还有针对sath89/oracle-xe-11g这个镜像的教程,需要注意的是:Oracle快捷版(Oracle XE)是一款基于 Oracle 11g 第2版代码库的小型入门级数据库。Oracle Database XE对安装主机的规模和CPU数量不作限制(每台计算机一个数据库), 但XE将最多存储11GB的用户数据,同时最多使用1GB内存和主机上的一个CPU。
- 2、如果仅作测试也可以安装这个镜像,镜像大约700兆。而教程中的镜像大约近7G。
- 3、https://github.com/wnameless/docker-oracle-xe-11g