当前位置:网站首页>在mac中使用docker来搭建oracle数据库服务器
在mac中使用docker来搭建oracle数据库服务器
2022-07-27 06:10:00 【hawanglc】
近期需要使用oracle来做点事情,我需要在我的pc上搭建一个oracle服务器。以下就是记录搭建数据库服务器的流程。
主机系统:macOS big sur 版本:11.2.3
下载安装docker
在官网下载docker,路径是:https://docs.docker.com/docker-for-mac/install/,安装成功之后,运行docker,就绪之后,就可以在上面的状态栏看到一个静止的docker图标,此时,在命令行输入docker,shell会提示帮助信息。
常用的docker命令,请参见https://www.runoob.com/docker/docker-command-manual.html
修改镜像源配置
打开docker的preference,可以更改一些docker控制界面的配置,选择docker ENGINE,修改json格式的配置文件,内容如下:
{
"features": {
"buildkit": true
},
"experimental": false,
"registry-mirrors": [
"https://fzkgv7fj.mirror.aliyuncs.com"
]
}
拉取oracle数据库镜像
docker pull filemon/oracle_11g
拉取成功之后,可以单击右上角的docker图标,选择dashboard来查看当前的docker管理的镜像,如下:

也可以通过命令来查看:
[21-03-22 9:40:54 /Users/huGuohua]$docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
filemon/oracle_11g latest d03c4f0a4743 6 years ago 8.62GB
另外一种获得docker镜像的图形化方法
使用Kitematic
在https://kitematic.com/中找到下载路径,下载软件。然后运行软件,查找自己需要的镜像即可,如图:

运行oracle镜像来启动数据库
也可以在dashboard中修改好参数之后,直接点击开始按钮来运行oracle镜像,下面是运行的命令:
docker run -d -p 11521:1521 -p 10022:22 --name=oracle11g filemon/oracle_11g
这个命令的参数说明如下:
1.-p 11521:1521 允许远程的客户端可以从11521端口连接到数据库实例(端口映射,格式为:主机(宿主)端口:容器端口).
2.-d: 后台运行容器,并返回容器ID;
3.--name="oracle11g": 为容器指定一个名称;
正常的情况下,输入docker ps可以看到
[21-03-22 9:05:05 /Users/huGuohua]$docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c720c9aebbc filemon/oracle_11g "bash -c 'sed -i -E …" 34 minutes ago Up 15 seconds 0.0.0.0:10022->22/tcp, 0.0.0.0:11521->1521/tcp oracle11g
这就说明,docker启动正常了
这个镜像的oracle数据库的用户名和密码是:
system/[email protected]
sys/[email protected]
创建用户和表空间等
进入数据库
docker exec -it --user root oracle11g /bin/bash
如果找不到SQLPLUS,那就进入对应的sqlplus的所在的目录
cd /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin
sqlplus sys/[email protected] as sysdba
-- 创建表空间
create tablespace BABY
datafile '/home/oracle/app/oracle/oradata/orcl/baby.dbf'
size 100m
autoextend on next 50m;
-- 创建索引空间
create tablespace BABY_INDEX
datafile '/home/oracle/app/oracle/oradata/orcl/baby_index.dbf'
size 100m
autoextend on next 10m;
-- 创建用户
create user baby
identified by baby1234
default tablespace BABY
temporary tablespace TEMP
profile DEFAULT;
-- 给用户授权
grant connect to baby;
grant dba to baby;
grant resource to baby;
grant unlimited tablespace to baby;
用客户端验证操作
用dbeaver来验证
配置如图:

此时,数据库服务器就搭建完成了,就可以编写SQL来处理数据了。
关闭数据库
进入数据库
docker exec -it --user root oracle11g /bin/bash
如果找不到SQLPLUS,那就进入对应的sqlplus的所在的目录
cd /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin
./sqlplus sys/[email protected] as sysdba
shutdown normal
然后关闭所有的数据库连接,数据库就会关闭了。
重启docker
可以使用命令或者在任务栏点击docker图标来重启。
边栏推荐
- Consideration on how the covariance of Kalman filter affects the tracking effect of deepsort
- C4D动画如何提交云渲染农场快速渲染?
- 用typescript实现排序-递增
- Codeforces Round #809 (Div. 2)(6/6)(Kruskal重构树)
- Pytorch model
- Digital image processing Chapter 1 Introduction
- 36 - 新的 Promise 方法:allSettled & any & race
- 12. Integer to Roman
- (posted) comparison of Eureka, consumer and Nacos 2
- Digital image processing - Chapter 6 color image processing
猜你喜欢

C4D云渲染平台选哪家合作?

(转帖)eureka、consul、nacos的对比1

指令集董事长潘爱民出席2022 ECUG Con,为中国技术力量发声

Analysis on the current situation and optimization strategy of customer experience management in banking industry

SQLite 常用功能整合

使用反射实现动态修改@Excel的注解属性

MySQL2

Which C4d cloud rendering platform to cooperate with?

Relevant principles of MySQL index optimization

Automatically generate UML sequence diagram according to text (draw.io format)
随机推荐
A Competitive Swarm Optimizer for Large Scale Optimization
Codeforces Round #804 (Div. 2)(5/5)
36 - new promise method: allsettled & any & race
二叉树--天然的查找语义(1)基础篇
线性表 -- 栈和队列
ESP8266(ESP-12F) 第三方库使用 -- SparkFun_APDS9960 (手势识别)
No.0 training platform course-2. SSRF Foundation
sql-labs SQL注入平台-第1关Less-1 GET - Error based - Single quotes - String(基于错误的GET单引号字符型注入)
String类的用法
(posted) comparison of Eureka, consumer and Nacos 2
腾讯云服务器SSH链接自动断开解决方法
【golang学习笔记2.0】 golang中的数组和切片
Pan Aimin, chairman of instruction set, attended the 2022 ecug con to speak for China's technical forces
Linear table -- stack and queue
Tableau prep is connected to maxcompute and only writes simple SQL. Why is this error reported?
C# Winfrom 常用功能整合-2
Calledprocesserror during pre commit install
12. Integer to Roman整数转罗马数字
How does golang assign values to empty structures
Go obtains the processing results of goroutine through channel