1.下载镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
2.创建快速搭建脚本build.sh
#!/bin/bash
#启动镜像
containId=`docker ps -a |grep -i oracle11g|awk '{print $1}'`
FDIR=$(dirname $(readlink -f "$0"))
if [[ ! $containId ]] ;then
echo "target container not exist!"
else
echo "target container exist , ID = "$containId
docker stop $containId
docker rm $containId
echo "success delete container "$containId
fidocker run -d -p 1521:1521 -v $FDIR/data/oracle:/data/oracle --name oracle11g --restart always registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
sleep 3
docker logs -f --tail 100 oracle11g
3.启动脚本并进入容器进行配置
sh build.sh
docker exec -it oracle11g bash
root密码:helowin
su - root
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
数据库配置:
su - oracle
sqlplus /nolog
conn /as sysdba;
修改密码:
alter user system identified by system;
alter user sys identified by sys;
alter profile default limit password_life_time unlimited;创建用户:
create user test identified by test;并给用户赋予权限:
grant connect,resource,dba to test;用户解锁:
alter user test account unlock;自动增加表空间容量:
alter tablespace users add datafile '/home/oracle/app/oracle/oradata/helowin/users02.dbf' size 10240m autoextend on next 1024m maxsize unlimited;扩大共享内存:
alter system set SHARED_POOL_SIZE='150M' SCOPE=spfile;shutdown immediate;
startup;
4.登录信息
5.常见问题解决
①ORA-09925
df -ih 发现Inodes空间不足:删除日志等文件for i in /*; do echo $i; find $i | wc -l; done
清理adump目录
find /home/oracle/app/oracle/admin/helowin/adump -name '*.aud' -mtime +3 -exec rm -rf {} \;
清理trace文件
find /home/oracle/app/oracle/diag/rdbms/helowin/helowin/trace -name '*.trc' -mtime +3 -exec rm -rf {} \;
find /home/oracle/app/oracle/diag/rdbms/helowin/helowin/trace -name '*.trm' -mtime +3 -exec rm -rf {} \;
清理xml日志
find /home/oracle/app/oracle/diag/rdbms/helowin/helowin/alert -name 'log_*.xml' -mtime +3 -exec rm -rf {} \;
清理监听日志
find /home/oracle/app/oracle/diag/tnslsnr/{NODE_NAME}/listener/alert -name 'log_*.xml' -mtime +3 -exec rm -rf {} \;②关闭归档日志
#查看是否是归档方式
archive log list;
#禁用自动归档
alter system set log_archive_start=false scope=spfile;
shutdown immediate;
打开控制文件,不打开数据文件
startup mount; #
#将数据库切换为非归档模式
alter database noarchivelog;
#将数据文件打开
alter database open;
#查看此时便处于非归档模式
archive log list;③设置归档日志
#查询归档文件大小;
show parameter DB_RECOVERY_FILE_DEST_SIZE;
select * from v$flash_recovery_area_usage;
#设置归档文件大小;
alter system set db_recovery_file_dest_size=30737418240;
删除归档文件
rman target /
delete archivelog until time 'sysdate-5';④禁止系统用户外部登录
#显示外部登录方式
show PARAMETER REMOTE_LOGIN_PASSWORD;
#设置禁止外部登录
alter system set remote_login_passwordfile=none scope=spfile;