1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Docker——Mac通过Docker安装Oracle11g

Docker——Mac通过Docker安装Oracle11g

时间:2022-11-23 13:08:06

相关推荐

Docker——Mac通过Docker安装Oracle11g

Mac OS系统如何通过Docker安装Oracle11g

Docker基本概念1.在Mac系统上安转Docker1.2.在Mac下载Docker1.3.stable Docker下载/mac/stable/Docker.dmg1.4.Mac上安装和运行Docker安装运行1.5.Mac平台下Docker相关docker psdocker startdocker ps -adocker rm -f webserverdocker rmidocker --versiondocker info1.5.1Docker搜索 Oracle镜像docker search docker-oracle-xe-11g1.5.2Docker拉取Oracle镜像docker pull deepdiver/docker-oracle-xe-11g1.5.3 Oracle镜像转成容器并使用该容器docker run -d -p 1521:1521 --name oracle11g deepdiver/docker-oracle-xe-11gMac用Navicat连接Oracle数据库报ORA-21561: OID generation failed再次测试 连接成功

Docker基本概念

Docker 包括三个基本概念

镜像(Image)容器(Container)仓库(Repository)

先理解了这三个概念,就理解了 Docker 的整个生命周期。

Docker是一个跨平台的轻量级虚拟机,可移植性非常高,一次部署,终生可用。Docker可以在Linux,Windows,MacOS等平台上安装使用。我们都知道Linux有很多不同 的版本,例如Ubuntu,AIX,CentOS,Debian,Fedora,Oracle Linux,Red Hat Enterprise Linux,openSUSE and SUSE Linux Enterprise等。尽管Linux的版本很多,但是我们的Docker都可以在他们在面运行。你也可以使用Docker云来自动准备和管理你的云实例。

1.在Mac系统上安转Docker

Docker的Mac系统上的安装包中包含了你在Mac上运行Docker的所有依赖的东西,下面这个主题是描述在Mac系统上预安装需要考虑的一些问题和怎样在Mac系统上安装 Docker。

你的Mac本上是否已经安装了Docker,如果已经安装了Docker,你可以直接去启动Docker,如果你已经掌握了在Mac上使用Docker,那么你可以直接跳过整个Mac上的Docker的安装和运行部分。

1.2.在Mac下载Docker

在Mac系统上下载Docker有两种方式,一种是下载stable Docker,另一种是下载Beta版本的Docker

1.3.stable Docker下载

稳定版的Docker是完全测试过的,并且在Docker引擎中带有实验特征的最新版本的Docker引擎,这种引擎在默认情况下启用并其在Docker Daemon设置中优先配置为实验模式。如果你想依赖平台来工作那么这种安装方式是最好的选择。这些版本遵循比beta版更长的发布时间版本计划,与Docker Engine版本和修补程序同步。在稳定通道上,您可以选择是否发送使用统计信息和其他数据。

下载地址:

/mac/stable/Docker.dmg

1.4.Mac上安装和运行Docker

安装

双击Docker.dmg打开安装包,然后拖拽Moby蓝鲸到应用文件夹。在安装过程中你将会被Docker.app请求输入你电脑的系统密码。给予进入特权的需要安装网络组件和链接到Docker应用程序。

运行

双击Docker.app启动Docker

Docker Desktop id running 恭喜你,你已经完成Mac下面的Docker安装

1.5.Mac平台下Docker相关

docker相关命令

