docker安装oracle数据

docker安装oracle数据库

1️⃣ 通过docker拉取并启动oracle11g(此版本目前主流),docker换源及安装mysql看Springboot创建项目及测试 - $YX$ - 博客园 (cnblogs.com)

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
docker images

docker run -d -p 1521:1521 --privileged=true --name oracle registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
docker ps -a

docker exec -it oracle11g bash
su root
helowin
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
helowin
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
su oracle
echo $ORACLE_HOME
echo $ORACLE_SID

修改oracle的监听文件,实现连接oracle
cd $ORACLE_HOME
cd network/admin
vi listener.ora
vi tnsnames.ora
sqlplus / as sysdba
shutdown immediate
startup
exit
lsnrctl stop
lsnrctl start
lsnrctl status

 

 由于每次重启docker下面的镜像,都会导致环境变量失效,此方法可以重启docker时,不会使环境变量生效,注意以oracle用户修改

vi ~/.bashrc
source /etc/profile

sqlplus / as sysdba
select * from dual;
alter user sys identified by sys;

 

网上下载plsql工具,以及远程连接数据库的工具instantclient,安装instantclient的原因是因为你本机没有安装oracle,需要远程连接数据库,通过instantclient可以达到此目的

 

 

打开plsql,连接oracle,账号密码sys,sys,上一步identified就是修改密码为sys

 

服务器上创建oralce数据库实例需要的相关目录,oracle上创建表空间,创建用户,创建表,索引等

 

在服务器创建oracle相关目录时,首先要切换在oracle权限下,这样后续在使用sqlldr入库以及创建表空间的时候,不会报权限不足,创建目录要在ORACLE_HOME相关目录下进行,因为只有这个目录oracle用户才有权限操作

创建表空间
sqlplus / as sysdba

CREATE TABLESPACE "XDB_INTERFACE"
LOGGING DATAFILE
'/home/oracle/XDB/XDB_DATA/XDB_SPACE_DATA/XDB_INTERFACE.dbf' SIZE 1G,
'/home/oracle/XDB/XDB_DATA/XDB_SPACE_DATA/XDB_INTERFACE2.dbf' SIZE 1G
autoextend on
next 1G
maxsize unlimited;

创建用户XDBASE
create user XDBASE identified by XDBASE 

给XDBASE用户授权
GRANT "JAVAUSERPRIV" TO XDBASE WITH ADMIN OPTION;
GRANT "RESOURCE" TO XDBASE WITH ADMIN OPTION;
GRANT "DBA" TO XDBASE WITH ADMIN OPTION;
GRANT "JAVASYSPRIV" TO XDBASE WITH ADMIN OPTION;
GRANT "CONNECT" TO XDBASE WITH ADMIN OPTION;
ALTER USER XDBASE DEFAULT ROLE "JAVAUSERPRIV","RESOURCE","DBA","JAVASYSPRIV","CONNECT";
GRANT CREATE ANY INDEX TO XDBASE WITH ADMIN OPTION;
GRANT CREATE ANY TABLE TO XDBASE WITH ADMIN OPTION;
GRANT UNLIMITED TABLESPACE TO XDBASE WITH ADMIN OPTION;
grant select on SYS.DBA_DATA_FILES to XDBASE;
grant select on SYS.DBA_FREE_SPACE to XDBASE;
grant select on SYS.DBA_TABLESPACES to XDBASE;
grant create session to XDBASE;
grant create sequence to XDBASE;
grant drop any sequence to XDBASE;
grant select any dictionary to XDBASE;

 

 

 

posted @ 2023-03-07 15:19  $YX$  阅读(125)  评论(0编辑  收藏  举报