Oracle Enterprise Manager (OEM) is a set of web-based tools aimed at managing software and hardware produced by Oracle Corporation as well as by some non-Oracle entities.

Download OEM package:https://www.oracle.com/enterprise-manager/downloads/cloud-control-downloads.html

Installation Information

  • Operating System: oracle linux 7.9
  • CPU core: > 2
  • Memory: > 8GB
  • Disk space: > 100GB
  • Swap size: 16GB
  • Package: oracle-database-preinstall-19c
  • Selinux: permissive
  • Firewall: 22/1521/7803/3872/4903

System environment preparation

# calculate the swap partition size
swap_size=16384
echo "adding swap partition with size of $swap_size ..."
dd if=/dev/zero of=/swapfile bs=1M count="$swap_size"
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
[ -z "$(grep swapfile /etc/fstab)" ] && echo '/swapfile    swap    swap    defaults    0 0' >>/etc/fstab

# init system package and oracle user
yum update -y && yum groupinstall "Development Tools" -y && yum install oracle-database-preinstall-19c lrzsz vim wget htop zip -y
yum install -y binutils gcc gcc-c++ glibc glibc-devel glibc-devel.i686 libaio libaio-devel libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel libnsl sysstat motif motif-devel redhat-lsb redhat-lsb-core openssl make compat-libcap1 compat-libstdc++-33 compat-libstdc++-33.i686 dejavu-serif-fonts ksh numactl numactl-devel

# turn off selinux and firewall
systemctl stop firewalld
systemctl stop iptables
systemctl disable firewalld
systemctl disable iptables
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux

Start installing oracle database 19c

Before installing OEM we need to install the oracle database first.

Installation directory and environment variable preparation

# create an Oracle database installation directory
# dbhome_1 serves as the $ORACLE_HOME path and is assigned to the oracle account
mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
chown -R oracle:oinstall /u01 && chmod -R 775 /u01

# backup .bash_profile file
mv /home/oracle/.bash_profile /home/oracle/bash_profile-$(date '+%Y%m%d%H%M%S')

# set oracle user profile
cat >/home/oracle/.bash_profile <<EOF
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

# Fake Oracle Linux 8
export CV_ASSUME_DISTID=OEL7.9

# Oracle Settings
export ORACLE_HOSTNAME=oracle-db-19c.test.com
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/19.0.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=oem
export PATH=.:\$PATH:\$HOME/bin:\$ORACLE_HOME/bin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
EOF

chown oracle:oinstall /home/oracle/.bash_profile

# import environment variable
source /home/oracle/.bash_profile

Decompress the installation package

su -c "unzip -q ~/software/LINUX.X64_193000_db_home.zip -d /u01/app/oracle/product/19.0.0/dbhome_1" oracle

Install oracle database 19c

# silent installation because no graphics are installed
su -c "/u01/app/oracle/product/19.0.0/dbhome_1/runInstaller -ignorePrereq -waitforcompletion -silent -responseFile ${ORACLE_HOME}/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=${ORA_INVENTORY} \
SELECTED_LANGUAGES=en,zh_CN \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=racdba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true" oracle

# root run script
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.0.0/dbhome_1/root.sh

Create oem database

# create oracle data folder
mkdir -p /u01/oradata
chown oracle:oinstall /u01/oradata

# set oracle database envionment variables
export ORACLE_SID=oem
export SYS_PASSWORD="Test-1234"
export DATA_DIR=/u01/oradata

# create oracle database
su -c "dbca -silent -createDatabase \
  -templateName General_Purpose.dbc \
  -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE \
  -characterSet AL32UTF8 \
  -sysPassword ${SYS_PASSWORD} \
  -systemPassword ${SYS_PASSWORD} \
  -createAsContainerDatabase false \
  -databaseType MULTIPURPOSE \
  -memoryMgmtType auto_sga \
  -totalMemory 2048 \
  -storageType FS \
  -datafileDestination "${DATA_DIR}" \
  -redoLogFileSize 600 \
  -emConfiguration NONE \
  -ignorePreReqs" oracle

Set oracle oem database parameter

su - oracle -c "sqlplus / as sysdba <<EOF
alter user system identified by \"Test-1234\";
alter system set db_domain='test.com' scope=spfile;
exit;
EOF"

# set oracle parameter
su - oracle -c "sqlplus / as sysdba <<EOF
alter system set db_create_file_dest='${DATA_DIR}';

-- Recommended minimum settings.
alter system set \"_allow_insert_with_update_check\" = true scope=both;
alter system set session_cached_cursors=200 scope=spfile;
 
-- Recommended: processes=600
alter system set processes=600 scope=spfile;