A self-sufficient runtime for containersOptions:--config stringLocation of client config files (default "/Users/hjma/.docker")-c, --context stringName of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with"docker context use")-D, --debug Enable debug mode-H, --host listDaemon socket(s) to connect to-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")--tlsUse TLS; implied by --tlsverify--tlscacert string Trust certs signed only by this CA (default "/Users/hjma/.docker/ca.pem")--tlscert stringPath to TLS certificate file (default "/Users/hjma/.docker/cert.pem")--tlskey stringPath to TLS key file (default "/Users/hjma/.docker/key.pem")--tlsverifyUse TLS and verify the remote-v, --version Print version information and quitManagement Commands:builderManage buildsconfigManage Docker configscontainer Manage containerscontextManage contextsimage Manage imagesnetworkManage networksnode Manage Swarm nodespluginManage pluginssecretManage Docker secretsserviceManage servicesstack Manage Docker stacksswarm Manage SwarmsystemManage Dockertrust Manage trust on Docker imagesvolumeManage volumesCommands:attachAttach local standard input, output, and error streams to a running containerbuild Build an image from a DockerfilecommitCreate a new image from a container's changescpCopy files/folders between a container and the local filesystemcreateCreate a new containerdiff Inspect changes to files or directories on a container's filesystemeventsGet real time events from the serverexec Run a command in a running containerexportExport a container's filesystem as a tar archivehistoryShow the history of an imageimagesList imagesimportImport the contents from a tarball to create a filesystem imageinfo Display system-wide informationinspectReturn low-level information on Docker objectskill Kill one or more running containersload Load an image from a tar archive or STDINlogin Log in to a Docker registrylogoutLog out from a Docker registrylogs Fetch the logs of a containerpause Pause all processes within one or more containersport List port mappings or a specific mapping for the containerpsList containerspull Pull an image or a repository from a registrypush Push an image or a repository to a registryrenameRename a containerrestartRestart one or more containersrmRemove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save one or more images to a tar archive (streamed to STDOUT by default)searchSearch the Docker Hub for imagesstart Start one or more stopped containersstats Display a live stream of container(s) resource usage statisticsstop Stop one or more running containerstag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop Display the running processes of a containerunpauseUnpause all processes within one or more containersupdateUpdate configuration of one or more containersversionShow the Docker version informationwait Block until one or more containers stop, then print their exit codes

docker ps

查看正在运行的容器

hjmadeMacBook-Air:/ hjma$ docker ps CONTAINER ID IMAGE ##### docker stop

停止正在运行的容器

docker start

启动容器

docker ps -a

查看终止状态的容器

docker rm -f webserver

移除正在运行的容器

docker rmi

删除的镜像

docker --version

查看docker的版本号,包括客户端、服务端、依赖的Go等

hjmadeMacBook-Air:/ hjma$ docker --versionDocker version 19.03.13, build 4484c46d9dhjmadeMacBook-Air:/ hjma$ docker versionClient: Docker Engine - CommunityCloud integration 0.1.18Version: 19.03.13API version: 1.40Go version: go1.13.15Git commit: 4484c46d9dBuilt: Wed Sep 16 16:58:31 OS/Arch: darwin/amd64Experimental:falseServer: Docker Engine - CommunityEngine:Version:19.03.13API version:1.40 (minimum version 1.12)Go version: go1.13.15Git commit: 4484c46d9dBuilt: Wed Sep 16 17:07:04 OS/Arch:linux/amd64Experimental:falsecontainerd:Version:v1.3.7GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175runc:Version:1.0.0-rc10GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dddocker-init:Version:0.18.0GitCommit: fec3683

docker info

查看系统(docker)层面信息,包括管理的images, containers数等

1.5.1Docker搜索 Oracle镜像

1)Docker是一个容器,在容器内部存在很多镜像文件,通过具体的镜像文件可以运行具体的容器。要想在Docker中安装Oracle镜像,我们首先应该在Docker的远程仓库中进行搜索,因为Docker没有自带Oracle相关镜像,命令如下(根据你Mac的实际情况决定是否要加sudo):

docker search docker-oracle-xe-11g

