基于docker的oracle12.2.0.1部署及oracle使用与docker镜像容器制作迁移方法
以下是一个简化的Dockerfile示例,用于创建包含Oracle 12.2.0.1数据库的Docker镜像:
# 使用Oracle Linux作为基础镜像
FROM oraclelinux:7-slim
# 设置环境变量
ENV ORACLE_SID=orcl \
ORACLE_HOME=/opt/oracle/product/12.2.0.1/dbhome_1 \
ORACLE_BASE=/opt/oracle \
PATH=$PATH:$ORACLE_HOME/bin
# 安装Oracle数据库软件所需的依赖
RUN yum -y install oracle-database-server-12cR2-preinstall \
&& yum clean all
# 设置内核参数
RUN echo 'fs.file-max=6815744' >> /etc/sysctl.conf \
&& echo 'kernel.sem=250 32000 100 128' >> /etc/sysctl.conf \
&& echo 'net.ipv4.ip_local_port_range=9000 65500' >> /etc/sysctl.conf \
&& echo 'net.core.rmem_default=262144' >> /etc/sysctl.conf \
&& echo 'net.core.wmem_default=262144' >> /etc/sysctl.conf \
&& echo 'net.core.rmem_max=4194304' >> /etc/sysctl.conf \
&& echo 'net.core.wmem_max=1048576' >> /etc/sysctl.conf \
&& sysctl -p
# 设置Oracle用户的限制
RUN echo 'oracle soft nofile 1024' >> /etc/security/limits.conf \
&& echo 'oracle hard nofile 65536' >> /etc/security/limits.conf \
&& echo 'oracle soft nproc 2047' >> /etc/security/limits.conf \
&& echo 'oracle hard nproc 16384' >> /etc/security/limits.conf \
&& echo 'oracle soft stack 10240' >> /etc/security/limits.conf \
&& echo 'oracle hard stack 32768' >> /etc/security/limits.conf
# 创建Oracle用户和组
RUN groupadd -g 54321 oinstall \
&& groupadd -g 54322 dba \
&& groupadd -g 54323 oper \
&& groupadd -g 54324 backupdba \
&& groupadd -g 54325 dgdba \
&& groupadd -g 54326 kmdba \
&& groupadd -g 54327 asmdba \
&& groupadd -g 54328 asmoper \
&& groupadd -g 54329 asmadmin \
&& useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,asmdba,asmoper,asmadmin -m oracle
# 设置Oracle环境变量
RUN echo 'export ORACLE_BASE=/opt/oracle' >> /home/oracle/.bashrc \
&& echo 'export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/dbhome_1' >> /home/oracle/.bashrc \
&& echo 'export ORACLE_SID=orcl' >> /home/oracle/.bashrc \
&& echo 'export PATH=$PATH:$ORACLE_HOME/bin' >> /home/oracle/.bashrc
# 设置工作目录权限
RUN mkdir -p /opt/oracle \
&& chown -R oracle:oinstall /opt/oracle
# 设置开机自启动
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
评论已关闭