-- Recommended: pga_aggregate_target=1G
alter system set pga_aggregate_target=450M scope=spfile;

-- Recommended: sga_target=3G
alter system set sga_target=800M scope=spfile;

-- Recommended: shared_pool_size=600M
--alter system set shared_pool_size=600M scope=spfile;


SHUTDOWN IMMEDIATE;
STARTUP;

exit;
EOF"

# start listener
# su - oracle -c "netca -silent -responseFile $ORACLE_HOME/assistants/netca/netca.rsp"
su - oracle -c "lsnrctl start"

# set restart flag in /etc/oratab.
sed -i 's/:N$/:Y/' /etc/oratab

Install OEM

When the oracle database is ready, we can start installing the OEM.

# download oem package
su -c "chmod +x ~/software/em13500_linux64.bin" oracle

Generate response file

# generate a basic response file
su -c "/home/oracle/software/em13500_linux64.bin -getResponseFileTemplates -outputLoc /tmp/" oracle

# set oracle cloud control env parameters
ORACLE_BASE=/u01/app/oracle
UNIX_GROUP_NAME=oinstall
ORA_INVENTORY=/u01/app/oraInventory
MW_HOME=${ORACLE_BASE}/middleware
ORACLE_HOSTNAME=${HOSTNAME}
AGENT_BASE=${ORACLE_BASE}/agent
WLS_USERNAME=weblogic
WLS_PASSWORD=WLS_PASSWORD
GC_INST=${ORACLE_BASE}/gc_inst
SOFTWARE_LIBRARY=${ORACLE_BASE}/swlib
DATABASE_HOSTNAME=localhost
LISTENER_PORT=1521
DB_NAME=oem
SYS_PASSWORD=Test-1234
AGENT_PASSWORD=${WLS_PASSWORD}
ORACLE_SID=oem
DATA_DIR=/u01/oradata
OMS_HOME=${MW_HOME}
SYSMAN_PASSWORD=${WLS_PASSWORD}
SOFTWARE_DIR=/home/oracle/software

# create response file.
cat > /tmp/install.rsp <<EOF
RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME=${UNIX_GROUP_NAME}
INVENTORY_LOCATION=${ORA_INVENTORY}
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
INSTALL_UPDATES_SELECTION=skip
ORACLE_MIDDLEWARE_HOME_LOCATION=${MW_HOME}
ORACLE_HOSTNAME=${ORACLE_HOSTNAME}
AGENT_BASE_DIR=${AGENT_BASE}
WLS_ADMIN_SERVER_USERNAME=${WLS_USERNAME}
WLS_ADMIN_SERVER_PASSWORD=${WLS_PASSWORD}
WLS_ADMIN_SERVER_CONFIRM_PASSWORD=${WLS_PASSWORD}
NODE_MANAGER_PASSWORD=${WLS_PASSWORD}
NODE_MANAGER_CONFIRM_PASSWORD=${WLS_PASSWORD}
ORACLE_INSTANCE_HOME_LOCATION=${GC_INST}
CONFIGURE_ORACLE_SOFTWARE_LIBRARY=true
SOFTWARE_LIBRARY_LOCATION=${SOFTWARE_LIBRARY}
DATABASE_HOSTNAME=${DATABASE_HOSTNAME}
LISTENER_PORT=${LISTENER_PORT}
SERVICENAME_OR_SID=${DB_NAME}
SYS_PASSWORD=${SYS_PASSWORD}
SYSMAN_PASSWORD=${SYSMAN_PASSWORD}
SYSMAN_CONFIRM_PASSWORD=${SYSMAN_PASSWORD}
DEPLOYMENT_SIZE=SMALL
AGENT_REGISTRATION_PASSWORD=${AGENT_PASSWORD}
AGENT_REGISTRATION_CONFIRM_PASSWORD=${AGENT_PASSWORD}
PLUGIN_SELECTION={}
b_upgrade=false
EM_INSTALL_TYPE=NOSEED
CONFIGURATION_TYPE=LATER
CONFIGURE_SHARED_LOCATION_BIP=false
MANAGEMENT_TABLESPACE_LOCATION=${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}/mgmt.dbf
CONFIGURATION_DATA_TABLESPACE_LOCATION=${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}/mgmt_ecm_depot1.dbf
JVM_DIAGNOSTICS_TABLESPACE_LOCATION=${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}/mgmt_deepdive.dbf
EOF

chown oracle:oinstall /tmp/install.rsp

Initialize oem configuration file

unset CLASSPATH
su -c "${SOFTWARE_DIR}/em13500_linux64.bin -silent -responseFile /tmp/install.rsp" oracle

