下载操作系统基镜像
docker pull oraclelinux:6.10
docker tag oraclelinux:6.10 10.240 .4 .159 /os/oraclelinux:6.10
docker push 10.240 .4 .159 /os/oraclelinux:6.10
docker pull oraclelinux:7.5
docker tag oraclelinux:7.5 10.240 .4 .159 /os/oraclelinux:7.5
docker push 10.240 .4 .159 /os/oraclelinux:7.5
BUILD数据库软件镜像 mkdir -p /docker_build/oracle_database/oel-6.10 /01 _database
cd /docker_build/oracle_database/oel-6.10 /01 _database
rz
rlwrap-0.42 .tar.gz
p13390677_112040_Linux-x86-64 _1of7.zip
p13390677_112040_Linux-x86-64 _2of7.zip
vi db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oradb
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2 .0 /db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2 .0 .4 .0 ,oracle.oraolap:11.2 .0 .4 .0 ,oracle.rdbms.dm:11.2 .0 .4 .0 ,oracle.rdbms.dv:11.2 .0 .4 .0 ,oracle.rdbms.lbac:11.2 .0 .4 .0 ,oracle.rdbms.rat:11.2 .0 .4 .0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
vi Dockerfile
FROM 10.240 .4 .159 /os/oralcelinux:6.10
ADD rlwrap-0.42 .tar.gz /tmp/
ADD p13390677_112040_Linux-x86-64 _1of7.zip /tmp/
ADD p13390677_112040_Linux-x86-64 _2of7.zip /tmp/
ADD db_install.rsp /tmp/
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle && \
yum -y install oracle-rdbms-server-11 gR2-preinstall unzip readline-devel.x86_64 lrzsz && \
cd /tmp/rlwrap-0.42 && ./configure && make && make install && \
echo "Create /u01/app dir..." && \
mkdir -p -m 755 /u01/app/dumpdir && \
mkdir -p -m 755 /u01/app/oradata && \
mkdir -p -m 755 /u01/app/oraInventory && \
mkdir -p -m 755 /u01/app/oracle && \
mkdir -p -m 755 /u01/app/oracle/product/11.2 .0 /db_1 && \
chown -R oracle:oinstall /u01 && \
unzip -oq /tmp/p13390677_112040_Linux-x86-64 _1of7.zip -d /tmp/ && \
unzip -oq /tmp/p13390677_112040_Linux-x86-64 _2of7.zip -d /tmp/ && \
chown -R oracle:oinstall /tmp/database && \
printf "%s\n" 'export ORACLE_SID=orcl' \
'export ORACLE_BASE=/u01/app/oracle' \
'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' \
'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32' \
'export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch' \
'export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK' \
'export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"' \
'alias sqlplus="rlwrap sqlplus"' \
'alias rman="rlwrap rman"' \
>>/home/oracle/.bash_profile && \
cat /etc/security/limits.conf | grep -v oracle | tee /etc/security/limits.conf && \
su oracle -c "/tmp/database/runInstaller -ignorePrereq -ignoreSysPrereqs -waitforcompletion -silent -responseFile /tmp/db_install.rsp 2>&1" && \
/u01/app/oraInventory/orainstRoot.sh && \
/u01/app/oracle/product/11.2 .0 /db_1/root.sh && \
yum clean all && \
rm -rf /tmp/* && rm -rf /var/log/* && rm -rf /var/cache/*
vi build.sh
imagetag="10.240.4.159/app/oracledatabase:11.2.0.4-software"
dockerfile="Dockerfile"
docker build --rm \
--force-rm \
--no-cache \
--memory=4 g \
--shm-size=4 g \
-t ${imagetag} \
-f ${dockerfile} .
chmod +x build.sh
./build.sh
PSU mkdir -p /docker_build/oracle_database/oel-6.10 /02 _psu
cd /docker_build/oracle_database/oel-6.10 /02 _psu
rz
ocm.rsp
p6880880_112000_Linux-x86-64. zip
p27967757_112040_Linux-x86-64 _2of7.zip
p27923163_112040_Linux-x86-64 _2of7.zip
vi Dockerfile
FROM 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -software
ADD ocm.rsp /tmp/ocm.rsp
ADD p6880880_112000_Linux-x86-64. zip /tmp/
ADD p27967757_112040_Linux-x86-64. zip /tmp/
ADD p27923163_112040_Linux-x86-64. zip /tmp/
RUN printf "%s\n" '[GENERAL]' \
'RESPONSEFILE_VERSION="11.2"' \
'CREATE_TYPE="CUSTOM"' \
'[oracle.net.ca]' \
'INSTALLED_COMPONENTS={"server","net8","javavm"}' \
'INSTALL_TYPE=""typical""' \
'LISTENER_NUMBER=1' \
'LISTENER_NAMES={"LISTENER"}' \
'LISTENER_PROTOCOLS={"TCP;1521"}' \
'LISTENER_START=""LISTENER""' \
'NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}' \
'NSN_NUMBER=1' \
'NSN_NAMES={"EXTPROC_CONNECTION_DATA"}' \
'NSN_SERVICE={"PLSExtProc"}' \
'NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}' \
>>/tmp/netca.rsp && \
unzip -oq /tmp/p6880880_112000_Linux-x86-64. zip -d /tmp/ && \
rm -rf /u01/app/oracle/product/11.2 .0 /db_1/OPatch && \
chown -R oracle:oinstall /tmp/OPatch && \
mv /tmp/OPatch /u01/app/oracle/product/11.2 .0 /db_1/ && \
unzip -qo /tmp/p27967757_112040_Linux-x86-64. zip -d /tmp && \
unzip -qo /tmp/p27923163_112040_Linux-x86-64. zip -d /tmp && \
su - oracle -c "opatch apply -silent -ocmrf /tmp/ocm.rsp -local /tmp/27967757/27734982" && \
su - oracle -c "opatch apply -silent -ocmrf /tmp/ocm.rsp -local /tmp/27923163" && \
su oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/netca -silent -responseFile /tmp/netca.rsp" && \
yum clean all && \
rm -rf /tmp/* && rm -rf /var/log/* && rm -rf /var/cache/*
vi build.sh
imagetag="10.240.4.159/app/oracledatabase:11.2.0.4-psu"
dockerfile="Dockerfile"
docker build --rm \
--force-rm \
--no-cache \
--memory=4 g \
--shm-size=4 g \
-t ${imagetag} \
-f ${dockerfile} .
chmod +x build.sh
./build.sh
安装数据库 mkdir -p /docker_build/oracle_database/oel-6.10 /03 _db
cd /docker_build/oracle_database/oel-6.10 /03 _db
vi Dockerfile
FROM 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -psu
RUN printf "%s\n" '[GENERAL]' \
'RESPONSEFILE_VERSION = "11.2.0"' \
'OPERATION_TYPE = "createDatabase"' \
'[CREATEDATABASE]' \
'GDBNAME = "orcl"' \
'DATABASECONFTYPE = "SI"' \
'SID = "orcl"' \
'TEMPLATENAME = "General_Purpose.dbc"' \
'SYSPASSWORD = "Center08"' \
'SYSTEMPASSWORD = "Center08"' \
'DATAFILEDESTINATION=/u01/app/oradata' \
'RECOVERYAREADESTINATION=/u01/app/oradata' \
'STORAGETYPE=FS' \
'CHARACTERSET="ZHS16GBK"' \
'INITPARAMS="java_jit_enabled=false,memory_target=0,sga_target=2048,pga_aggregate_target=300,processes=300,open_cursors=300"' \
'AUTOMATICMEMORYMANAGEMENT="False"' \
> /tmp/dbca.rsp && chown oracle:oinstall /tmp/dbca.rsp && chmod +x /tmp/dbca.rsp && \
su oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/dbca -silent -responseFile /tmp/dbca.rsp" && \
yum clean all && \
rm -rf /tmp/* && rm -rf /var/log/* && rm -rf /var/cache/*
vi build.sh
imagetag="10.240.4.159/app/oracledatabase:11.2.0.4-db"
dockerfile="Dockerfile"
docker build --rm \
--force-rm \
--no-cache \
--memory=4 g \
--shm-size=4 g \
-t ${imagetag} \
-f ${dockerfile} .
chmod +x build.sh
./build.sh
docker push 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4
启机后数据库自行启动 mkdir -p /docker_build/oracle_database/oel-6.10 /04 _run
cd /docker_build/oracle_database/oel-6.10 /04 _run
cp /usr/share/zoneinfo/Asia/Shanghai .
vi entrypoint.sh
set -e
/etc/init.d/sshd start
chown -R oracle:oinstall /u01
su - oracle -c "/usr/sbin/entrypoint_oracle.sh"
chmod +x entrypoint.sh
vi entrypoint_oracle.sh
set -e
source ~/.bashrc
alert_log="$ORACLE_BASE/diag/rdbms/orcl/$ORACLE_SID/trace/alert_$ORACLE_SID.log"
listener_log="$ORACLE_BASE/diag/tnslsnr/$HOSTNAME/listener/trace/listener.log"
pfile=$ORACLE_HOME/dbs/init$ORACLE_SID.ora
monitor() {
tail -F -n 0 $1 | while read line; do echo -e "$2: $line" ; done
}
trap_db() {
trap "echo 'Caught SIGTERM signal, shutting down...'; stop_db" SIGTERM;
trap "echo 'Caught SIGINT signal, shutting down...'; stop_db" SIGINT;
}
check_shm() {
echo ""
echo "Checking shared memory..."
df -h | grep "Mounted on" && df -h | egrep --color "^.*/dev/shm" || echo "Shared memory is not mounted."
}
reconfig_lsnr() {
echo ""
echo "Reconfig listener for hostname : [$HOSTNAME]..."
sed -i "s/(HOST.*)(/(HOST = $HOSTNAME)(/g" /u01/app/oracle/product/11.2 .0 /db_1/network/admin/tnsnames.ora
sed -i "s/(HOST.*)(/(HOST = $HOSTNAME)(/g" /u01/app/oracle/product/11.2 .0 /db_1/network/admin/listener.ora
echo "Show tnsnames.ora..."
cat /u01/app/oracle/product/11.2 .0 /db_1/network/admin/tnsnames.ora
echo "Show listener.ora..."
cat /u01/app/oracle/product/11.2 .0 /db_1/network/admin/listener.ora
}
start_lsnr() {
echo ""
echo "Starting listener..."
monitor $listener_log listener &
lsnrctl start | while read line; do echo -e "lsnrctl: $line" ; done
MON_LSNR_PID=$!
}
start_db() {
echo ""
echo "Starting database..."
trap_db
monitor $alert_log alertlog &
MON_ALERT_PID=$!
sqlplus / as sysdba <<-EOF |
pro Starting with pfile='$pfile' ...
startup;
alter system register;
exit 0
EOF
while read line; do echo -e "sqlplus: $line" ; done
change_dpdump_dir
change_profile_default_limit
wait $MON_ALERT_PID
}
stop_db() {
trap '' SIGINT SIGTERM
shut_immediate
echo "Shutting down listener..."
lsnrctl stop | while read line; do echo -e "lsnrctl: $line" ; done
kill $MON_ALERT_PID $MON_LSNR_PID
exit 0
}
shut_immediate() {
ps -ef | grep ora_pmon | grep -v grep > /dev/null && \
echo "Shutting down the database..." && \
sqlplus / as sysdba <<-EOF |
set echo on
shutdown immediate;
exit 0
EOF
while read line; do echo -e "sqlplus: $line" ; done
}
change_dpdump_dir () {
echo ""
echo "Changing dpdump dir to /u01/app/dumpdir"
sqlplus / as sysdba <<-EOF |
create or replace directory data_pump_dir as '/u01/app/dumpdir' ;
commit;
exit 0
EOF
while read line; do echo -e "sqlplus: $line" ; done
}
change_profile_default_limit() {
echo ""
echo "Changing profile default limit : password_life_time/failed_login_attempts"
sqlplus / as sysdba <<-EOF |
alter profile default limit password_life_time unlimited;
alter profile default limit failed_login_attempts unlimited;
commit;
exit 0
EOF
while read line; do echo -e "sqlplus: $line" ; done
}
check_shm
reconfig_lsnr
start_lsnr
start_db
chmod +x entrypoint_oracle.sh
vi Dockerfile
FROM 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -db
ADD Shanghai /etc/localtime
ADD entrypoint.sh /usr/sbin/entrypoint.sh
ADD entrypoint_oracle.sh /usr/sbin/entrypoint_oracle.sh
RUN sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config && \
echo "export LANG=en_US.utf8" >> /etc/profile && \
echo 'root:ydgw.cn' | chpasswd
ENTRYPOINT ["/usr/sbin/entrypoint.sh" ]
CMD ["" ]
vi build.sh
imagetag="10.240.4.159/app/oracledatabase:11.2.0.4-rundb"
dockerfile="Dockerfile"
docker build --rm \
--force-rm \
--no-cache \
--memory=4 g \
--shm-size=4 g \
-t ${imagetag} \
-f ${dockerfile} .
chmod +x build.sh
./build.sh
部署ORACLE服务
登陆Rancher(1.6.21),编排工具用的是默认的Cattle
应用 - 用户 - 添加应用 - 名称:[ORACLE] - 创建(已有服务此步忽略)
添加服务 - 在添加服务页面添写配置如下信息 - 创建名称: erptest2-11 g
描述: 日结后
选择镜像: 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -database
端口映射: 1521 :1522 /tcp 15620 :22 /tcp
网络 - 主机名: erptest2
安全/主机: 主机完全访问权限 内存限制 4096
调度 - 在指定主机上运行全部容器: docker156
4.启动应用(容器) - 检查检查并登录erptest2-11g服务,无问题后shutdown immediate
数据库 5.登陆宿主机,执行以下命令docker ps -a | grep oracle
ab409de14588 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -database "/.r/r /entrypoint.s…" 7 minutes ago Up 7 minutes r-Oracle-erptest1-11 g-1 -c16a25ba
295 f99a4f7d4 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -database "/.r/r /entrypoint.s…" 3 hours ago Up 3 hours r-Oracle-erptest2-1 -efd39217
cd /docker_mnt/oracledb/erptest2-20180817
docker cp 295 f99a4f7d4:/u01/app/oradata .
docker cp 295 f99a4f7d4:/u01/app/dumpdir .
docker cp 295 f99a4f7d4:/u01/app/oracle/fast_recovery_area .
docker cp 295 f99a4f7d4:/u01/app/oracle/diag .
docker cp 295 f99a4f7d4:/u01/app/oracle/product/11.2 .0 /db_1/dbs .
6.升级erptest2-11g卷 - 添加卷: /etc/localtime:/etc/localtime:ro
/docker_mnt/oracledb/erptest2-20180817 /oradata:/u01/app/oradata
/docker_mnt/oracledb/erptest2-20180817 /dpdump:/u01/app/dumpdir
/docker_mnt/oracledb/erptest2-20180817 /fast_recovery_area:/u01/app/oracle/fast_recovery_area
/docker_mnt/oracledb/erptest2-20180817 /diag:/u01/app/oracle/diag
/docker_mnt/oracledb/erptest2-20180817 /dbs:/u01/app/oracle/product/11.2 .0 /db_1/dbs
docker 限制内存, 报 not support swap limit capabilities 参考:https://segmentfault.com/q/1010000002888521
Adjust memory and swap accounting
When users run Docker, they may see these messages when working with an image:
WARNING: Your kernel does not support cgroup swap limit. WARNING: Your
kernel does not support swap limit capabilities. Limitation discarded.
To prevent these messages, enable memory and swap accounting on your system. To enable these on system using GNU GRUB (GNU GRand Unified Bootloader), do the following.
Log into Ubuntu as a user with sudo privileges.
Edit the /etc/default/grub file.
Set the GRUB_CMDLINE_LINUX value as follows:
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
Save and close the file.
Update GRUB.
$ sudo update-grub
Reboot your system.
参考
expect的用法示例 RUN yum -y install expect && \
unzip -qo /tmp/p6880880_112000_Linux-x86-64. zip -d /tmp && \
unzip -qo /tmp/p27967757_112040_Linux-x86-64. zip -d /tmp && \
unzip -qo /tmp/p27923163_112040_Linux-x86-64. zip -d /tmp && \
rm -rf /u01/app/oracle/product/11.2 .0 /db_1/OPatch && \
chown -R oracle:oinstall /tmp/OPatch && \
mv /tmp/OPatch /u01/app/oracle/product/11.2 .0 /db_1/ && \
printf "%s\n" '#!/usr/bin/expect' \
'spawn opatch apply -local /tmp/27967757/27734982/' \
'expect "*proceed*" {send "y\r"}' \
'expect "*Email*" {send "\r"}' \
'expect "*security*" {send "y\r"}' \
'expect "*patching" {send "y\r"}' \
'interact' \
>> /tmp/27967757 /27734982 /psu_apply.sh && \
printf "%s\n" '#!/usr/bin/expect' \
'spawn opatch apply -local /tmp/27923163/' \
'expect "*proceed*" {send "y\r"}' \
'expect "*Email*" {send "\r"}' \
'expect "*security*" {send "y\r"}' \
'expect "*patching" {send "y\r"}' \
'interact' \
>> /tmp/27923163 /jvm_apply.sh && \
chmod +x /tmp/27967757 /27734982 /psu_apply.sh && \
chmod +x /tmp/27923163 /jvm_apply.sh && \
su - oracle -c "/tmp/27967757/27734982/psu_apply.sh" && \
su - oracle -c "/tmp/27923163/jvm_apply.sh"
整合成一个dockerfile 制作镜像 FROM 10.240 .4 .159 /os/oraclelinux:6.10
ADD Shanghai /etc/localtime
ADD rlwrap-0.42 .tar.gz /tmp/
ADD p13390677_112040_Linux-x86-64 _1of7.zip /tmp/
ADD p13390677_112040_Linux-x86-64 _2of7.zip /tmp/
ADD p6880880_112000_Linux-x86-64. zip /tmp/
ADD p27967757_112040_Linux-x86-64. zip /tmp/
ADD p27923163_112040_Linux-x86-64. zip /tmp/
ADD db_install.rsp /tmp/
ADD ocm.rsp /tmp/ocm.rsp
ADD p6880880_112000_Linux-x86-64. zip /tmp/
ADD p27967757_112040_Linux-x86-64. zip /tmp/
ADD p27923163_112040_Linux-x86-64. zip /tmp/
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle && \
yum -y install oracle-rdbms-server-11 gR2-preinstall unzip readline-devel.x86_64 lrzsz && \
cd /tmp/rlwrap-0.42 && ./configure && make && make install && \
echo "Create /u01/app dir..." && \
mkdir -p -m 755 /u01/app/dumpdir && \
mkdir -p -m 755 /u01/app/oradata && \
mkdir -p -m 755 /u01/app/oraInventory && \
mkdir -p -m 755 /u01/app/oracle && \
mkdir -p -m 755 /u01/app/oracle/product/11.2 .0 /db_1 && \
chown -R oracle:oinstall /u01 && \
unzip -oq /tmp/p13390677_112040_Linux-x86-64 _1of7.zip -d /tmp/ && \
unzip -oq /tmp/p13390677_112040_Linux-x86-64 _2of7.zip -d /tmp/ && \
chown -R oracle:oinstall /tmp/database && \
printf "%s\n" 'export ORACLE_SID=orcl' \
'export ORACLE_BASE=/u01/app/oracle' \
'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' \
'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32' \
'export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch' \
'export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK' \
'export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"' \
'alias sqlplus="rlwrap sqlplus"' \
'alias rman="rlwrap rman"' \
>>/home/oracle/.bash_profile && \
cat /etc/security/limits.conf | grep -v oracle | tee /etc/security/limits.conf && \
su oracle -c "/tmp/database/runInstaller -ignorePrereq -ignoreSysPrereqs -waitforcompletion -silent -responseFile /tmp/db_install.rsp 2>&1" && \
/u01/app/oraInventory/orainstRoot.sh && \
/u01/app/oracle/product/11.2 .0 /db_1/root.sh && \
unzip -oq /tmp/p6880880_112000_Linux-x86-64. zip -d /tmp/ && \
rm -rf /u01/app/oracle/product/11.2 .0 /db_1/OPatch && \
chown -R oracle:oinstall /tmp/OPatch && \
mv /tmp/OPatch /u01/app/oracle/product/11.2 .0 /db_1/ && \
unzip -qo /tmp/p27967757_112040_Linux-x86-64. zip -d /tmp && \
unzip -qo /tmp/p27923163_112040_Linux-x86-64. zip -d /tmp && \
su - oracle -c "opatch apply -silent -ocmrf /tmp/ocm.rsp -local /tmp/27967757/27734982" && \
su - oracle -c "opatch apply -silent -ocmrf /tmp/ocm.rsp -local /tmp/27923163" && \
printf "%s\n" '[GENERAL]' \
'RESPONSEFILE_VERSION="11.2"' \
'CREATE_TYPE="CUSTOM"' \
'[oracle.net.ca]' \
'INSTALLED_COMPONENTS={"server","net8","javavm"}' \
'INSTALL_TYPE=""typical""' \
'LISTENER_NUMBER=1' \
'LISTENER_NAMES={"LISTENER"}' \
'LISTENER_PROTOCOLS={"TCP;1521"}' \
'LISTENER_START=""LISTENER""' \
'NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}' \
'NSN_NUMBER=1' \
'NSN_NAMES={"EXTPROC_CONNECTION_DATA"}' \
'NSN_SERVICE={"PLSExtProc"}' \
'NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}' \
>>/tmp/netca.rsp && \
su oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/netca -silent -responseFile /tmp/netca.rsp" && \
printf "%s\n" '[GENERAL]' \
'RESPONSEFILE_VERSION = "11.2.0"' \
'OPERATION_TYPE = "createDatabase"' \
'[CREATEDATABASE]' \
'GDBNAME = "orcl"' \
'DATABASECONFTYPE = "SI"' \
'SID = "orcl"' \
'TEMPLATENAME = "General_Purpose.dbc"' \
'SYSPASSWORD = "Center08"' \
'SYSTEMPASSWORD = "Center08"' \
'DATAFILEDESTINATION=/u01/app/oradata' \
'RECOVERYAREADESTINATION=/u01/app/oradata' \
'STORAGETYPE=FS' \
'CHARACTERSET="ZHS16GBK"' \
'INITPARAMS="java_jit_enabled=false,memory_target=0,sga_target=2048,pga_aggregate_target=300,processes=300,open_cursors=300"' \
'AUTOMATICMEMORYMANAGEMENT="False"' \
> /tmp/dbca.rsp && chown oracle:oinstall /tmp/dbca.rsp && chmod +x /tmp/dbca.rsp && \
su oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/dbca -silent -responseFile /tmp/dbca.rsp" && \
sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config && \
echo "export LANG=en_US.utf8" >> /etc/profile && \
yum clean all && \
rm -rf /tmp/* && rm -rf /var/log/* && rm -rf /var/cache/*
添加到rancher中
登陆Rancher(1.6.21),编排工具用的是默认的Cattle
应用 - 用户 - 添加应用 - 名称:[ORACLE] - 创建(已有服务此步忽略)
添加服务 - 在添加服务页面添写配置如下信息 - 创建名称: dev-erp
选择镜像: 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -run
端口映射: 1521 :1521 /tcp 16221 :22 /tcp
网络 - 主机名: dev-erp
安全/主机: 主机完全访问权限 内存限制 4096
调度 - 在指定主机上运行全部容器: docker162
4.启动应用(容器) - 检查检查并登录dev-erp服务,无问题后shutdown immediate
数据库 5.登陆宿主机,执行以下命令docker ps -a | grep erp
cdf49b075fb6 10.240 .4 .159 /app/oracledatabase:11.2 .0 .4 -run "/.r/r /usr/sbin/ent…" 38 minutes ago Up 38 minutes r-Oracle-erp-dev-1 -77 fbbce2
mkdir -p /docker_mnt/oracledb/dev-erp-20180925
cd /docker_mnt/oracledb/dev-erp-20180925
docker cp cdf49b075fb6:/u01/app/oradata .
docker cp cdf49b075fb6:/u01/app/dumpdir .
docker cp cdf49b075fb6:/u01/app/oracle/fast_recovery_area .
docker cp cdf49b075fb6:/u01/app/oracle/diag .
docker cp cdf49b075fb6:/u01/app/oracle/product/11.2 .0 /db_1/dbs .
6.升级卷 - 添加卷:
/docker_mnt/oracledb/dev-pos-20180925 /oradata:/u01/app/oradata
/docker_mnt/oracledb/dev-pos-20180925 /dpdump:/u01/app/dumpdir
/docker_mnt/oracledb/dev-pos-20180925 /fast_recovery_area:/u01/app/oracle/fast_recovery_area
/docker_mnt/oracledb/dev-pos-20180925 /diag:/u01/app/oracle/diag
/docker_mnt/oracledb/dev-pos-20180925 /dbs:/u01/app/oracle/product/11.2 .0 /db_1/dbs