重庆网站建设及推广公司seo企业建站系统
oracle容器的使用
1.下载oracle容器
1.1拉取容器
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
拉取国内镜像,该镜像大小为2.99G,已经集成了oracle环境,拉取完可以直接用,推荐使用这款oracle镜像
1.2查看是否拉取成功
docker images
2.运行oracle容器
docker run -d -it -p 1521:1521 --name oracle11g --restart=always registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
持久化启动方式如下:
docker run -d -it -p 1521:1521 --name oracle --restart=always --mount source=oracle_vol,target=/home/oracle/app/oracle/oradata registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
3.配置oracle数据库
3.1进入oracle数据库
docker exec -it [容器名/容器id] bash
3.2修改环境变量
3.2.1切换到root
su root
密码为helowin
3.2.2编辑vi/etc/profile
在尾部添加如下内容
# oracle home目录
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
# oracle 服务名或者 SID名,要记住这个名字helowin,它是naivcat登录的重要选项
export ORACLE_SID=helowin
# oracle环境变量
export PATH=$ORACLE_HOME/bin:$PATH
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
使环境变量立即生效
3.2.3创建软连接
使用命令
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
3.2.4登录oracle
1.切换oracle用户
su - oracle#登录
sqlplus /nolog#连接
conn /as sysdba
3.2.5修改sys system用户密码
alter user system identified by需要设置的密码;alter user sys identified by 需要设置的密码;alter profile default limit PASSWORD_LIFE_TIME UNLIMITED;
3.2.6创建用户(可选,根据需要)
用一个具有dba权限的用户登录(sysdba),然后输入以下语句
create user 用户名 identified by 密码;grant connect,resource,dba to test;