# root run this script
sh ${MW_HOME}/allroot.sh

Create OEM data directory

mkdir -p ${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}
chown oracle:oinstall ${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}

Configure oracle cloud control

# configure oracle cloud control, create a response file for the configuration process.
cat > /tmp/config.rsp <<EOF
RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME=${UNIX_GROUP_NAME}
INVENTORY_LOCATION=${ORA_INVENTORY}
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
INSTALL_UPDATES_SELECTION=skip
ORACLE_MIDDLEWARE_HOME_LOCATION=${MW_HOME}
ORACLE_HOSTNAME=${ORACLE_HOSTNAME}
AGENT_BASE_DIR=${AGENT_BASE}
WLS_ADMIN_SERVER_USERNAME=${WLS_USERNAME}
WLS_ADMIN_SERVER_PASSWORD=Test1234
WLS_ADMIN_SERVER_CONFIRM_PASSWORD=Test1234
NODE_MANAGER_PASSWORD=Test1234
NODE_MANAGER_CONFIRM_PASSWORD=Test1234
ORACLE_INSTANCE_HOME_LOCATION=${GC_INST}
CONFIGURE_ORACLE_SOFTWARE_LIBRARY=true
SOFTWARE_LIBRARY_LOCATION=${SOFTWARE_LIBRARY}
DATABASE_HOSTNAME=${DATABASE_HOSTNAME}
LISTENER_PORT=${LISTENER_PORT}
SERVICENAME_OR_SID=${DB_NAME}
SYS_PASSWORD=${SYS_PASSWORD}
SYSMAN_PASSWORD=Test1234
SYSMAN_CONFIRM_PASSWORD=Test1234
DEPLOYMENT_SIZE=SMALL
AGENT_REGISTRATION_PASSWORD=Test1234
AGENT_REGISTRATION_CONFIRM_PASSWORD=Test1234
PLUGIN_SELECTION={}
b_upgrade=false
EM_INSTALL_TYPE=NOSEED
CONFIGURATION_TYPE=ADVANCED
CONFIGURE_SHARED_LOCATION_BIP=false
MANAGEMENT_TABLESPACE_LOCATION=${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}/mgmt.dbf
CONFIGURATION_DATA_TABLESPACE_LOCATION=${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}/mgmt_ecm_depot1.dbf
JVM_DIAGNOSTICS_TABLESPACE_LOCATION=${DATA_DIR}/${ORACLE_SID^^}/${DB_NAME}/mgmt_deepdive.dbf
EOF

chown oracle:oinstall /tmp/config.rsp

# run the configuration using the response file, making sure that CLASSPATH is not set.
unset CLASSPATH
su -c "${MW_HOME}/sysman/install/ConfigureGC.sh -silent -responseFile /tmp/config.rsp" oracle

Set OEM auto start

# set up auto-start at boot
file_path="/etc/init.d/dbora"
if [ -f "$file_path" ]; then
    backup_file="$file_path.$(date +"%Y%m%d%H%M%S").bak"
    mv "$file_path" "$backup_file"
fi

cat << EOF > "$file_path"
#! /bin/sh -x
#
# chkconfig: 2345 80 05
# description: start and stop Oracle Database Enterprise Edition on Oracle Linux 5 and 6
#

# In /etc/oratab, change the autostart field from N to Y for any
# databases that you want autostarted.
#
# Create this file as /etc/init.d/dbora and execute:
#  chmod 750 /etc/init.d/dbora
#  chkconfig --add dbora
#  chkconfig dbora on

# Note: Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
# ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
OMS_HOME=/u01/app/oracle/middleware
#
# Note: Change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle

