init
This commit is contained in:
Executable
+372
@@ -0,0 +1,372 @@
|
||||
|
||||
http://211.23.61.114/ISO/OracleDB/Ora11g11.2.0.4/
|
||||
|
||||
|
||||
|
||||
```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=
|
||||
```
|
||||
|
||||
|
||||
Dockerfile-inst
|
||||
```Dockerfile
|
||||
FROM oralcelinux:6.10
|
||||
ARG NLS_LANG
|
||||
ARG ORACLE_SID
|
||||
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-11gR2-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=${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=${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/*
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
build-inst.sh:
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
imagetag="oracle:11.2.0.4-inst"
|
||||
dockerfile="Dockerfile-inst"
|
||||
docker build --rm \
|
||||
--force-rm \
|
||||
--no-cache \
|
||||
--memory=4g \
|
||||
--shm-size=4g \
|
||||
-t ${imagetag} \
|
||||
-f ${dockerfile} .
|
||||
```
|
||||
|
||||
|
||||
Dockerfile-db
|
||||
```Dockerfile
|
||||
FROM oracle:11.2.0.4-inst
|
||||
|
||||
# Set environment variables
|
||||
ENV ORACLE_BASE=/u01/app/oracle
|
||||
ENV ORACLE_HOME=${ORACLE_BASE}/product/11.2.0/db_1
|
||||
ENV PATH=$PATH:${ORACLE_HOME}/bin
|
||||
|
||||
# Build arguments with default password values
|
||||
ARG SYSPASSWORD=admingzzn
|
||||
ARG SYSTEMPASSWORD=admingzzn
|
||||
ARG ORACLE_SID=orcl
|
||||
|
||||
# Set environment variables for oracle user
|
||||
RUN printf "%s\n" \
|
||||
'export ORACLE_BASE=/u01/app/oracle' \
|
||||
'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' \
|
||||
'export ORACLE_SID=$ORACLE_SID' \
|
||||
'export PATH=$PATH:$ORACLE_HOME/bin' \
|
||||
>> /home/oracle/.bash_profile
|
||||
|
||||
|
||||
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 && \
|
||||
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 = "${ORACLE_SID}"' \
|
||||
'DATABASECONFTYPE = "SI"' \
|
||||
'SID = "orcl"' \
|
||||
'TEMPLATENAME = "General_Purpose.dbc"' \
|
||||
'SYSPASSWORD = \"${SYSPASSWORD}\"' \
|
||||
'SYSTEMPASSWORD = \"${SYSTEMPASSWORD}\"' \
|
||||
'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
|
||||
|
||||
# Cleanup
|
||||
RUN yum clean all && \
|
||||
rm -rf /tmp/* /var/log/* /var/cache/*
|
||||
|
||||
```
|
||||
|
||||
build-db.sh
|
||||
```bash
|
||||
imagetag="oracle:11.2.0.4-db"
|
||||
dockerfile="Dockerfile-db"
|
||||
docker build --rm \
|
||||
--force-rm \
|
||||
--no-cache \
|
||||
--memory=4g \
|
||||
--shm-size=4g \
|
||||
-t ${imagetag} \
|
||||
-f ${dockerfile} .
|
||||
```
|
||||
|
||||
|
||||
entrypoint_oracle.sh:
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
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 $logfile
|
||||
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 shared memory
|
||||
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 listener
|
||||
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 listener
|
||||
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 database
|
||||
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 database
|
||||
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
|
||||
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
|
||||
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 shared memory
|
||||
check_shm
|
||||
# Reconfig listener
|
||||
reconfig_lsnr
|
||||
# Start listener
|
||||
start_lsnr
|
||||
# Start database
|
||||
start_db
|
||||
```
|
||||
|
||||
entrypoint.sh :
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
/etc/init.d/sshd start
|
||||
find /u01 ! -user oracle -o ! -group oinstall -exec chown oracle:oinstall {} +
|
||||
su - oracle -c "/usr/sbin/entrypoint_oracle.sh"
|
||||
```
|
||||
|
||||
Dockerfile-run
|
||||
```Dockerfile
|
||||
# Use Oracle Database 11.2.0.4 as the base image
|
||||
FROM oracle:11.2.0.4-db
|
||||
|
||||
# Set the timezone to Shanghai
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# Set environment variables
|
||||
ENV LANG=en_US.utf8
|
||||
|
||||
# Copy entry point scripts
|
||||
ADD entrypoint.sh /usr/sbin/entrypoint.sh
|
||||
ADD entrypoint_oracle.sh /usr/sbin/entrypoint_oracle.sh
|
||||
|
||||
# Make scripts executable
|
||||
RUN chmod +x /usr/sbin/entrypoint.sh /usr/sbin/entrypoint_oracle.sh
|
||||
|
||||
# Modify SSH configuration (with security considerations)
|
||||
# It's recommended to create a non-root user and use SSH keys
|
||||
# RUN sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config
|
||||
|
||||
# Set the root password securely (not recommended to hardcode)
|
||||
# ARG ROOT_PASSWORD
|
||||
# RUN echo "root:${ROOT_PASSWORD}" | chpasswd
|
||||
|
||||
EXPOSE 1521
|
||||
|
||||
# Set the entry point
|
||||
ENTRYPOINT ["/usr/sbin/entrypoint.sh"]
|
||||
CMD [""]
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
debain can't run oraclelinux
|
||||
```
|
||||
I believe this is the vsyscall=emulate problem:
|
||||
|
||||
If `sudo grep vsyscall /proc/1/maps` prints nothing, then edit `/etc/default/grub` and append `vsyscall=emulate` to the variable `GRUB_CMDLINE_LINUX_DEFAULT`. Then run a `sudo update-grub` and reboot.
|
||||
|
||||
Additional references: [https://github.com/JiscSD/rdss-archivematica/issues/65](https://github.com/JiscSD/rdss-archivematica/issues/65) , [Enalean/docker-tuleap-aio#57](https://github.com/Enalean/docker-tuleap-aio/issues/57) , [moby/moby#28705](https://github.com/moby/moby/issues/28705)
|
||||
|
||||
👍8
|
||||
```
|
||||
Reference in New Issue
Block a user