hjmadeMacBook-Air:/ hjma$ docker search docker-oracle-xe-11gNAME DESCRIPTION STARSOFFICIAL AUTOMATEDdeepdiver/docker-oracle-xe-11g34 [OK]epiclabs/docker-oracle-xe-11g Customized Oracle XE 11g build for CI and de… 17 [OK]pengbai/docker-oracle-xe-11g-r2oracle xe 11g r2 with sql initdb and web con… 9 [OK]arahman/docker-oracle-xe-11g phusion/baseimage based spin off of alexei-l… 9 [OK]konnecteam/docker-oracle-xe-11gFork of /wnameless/docker-… 3 [OK]rafaelri/docker-oracle-xe-11g Fork from wnameless/docker-oracle-xe-11g 3 [OK]ignatov/docker-oracle-xe-11g Dockerfile of Oracle Database Express Editio… 3 [OK]rdehuyss/docker-oracle-xe-11g Oracle Express 11g R2 on Ubuntu 14.04.2 LTS0 [OK]jeromefromcn/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]lynxsolutions/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]zzzfree/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]gswteam/docker-oracle-xe-11g Oracle XE 11g0 [OK]deadok22/docker-oracle-xe-11g docker-oracle-xe-11g 0 deradam/docker-oracle-xe-11g Oracle Express Edition 11g Release 2 on Ubun… 0 bizybot/docker-oracle-xe-11g wnameless/docker-oracle-xe-11g 0 [OK]dbanttari/docker-oracle-xe-11g Branch of wnameless/docker-oracle-xe-11g tha… 0 [OK]nguoianphu/docker-oracle-xe-11gOracle Express Edition 11g Release 2 on Ubun… 0 [OK]xtechnologies/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK]cheyu0325/docker-oracle-xe-11g docker-oracle-xe-11g 0 kikicarbonell/docker-oracle-xe-11g Docker image of Oracle Database Express Edit… 0 [OK]demers/docker-oracle-xe-11g-spark Oracle XE 11g with Spark 0 ceagan/docker-oracle-xe-11gModified version of wnameless/docker-oracle-… 0 [OK]zigac/docker-oracle-xe-11g Oracle xe 11g0 [OK]gmartsenkov/docker-oracle-xe-11goracle 0 [OK]dockerbolcom/docker-oracle-xe-11g Fork of /wnameless/docker-… 0 [OK]

1.5.2Docker拉取Oracle镜像

我们选择第一个STAR最多的一个镜像进行安装,拉取镜像命令如下:

docker pull deepdiver/docker-oracle-xe-11g

hjmadeMacBook-Air:/ hjma$ docker pull deepdiver/docker-oracle-xe-11gUsing default tag: latestlatest: Pulling from deepdiver/docker-oracle-xe-11gImage docker.io/deepdiver/docker-oracle-xe-11g:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at /registry/spec/deprecated-schema-v1/a3ed95caeb02: Pulling fs layer 9cf7e98c567b: Pulling fs layer d2ff49536f4d: Pulling fs layer f94adccdbb9c: Pulling fs layer ee950bf8af06: Pulling fs layer eec0023b823a: Pulling fs layer 2bbcf2933a57: Pull complete 1d639c2160a1: Pull complete 2631aa3055c3: Pull complete d859f4b0261f: Pull complete 344fe8edcc0a: Pull complete 48fec8d59976: Pull complete c9c81ef7960f: Pull complete 7e928eb7228a: Pull complete 56e977b47ad6: Pull complete 5c896b34601c: Pull complete bcab6dcbd345: Pull complete 42e031cc37c0: Pull complete fd6c6b47d0ba: Pull complete 546a383ffbe3: Pull complete 5acead7005d0: Pull complete 206b7448a401: Pull complete bdf584565438: Pull complete 4ce7a34d8c4b: Pull complete 8702b3ee1143: Pull complete 777d696e58cd: Pull complete 8271d90e318b: Pull complete c0e2d1590154: Pull complete aeb67e38d18e: Pull complete Digest: sha256:30c9b1f61397bbca016c25b21c4c2e5399af225306e41272874411ae2bd741d3Status: Downloaded newer image for deepdiver/docker-oracle-xe-11g:latestdocker.io/deepdiver/docker-oracle-xe-11g:latest

1.5.3 Oracle镜像转成容器并使用该容器

等待镜像下载完毕就可。待镜像下载完毕之后,我们需要将该镜像转成容器并使用该容器,命令如下:

docker run -d -p 1521:1521 --name oracle11g deepdiver/docker-oracle-xe-11g

hjmadeMacBook-Air:/ hjma$ docker run -d -p 1521:1521 --name oracle11g deepdiver/docker-oracle-xe-11gf280f8cf651bd0e1463ed4ff9928fdb1222903dfdf030ddb5d7b511c2ffc95bfhjmadeMacBook-Air:/ hjma$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESf280f8cf651b deepdiver/docker-oracle-xe-11g "/bin/sh -c 'sed -i …" 3 minutes ago Up 3 minutes 22/tcp, 8080/tcp, 0.0.0.0:1521->1521/tcp oracle11g