PATH=\${PATH}:\$ORACLE_HOME/bin
HOST=\`hostname\`
PLATFORM=\`uname\`
export ORACLE_HOME PATH

case \$1 in
'start')
        echo -n $"Starting Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbstart \$ORACLE_HOME"
        sleep 5
        su \$ORACLE -c "\$ORACLE_HOME/bin/lsnrctl start"
        sleep 5
        su \$ORACLE -c "\$OMS_HOME/bin/emctl start oms"

        ;;
'stop')
        echo -n $"Shutting down Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbshut \$ORACLE_HOME"
        ;;
'restart')
        echo -n $"Shutting down Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbshut \$ORACLE_HOME"
        sleep 5
        echo -n $"Starting Oracle: "
        su \$ORACLE -c "\$ORACLE_HOME/bin/dbstart \$ORACLE_HOME"
        ;;
*)
        echo "usage: \$0 {start|stop|restart}"
        exit
        ;;
esac

exit 0
EOF

chmod 750 /etc/init.d/dbora
chkconfig --add dbora
chkconfig dbora on
chkconfig --list |grep dbora

Login info

# login oracle cloud crontrol
# https://$your_host_ip:7803/em
# user:sysman
# pwd:Test1234

Prepare OEM agent installation package

export OMS_HOME=/u01/app/oracle/middleware
rm -rf /tmp/oms_soft/*
echo passwd | $OMS_HOME/bin/emcli login -username=sysman
$OMS_HOME/bin/emcli sync
$OMS_HOME/bin/emcli get_supported_platforms
$OMS_HOME/bin/emcli get_agentimage -destination=/tmp/oms_soft -platform="Linux x86-64" -version=13.5.0.0.0

aws s3 rm s3://test-oracle/Packages/oracle-emcc/agent/ --exclude "" --include "Agent" --recursive aws s3 cp /tmp/oms_soft/.zip s3://test-oracle/Packages/oracle-emcc/agent/
aws s3 ls s3://test-oracle/Packages/oracle-emcc/agent/
aws s3 ls s3://test-oracle/Packages/oracle-emcc/agent/ --recursive | grep "Agent" | awk '{print $4}' | xargs -I {} aws s3api put-object-acl --bucket test-oracle --key {} --acl public-read

Install oracle manager agent

# environment variables
OEM_HOSTNAME="oem"
OEM_IP_ADRESS="192.168.100.10"
AGENT_DIR="/u01/app/agent"
TMP_DIR="$AGENT_DIR/agent_tmp"
KEYWORD="Agent"
HOST_IP=$(hostname -I | awk '{print $1}' | grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}")
NEW_HOSTNAME="$HOSTNAME"
RESPONSE_FILE="$TMP_DIR/agentInstall.rsp"
AGENT_IMAGE="$TMP_DIR/agentimage.properties"

# environment variables
OEM_HOSTNAME="oem"
OEM_IP_ADRESS="192.168.100.10"
AGENT_DIR="/u01/app/agent"
TMP_DIR="$AGENT_DIR/agent_tmp"
KEYWORD="Agent"
HOST_IP=$(hostname -I | awk '{print $1}' | grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}")
NEW_HOSTNAME="$HOSTNAME"
RESPONSE_FILE="$TMP_DIR/agentInstall.rsp"
AGENT_IMAGE="$TMP_DIR/agentimage.properties"

mkdir -p $AGENT_DIR

# download oem package to local
aws s3 cp s3://test-oracle/Packages/oracle-emcc/agent/ /u01/app/agent/ --recursive --exclude "*" --include "*Agent*"

ZIP_FILE=$(find "$AGENT_DIR" -name "*$KEYWORD*.zip" -print -quit)

# check oem agent package
if [ -z "$ZIP_FILE" ]; then
  echo "oem agent installation package not found"
  exit 1
else
  unzip -q "$ZIP_FILE" -d "$TMP_DIR"
fi

AGENT_VERSION=$(grep '^VERSION=' "$AGENT_IMAGE" | cut -d'=' -f2)

# prepare response file
cat <<EOF >"$RESPONSE_FILE"
ORACLE_HOSTNAME=$NEW_HOSTNAME.test.test
OMS_HOST=$OEM_HOSTNAME.test.test
ORACLE_HOME=/u01/app/agent/agent_$AGENT_VERSION
AGENT_PORT=3872
EM_UPLOAD_PORT=4903
AGENT_BASE_DIR=/u01/app/agent
AGENT_INSTANCE_HOME=/u01/app/agent/agent_inst
AGENT_REGISTRATION_PASSWORD=Test1234
EMCTLCFG_MODE=NONE
START_AGENT=true
s_encrSecurePwd=
b_forceConfigure=false
b_sharedAgents=false
b_secureAgent=true
b_noUpgrade=true
b_agentupgrade=false
b_doDiscovery=true
b_forceInstCheck=true
-ignorePrereqs
-force
EOF

# update agent working directory permissions
chown -R oracle:oinstall $AGENT_DIR

# install agent
su -c "$TMP_DIR/agentDeploy.sh RESPONSE_FILE=$RESPONSE_FILE AGENT_BASE_DIR=$AGENT_DIR/oem_agent" oracle

$AGENT_DIR/agent_"$AGENT_VERSION"/root.sh

Test agent upload data to oem

/u01/app/agent/agent_13.5.0.0.0/bin/emctl upload

Add database in oem

When the server and client have been deployed, the database host will automatically join the OEM, and we can add the database to the OEM panel for monitoring.

  • oem index page
    • targets
      • database
        • add
          • oracle database
            • specify host or cluster --> search
              • select target host
                • next
                  • select target database name
                    • set database user and password
                      • test connection
                        • next
                          • save