当前位置: 首页 > news >正文

docker部署oracle数据库

一、下载oracle镜像

[root@localhost ~]# docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

二、创建自定义网段

[root@localhost ~]# docker network create --driver bridge --subnet 172.18.0.0/16 --gateway 172.18.0.1 my_bridge

三、创建数据持久化目录

[root@localhost ~]# mkdir -pv /dev/shm
[root@localhost ~]# mkdir -pv /home/app/oracleout

四、将数据解压到指定目录

[root@localhost ~]# tar xf oradata.tar.gz -C /home/app/oracleout

五、创建容器

[root@localhost ~]# docker run --privileged -h chemdb.thinks.net.cn -d -p 1521:1521 --restart=always -v /dev/shm:/dev/shm -v  /home/app/oracleout:/dockerfiles  -v /home/app/oracleout/oradata:/opt/app/oracle/oradata --name chemdb  --network my_bridge --ip 172.18.0.17 -t thinks/chemdb:oracle

六、进入数据库

[root@localhost ~]# docker exec -it chemdb bash

七、切换root用户

[oracle@chemdb /]$ su - root
Password: helowin

八、编辑环境变量

[root@chemdb ~]# tail -3 /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

九、加载环境变量

[root@chemdb ~]# source /etc/profile

十、创建启动命令软连接

[root@chemdb ~]# ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

十一、退出root用户并登录

[root@chemdb ~]# exit
logout
[oracle@chemdb /]$ sqlplus / as sysdba
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

十二、启动数据库服务并开启监听

SQL> startup;
ORACLE instance started.Total System Global Area 1603411968 bytes
Fixed Size		    2213776 bytes
Variable Size		  402655344 bytes
Database Buffers	 1191182336 bytes
Redo Buffers		    7360512 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@chemdb ~]$ lsnrctlLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-JUN-2025 23:28:24Copyright (c) 1991, 2009, Oracle.  All rights reserved.Welcome to LSNRCTL, type "help" for information.LSNRCTL> start
TNS-01106: Listener using listener name LISTENER has already been started
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                16-JUN-2025 22:34:03
Uptime                    3 days 0 hr. 54 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/chemdb/listener/alert/log.xml
Listening Endpoints Summary...(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=chemdb.thinks.net.cn)(PORT=1521)))
Services Summary...
Service "helowin" has 1 instance(s).Instance "helowin", status READY, has 1 handler(s) for this service...
Service "helowinXDB" has 1 instance(s).Instance "helowin", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> exit

十三、基本使用
1、创建用户并授权

[oracle@chemdb ~]$ sqlplus / as sysdba
SQL> create user lv identified by 123456;User created.SQL> grant dba to lv;Grant succeeded.

2、导入数据

将数据放到容器的挂在目录中,而后进入容器查看对应目录下是否有对应的数据.sql文件
[oracle@chemdb ~]$ sqlplus lv/123456
SQL> @/opt/app/oracle/admin/chemdb/dpdump/.sql

3、查看当前用户

SQL> show user;

4、查看表结构

SQL> desc dba_users;

5、启用锁定的用户

SQL> alter user username(用户名) account unlock;

6、设置用户的默认或者临时表空间

SQL> alter user username default|temporary tablespacetablespace_name;
#普通用户没有这个权限,管理员可以修改,也可以为普通用户设置

7、普通用户登录查看的数据表

SQL> select tablespace_name from user_tablespaces;

8、创建表空间

永久表空间
SQL> create tablespace tablespace_name datafile 'xx.dbf' size xx;
临时表空间
SQL> create temporary tablespace tablespace_name templile 'xx.dbf' size xx;
#DATAFILE:设置表空间数据文件,xx.dbf是数据文件的名称,最好设置数据文件的所在路径。SIZE:设置数据文件大小。

9、创建用户,随便分配表空间

SQL> create user username identified by "123456" default tablespace test profile default account unlock;

10、查询目录

SQL> select * from dba_directories;
http://www.lqws.cn/news/509761.html

相关文章:

  • Leetcode+JAVA+回溯1
  • i.MX平台下 Linux + FreeRTOS 协同启动与通讯全解(含Yocto实战与核心机制分析)
  • ​CentOS 7 单用户模式重置 root 密码完整指南
  • 无人机神经网络模块运行与技术难点
  • Dify与代理商奇墨科技为企业定制AI应用开发专属方案,适配多样化业务需求
  • vue-25( Composition API 与现有的 Options API 组件集成)
  • 采用ArcGIS10.8.2 进行插值图绘制
  • DEYOLO 全面复现,将双增强跨模态目标检测网络 DEYOLO 融合到 YOLOFuse 框架
  • C++字符大小
  • P0/P1级重大故障根因分析:技术挑战与无指责复盘文化
  • Leaking GAN
  • 医学数据分析实战:冠心病发病因素可视化
  • git学习资源
  • 轨迹降噪API及算法
  • 应用层协议 HTTP
  • 洛谷P1092 [NOIP 2004 提高组] 虫食算
  • openai-agents实现out_guardrails
  • DataSophon 1.2.1集成Flink 1.20并增加JMX 监控
  • [ruby on rails] ActiveJob中 discard_on,retry_on和 rescue_from的应用
  • 用福昕阅读器打开pdf文件,整个程序窗口自动缩小的问题
  • 14.OCR字符识别
  • 10-Python模块详解
  • 猿人学js逆向比赛第一届第十二题
  • 国产化条码类库Spire.Barcode教程:如何使用 C# 读取 PDF 中的条码(两种方法轻松实现)
  • 【前端】JS模块化解析-ESModule
  • C# VB.NET取字符串中全角字符数量和半角字符数量
  • 电机驱动基础
  • Rust 项目实战:多线程 Web 服务器
  • 第1篇:环境搭建与第一个Gin应用
  • 数字图像处理——滤波器核(kernel)