2)在Oracle容器中简单配置你的Oracle数据库并通过Navicat进行连接

进入容器内部的命令如下:

sudo docker exec -it 你的容器Id(可通过docker ps命令获得) /bin/bash

hjmadeMacBook-Air:~ root# docker exec -it f280f8cf651b /bin/bashroot@f280f8cf651b:/#

通过sqlplus进入Oracle:

sqlplus system/oracle

root@f280f8cf651b:/# sqlplus system/oracleSQL*Plus: Release 11.2.0.2.0 Production on Sun Oct 25 08:26:26 Copyright (c) 1982, , Oracle. All rights reserved.ERROR:ORA-28002: the password will expire within 7 daysConnected to:Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit ProductionSQL> select username,password from dba_users;USERNAME PASSWORD------------------------------ ------------------------------SYSANONYMOUSAUTOTESTSYSTEMAPEX_PUBLIC_USERAPEX_040000OUTLNXS$NULLFLOWS_FILESMDSYSCTXSYSUSERNAME PASSWORD------------------------------ ------------------------------XDBHR13 rows selected.

依次进行如下操作:

查看数据库用户名和密码:

select username,password from dba_users;

当然,你可以通过已经存在的用户名和密码来登录数据库,推荐使用新创建的用户来进行数据库的登录,sql如下:

SQL> create user user0435 identified by 123456;User created.

创建完之后,可以通过如下sql进行验证:

SQL> select * from all_users; USERNAME USER_ID CREATED------------------------------ ---------- ---------XS$NULL 2147483638 28-AUG-11USER0435 49 25-OCT-20AUTOTEST 48 25-OCT-20APEX_040000 47 28-AUG-11APEX_PUBLIC_USER 45 28-AUG-11FLOWS_FILES 44 28-AUG-11HR 43 28-AUG-11MDSYS 42 28-AUG-11ANONYMOUS 35 28-AUG-11XDB 34 28-AUG-11CTXSYS 32 28-AUG-11USERNAME USER_ID CREATED------------------------------ ---------- ---------OUTLN9 28-AUG-11SYSTEM5 28-AUG-11SYS0 28-AUG-1114 rows selected.

在创建完新用户之后,需要对该用户进行授权,该用户具有什么权限都是通过自己指定的,这也是为什么推荐使用自定义用户登录数据库的原因,sql如下:

SQL> grant dba to user0435;Grant succeeded.SQL> grant dba to user0436;grant dba to user0436*ERROR at line 1:ORA-01917: user or role 'USER0436' does not exist

connect表示具有连接数据库的权限;resource表示具有操作数据库的权限; dba管理员权限;

至此,所有需要配置的数据库配置都已经配置完毕,可以通过Navicat进行连接了,如下图所示:

几个需要注意的地方:

主机就是localhost或127.0.0.1端口为docker内部Oracle容器映射到宿主机的端口,上述命令有将,我的是映射到1521端口选择服务名进行连接,并且该版本Oracle数据库的服务名为XE(唯一)角色选择默认就行用户名和密码就是我们在上述创建的用户名和密码

Mac用Navicat连接Oracle数据库报ORA-21561: OID generation failed

yin138

码哥码哥yin138:后来者们注意了,这个问题不在于服务器的配置,而在于客户端(用navicat的电脑的hostname和/etc/hosts不一样)。2年前回复

点赞 qq_41973884 WithAtermisia回复: 好人一生平安,一直在服务器上改,没丁点反应。。。。 解决办法,修改

hostname 与 hosts 里保持一致,即在Mac的terminal终端中执行下面这条命令即可 而不是服务器中执行

hjmadeMacBook-Air:~ root# hostnamehjmadeMacBook-Air.localhjmadeMacBook-Air:~ root# sudo scutil --set HostName localhosthjmadeMacBook-Air:~ root# hostnamelocalhosthjmadeMacBook-Air:~ root#

再次测试 连接成功

在配置完上述内容之后,点击连接测试,即可连接成功。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。