docker部署oracle
oracle部署
创建oracle用户
[root@stpass-15 ~]# useradd oracle
[root@stpass-15 oracle]# cd oracle
[root@stpass-15 oracle]# mkdir dpdump
创建容器:
[root@stpass-15 oracle]# chown -R 1000:1000 dpdump
[root@stpass-15 oracle]# vi run
粘贴以下内容
#!/bin/bash docker run --name=oracle -d --shm-size=2g \ --hostname=oracle_db \ -p 1521:1521 \ -p 8082:8080 \ -v /data/hoslink/oracle-docker/dpdump:/u01/app/oracle/admin/XE/dpdump \ -v /data/hoslink/oracle-docker/init:/init \ -v /data/hoslink/oracle-docker/network:/u01/app/oracle/product/11.2.0/xe/network \ alexeiled/docker-oracle-xe-11g
[root@stpass-15 oracle]# chmod +x run
[root@stpass-15 oracle]#./run
创建表空间和用户
[root@stpass-15 oracle]# docker exec -it oracle bash
root@oracle_db:/# cd init
root@oracle_db:/init# sqlplus sys/oracle as sysdba;
SQL> @000-install.pdc
填入相应的内容回车,分别是:
- xe
- /u01/app/oracle/admin/XE/dpdump/
- oracle
即可完成表空间和用户的创建以及授权。
导入数据库
root@oracle_db:/init# sqlplus sys/oracle as sysdba;
SQL> GRANT READ,WRITE ON DIRECTORY DATA_PUMP_DIR to system;
SQL> exit
root@oracle_db:/init# impdp system/oracle@xe directory=DATA_PUMP_DIR dumpfile=synergy20180306.dmp table_exists_action=replace schemas=synergy,ids logfile=synergy.log
解决WM_CONCAT函数没有找到的问题
root@oracle_db:/init# sqlplus sys/oracle as sysdba;
SQL> @owmaggrb.plb
如果执行结果报错,说找不到WMSYS用户,那么执行 @owmctab.plb, 再执行@owmaggrs.plb和@owmaggrb.plb。
修改密码有效时间为永久和system用户密码
root@oracle_db:/init# sqlplus sys/oracle as sysdba;
SQL> select * from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';
SQL> alter profile default limit password_life_time unlimited;
SQL> commit;
SQL> select * from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';
SQL> alter user system identified by springiscoming;
SQL> commit;
SQL> exit
root@oracle_db:/init# exit
数据库导出(数据库备份使用)
root@oracle_db:/init# expdp system/oracle@xe directory=DATA_PUMP_DIR content=METADATA_ONLY dumpfile=synergy20180306.dmp schemas=synergy,ids logfile=synergy.log