1、用docker-compose安装oracle11g
version: '3.7'
services:
oracle_11g:
image: registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
container_name: oracle_11g
environment:
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro
- ./data/oracle:/data/oracle
- ./data/profile:/etc/profile
ports:
- 1521:1521
privileged: true
user: root
restart: always
command: /bin/bash -c "ln -s $ORACLE_HOME/bin/sqlplus /usr/bin"
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 500M
networks:
application:
aliases:
- net-oracle_11g
networks:
application:
name: net
driver: bridge
2、 执行docker-compose
docker-compose up -d
3、进入容器 oracle_11g
docker exec -it oracle_11g bash
4、进行软连接
sqlplus /nolog
如果没有 进行一下操作
vi /etc/profile
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
然后在执行 source /etc/profile 使配置生效
最后方便使用创建软连接 ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
5、切换到oracle 用户
su - oracle
6、登录sqlplus并修改sys、system用户密码并且创建用户
sqlplus /nolog --登录
startup; --启动数据库,注意第一次进入才执行
conn /as sysdba --连接数据库
alter user system identified by system;–修改system用户账号密码;
alter user sys identified by system;–修改sys用户账号密码;
create user test identified by test; – 创建内部管理员账号密码;
grant connect,resource,dba to test; --将dba权限授权给内部管理员账号和密码;
alter profile default limit password_life_time unlimited; --修改密码规则策略为密码永不过期;
alter system set processes=1000 scope=spfile; --修改数据库最大连接数据;
修改以上信息后,需要重新启动数据库
conn /as sysdba
shutdown immediate; --关闭数据库
startup; --启动数据库
exit:退出软链接
7、到这里基本上就能连接了
8、部分问题
8.1 navicat无法登陆
alter system set local_listener=‘(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))’; – 然后重启,如果执行不成也退出
然后退出SQL页面在执行
lsnrctl start #开启监听
dbstart # 启动用户实例