oracle docker安装

修改下载的Image的REPOSITORY和TAG属性

修改下载的Image的REPOSITORY和TAG属性:docker tag <IMAGE ID> <REPOSITORY NAME> docker tag 3fa112fd3642 aliyun/oracle_11g 参考网址 使用docker images时,可能会出现REPOSITORY和TAG均为none的镜像 docker tag IMAGEID(镜像id) REPOSITORY:TAG(仓库:标签)

1.拉取oracle镜像

用管理员权限打开cmd窗口,输入下面命令

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

2.下载完成以后,查看镜像。

docker images

3.创建容器

oracle11g是容器的名字,创建成功后会返回一个字符串

docker run -d --p 1521:1521 --name oracle11g aliyun/oracle_11g

4.启动容器

docker start oracle11g

docker linux 内核7以下会出现此类问题Windows使用Docker出现exit 139错误 建议直接升级内核或者 采用 如下配置 创建C:\Users(用户名).wslconfig,里面写入,写入后重启电脑,切记setting 中General 中选中Use the wsl2 based engine 可以参考:

复制代码
[wsl2]
kernelCommandLine = vsyscall=emulate
  • 存储在%UserProfile%目录中。

  • 用于在作为WSL2版本运行的所有已安装Linux发行版中全局配置设置。可用于WSL2运行的发行版。

  • 作为WSL 1运行的发行版不会受到此配置的影响,因为它们不是作为虚拟机运行的。

要访问您的%UserProfile%目录,请在PowerShell中使用CD~访问您的主目录(通常是您的用户配置文件,C:\Users<UserName>),或者您可以打开Windows文件资源管理器并在地址栏中输入%UserProfile%。目录路径应该类似于:C:\Users<UserName>\。wslconfig。WSL将检测这些文件的存在,读取内容,并在每次启动WSL时自动应用配置设置。如果文件丢失或格式不正确(标记格式不正确),WSL将继续正常启动,而不应用配置设置。 检查您正在运行的WSL版本。 使用wsl调整每个分发设置。conf文件仅在Windows Build 17093及更高版本中可用。 wslconfig的配置设置

这个wslconfig文件全局配置运行WSL2的所有Linux发行版的设置。(对于每个分发配置,请参见wsl.conf)。

看见WSLConfigf以获取有关存储位置的信息。wslconfig文件。 具有的全局配置选项。wslconfigis仅适用于在Windows Build 19041及更高版本中作为WSL 2运行的发行版。请记住,您可能需要运行WSL--shutdown来关闭WSL2VM,然后重新启动WSL实例,以使这些更改生效。

此文件可以包含影响为任何WSL 2发行版供电的VM的以下选项:

节标签:[wsl2]

key value default notes
kernel string The Microsoft built kernel provided inbox An absolute Windows path to a custom Linux kernel.
memory size 50% of total memory on Windows or 8GB, whichever is less; on builds before 20175: 80% of your total memory on Windows How much memory to assign to the WSL 2 VM.
processors number The same number of processors on Windows How many processors to assign to the WSL 2 VM.
localhostForwarding boolean true Boolean specifying if ports bound to wildcard or localhost in the WSL 2 VM should be connectable from the host via localhost:port.
kernelCommandLine string Blank Additional kernel command line arguments.
swap size 25% of memory size on Windows rounded up to the nearest GB How much swap space to add to the WSL 2 VM, 0 for no swap file. Swap storage is disk-based RAM used when memory demand exceeds limit on hardware device.
swapFile string %USERPROFILE%\AppData\Local\Temp\swap.vhdx An absolute Windows path to the swap virtual hard disk.
pageReporting boolean true Default true setting enables Windows to reclaim unused memory allocated to WSL 2 virtual machine.
guiApplications boolean* true Boolean to turn on or off support for GUI applications (WSLg) in WSL. Only available for Windows 11.
debugConsole boolean* false Boolean to turn on an output console Window that shows the contents of dmesg upon start of a WSL 2 distro instance. Only available for Windows 11.
nestedVirtualization boolean* true Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11.
vmIdleTimeout number* 60000 The number of milliseconds that a VM is idle, before it is shut down. Only available for Windows 11.
带有pathValue的条目必须是带有转义反斜杠的Windows路径,例如:C:\Temp\myCustomKernel

带有SizeValue的条目必须是后跟单位的大小,例如8GB或512MB。

值类型后面带有*的条目仅在Windows 11上可用。

实例wslconfig文件 这个下面的wslconfigsample文件演示了一些可用的配置选项。在本例中,文件路径为isC:\Users<UserName>\。wslconfig。

复制代码
# Settings apply across all Linux distros running on WSL 2
[wsl2]
​
# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=4GB
​
# Sets the VM to use two virtual processors
processors=2
​
# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel
kernel=C:\\temp\\myCustomKernel
​
# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
kernelCommandLine = vsyscall=emulate
​
# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=8GB
​
# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
swapfile=C:\\temp\\wsl-swap.vhdx
​
# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
pageReporting=false
​
# Turn off default connection to bind WSL 2 localhost to Windows localhost
localhostforwarding=true 
​
# Disables nested virtualization
nestedVirtualization=false
​
# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
debugConsole=true

5.进行镜像配置

进入oracle的命令环境中

docker exec -it oracle11g bash

切换oracle数据库的root用户下,密码helowin

su root 输入密码 helowin vi /etc/profile

修改profile的配置文件

输入命令 : vi /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
​

关于vi编译器这里简单介绍,使用vi查看文件后,按 "i"进入insert模式,这个时候你就可以编辑了,编辑完成后按"ESC"退出inset模式进入底线命令模式,输入":wq"保存并退出。编辑完成后使用source命令刷新

source /etc/profile

创建软链接

创建软连接方便后面登录

ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

切换oracle用户

切换oracle环境

su - oracle

登录sqlplus,修改sys、system用户密码,创建用户

登录连接数据库,修改密码,创建新用户

复制代码
//登录
 sqlplus /nolog
​
//连接
conn /as sysdba
​
复制代码
//修改密码
alter user system identified by system;
alter user sys identified by sys;
​
//创建用户
create user test identified by test;
//并给用户赋予权限
grant connect,resource,dba to test;
​
//创建用户
create user dev identified by dev;
//并给用户赋予权限
grant connect,resource,dba to dev;
​
​

注意事项 当我们修改密码时,弹出database not open和database not mount

解决办法: alter database mount alter database open

相关推荐
秃头摸鱼侠几秒前
MySQL安装与配置
数据库·mysql·adb
UGOTNOSHOT5 分钟前
每日八股文6.3
数据库·sql
行云流水行云流水29 分钟前
数据库、数据仓库、数据中台、数据湖相关概念
数据库·数据仓库
John Song31 分钟前
Redis 集群批量删除key报错 CROSSSLOT Keys in request don‘t hash to the same slot
数据库·redis·哈希算法
IvanCodes1 小时前
七、Sqoop Job:简化与自动化数据迁移任务及免密执行
大数据·数据库·hadoop·sqoop
tonexuan1 小时前
MySQL 8.0 绿色版安装和配置过程
数据库·mysql
JohnYan1 小时前
工作笔记- 记一次MySQL数据移植表空间错误排除
数据库·后端·mysql
我最厉害。,。2 小时前
Windows权限提升篇&数据库篇&MYSQL&MSSQL&ORACLE&自动化项目
数据库·mysql·sqlserver
远方16092 小时前
20-Oracle 23 ai free Database Sharding-特性验证
数据库·人工智能·oracle
GoodStudyAndDayDayUp2 小时前
初入 python Django 框架总结
数据库·python·django