安装Oracle EE
安装Oracle EE
前期
进入自己需要设置的目录,创建文件夹,文件夹授权
mkdir xxx
chmod o+w /oracle/oradata
chmod 777 /oracle/oradata
1:查找镜像
docker search oracle19c
2:选择适合的镜像
docker pull heartu41/oracle19c
3:运行
docker run -p 1521:1521 -p 5500:5500 \
--name oracletest \
--privileged=true \
--restart=always \
-e ORACLE_SID=ORCL \
-e ORACLE_PDB=ORCLTEST \
-e ORACLE_PWD=123456 \
-e ORACLE_CHARACTERSET=AL32UTF8 \
-e ORACLE_BASE=/opt/oracle \
-e ORACLE_EDITION=standard \
-e ORACLE_HOME=/opt/oracle/product/19c/dbhome_1 \
-e ORACLE_ALLOW_REMOTE=true \
-e TZ=Asia/Chongqing \
-e PATH=/opt/oracle/product/19c/dbhome_1/bin:/opt/oracle/product/19c/dbhome_1/OPatch/:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
-e NLS_LANG=AMERICAN_AMERICA.AL32UTF8 \
NLS_DATE_LANGUAGE
-it \
-v /data/oracle/oradata:/opt/oracle/oradata \
-d f59790109034
查看:
docker logs -ft oracletest
4:查看设置时区是否生效
docker exec -it oracletest date +"%Z %z"
5:进入容器
docker exec -it oracletest /bin/bash
6:修改密码
./setPassword.sh 123456
7:设置PDB
grep $ORACLE_HOME /etc/oratab | cut -d: -f1
export ORACLE_SID=ORCL
8:连接数据库
sqlplus / as sysdba
10:取消受限模式
alter system disable restricted session;
9:执行
alter session set "_ORACLE_SCRIPT"=true;
9:查看
show pdbs;
10:创建模式后授权表空间
ALTER USER 用户名 QUOTA UNLIMITED ON 表空间
11 如果需要修改字符集或者环境变量
查询:
SELECT USERENV('language') FROM dual;
则安装vim
docker exec -it --user root oracletest /bin/bash
yum install vim
**编辑文件 **
vim ~/.bash_profile
添加
export NLS_LANG="SIMPLIFIED CHINESE_CHINA".ZHS16GBK
or
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
or
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
加载文件
source ~/.bash_profile
修改oracle参数形式
**select * from v$nls_parameters; **
创建用户表空间
-- 移除表空间
DROP TABLESPACE HTHSETEMP INCLUDING CONTENTS AND DATAFILES
-- 移除用户
drop user HSE_TEMP CASCADE
-- 创建表空间
CREATE TABLESPACE NTHSETESTPSPACE
DATAFILE '/opt/oracle/oradata/ORCL/ORCLTEST/NTHSETESTPSPACE.dbf'
SIZE 20G AUTOEXTEND ON next 4G
-- 创建用户
CREATE USER HSE_TEMP IDENTIFIED BY 000000
--- 修改密码
alter user 用户名 identified by 新密码;
-- 修改用户表空间
ALTER USER HSE_TEMP quota unlimited ON HTHSETEMP
-- 实际应用
create user <username> identified by <password>
default tablespace <tablespace_name> -- 默认表空间
temporary tablespace temp -- 临时表空间
quota unlimited on <tablespace_name> -- 表空间额度
-- 权限设设置
grant create session to HSE_TEMP
grant create table to HSE_TEMP
grant create tablespace to HSE_TEMP;
grant create any view to HSE_TEMP;
grant connect,resource to HSE_TEMP;
grant create any sequence to HSE_TEMP;
grant create any table to HSE_TEMP;
grant delete any table to HSE_TEMP;
grant insert any table to HSE_TEMP;
grant select any table to HSE_TEMP;
grant unlimited tablespace to HSE_TEMP;
grant execute any procedure to HSE_TEMP;
grant update any table to HSE_TEMP;
-- 查看当前用户的权限
select * from role_sys_privs;
常用命令
startup mount #启动
shutdown immediate; 关闭
sqlplus / as sysdba 进入
lsnrctl status 查看监听状态
lsnrctl start 开启监听
lsnrctl reload 重启
lsnrctl stop 停止
其余问题
问题
cannot mount database in EXCLUSIVE mode
解决:
cd $ORACLE_HOME/dbs
ls lk*
rm lk*
问题
ORA-00205: error in identifying control file, check alert log for more info : (
解决
ipcs -s
ipcrm -s semid-NO.
问题
ORA-00214: control file '/opt/oracle/oradata/ORCL/control01.ctl' version 2647
inconsistent with file '/opt/oracle/oradata/ORCL/control02.ctl' version 2613
解决
cd /opt/oracle/oradata/ORCL/
ls
cp control01.ctl control02.ctl