Changer le répertoire d’installation d’un agent Cloud Control 12c

Cet article présente la procédure pour déplacer un agent Cloud Contol 12c d’un répertoire vers un autre et/ou pour modifier le port de l’agent.

Cette opération est rapide à réaliser et peut être effectuée à chaud, un blackout de la supervision étant réalisé.
A noter que le nom de l’agent – avec l’ancien numéro de port – est conservé : <hostname>:<ancien port>.
Le prérequis est le téléchargement du script perl ConvertToStandalone.pl sur le support Oracle à partir de la note suivante : « EM 12c : How to Move / Migrate an AGENT BASE DIRECTORY to New Location ?(Doc ID 2021782.1) ».
– Se connecter avec le compte oracle sur le serveur de l’agent à déplacer :

mkdir

– Vérifier l’état de l’agent :

/agent_inst/bin/emctl status agent

– Recréer le fichier plugins.txt (cette étape est nécessaire en cas de déploiement de plugins) :

/core//perl/bin/perl /core//sysman/install/create_plugin_list.pl -instancehome /core/

– Contrôler la présence de fichier appartenant à root (modifier les droits des fichiers autre que /sbin/nm*) :

find  -uid 0

Si d’autres fichiers existent, modifier les droits des fichiers (root vers oracle).
– Supprimer le répertoire lost+found (si besoin) :

rmdir /lost+found

– Déplacer l’agent vers le nouveau répertoire :

export OLD_AGENT_HOME=/core/
export ORACLE_HOME=/core/
$OLD_AGENT_HOME/perl/bin/perl /tmp/ConvertToStandalone.pl -instanceHome /agent_inst -newAgentBaseDir
Migrating the agent home to different home
Validating the arguments
The log file is /agent_inst/install/logs/convert/convertingtostandalone_2015-07-20_16-15-51.log
The agent image file Exists : /agentimage.properties. Check for value of : VERSION
The current home is /core/Software only install of the agent bits
The command is cp -r /core /plugins /agentimage.properties /plugins.txt
The command exitcode 0
The command is cp -r /sbin
cp: cannot open `/sbin/nmhs` for reading: Permission denied
cp: cannot open `/sbin/nmo` for reading: Permission denied
cp: cannot open `/sbin/nmb` for reading: Permission denied
The command exitcode 256
Copying of /sbinto  Failed
The command is /core//oui/bin/runInstaller -clone -forceClone -silent -waitForCompletion -nowait ORACLE_HOME=/core/ -noconfig -force EM_PROTOCOL=https ORACLE_HOME_NAME=agent12c -invPtrLoc /core//oraInst.loc AGENT_BASE_DIR=
The command exitcode 0
The command is /core//oui/bin/runInstaller -attachHome -force -silent ORACLE_HOME=/sbin ORACLE_HOME_NAME=sbin12c -waitForCompletion -invPtrLoc /core//oraInst.loc
The command exitcode 0
The command is /core//oui/bin/runInstaller -updateHomeDeps -waitForCompletion HOME_DEPENDENCY_LIST={/sbin:/core/} -invPtrLoc /core//oraInst.loc
The command exitcode 0
Converting the agent to standalone
The command is /agent_inst/bin/emctl start blackout AGT_CNT_BLK_OUT -nodeLevel
The command exitcode 0
The command is /agent_inst/bin/emctl stop agent
The command exitcode 0
The command is cp -r /agent_inst/* /agent_inst
The command exitcode 0
The command is /core//jdk/bin/java -jar /core//jlib/updateStateDirectory.jar -migrateBase -emStateDir /agent_inst -oldAgentHome /core/ -newAgentHome /core/ -oldAgentBase  -newAgentBase
The command exitcode 0
The command is /agent_inst/bin/emctl setproperty agent -name agentStateDir -value /agent_inst
The command exitcode 0
The command is /core//perl/bin/perl /core//bin/AgentPluginDeploy.pl -oracleHome /core/ -agentDir  -pluginIdsInfoFile /plugins.txt -action upgrade -emStateDir /agent_inst -ignoreUnzip -dont_restart
The command exitcode 0
The command is /agent_inst/bin/emctl update_inventory plugin
The command exitcode 0
The command is /core//jdk/bin/java -jar /core//jlib/upgradeCollections.jar -emStateDir /agent_inst -newPluginXml /core//sysman/admin/agentLib.xml -oldPluginXml /core//sysman/admin/agentLib.xml
log4j:ERROR No appenders could be found for category (oracle.sysman.gcagent.util.logging.ODLLogging).
log4j:ERROR Please initialize the log4j system properly.
The command exitcode 0
The command is /agent_inst/bin/emctl start agent
The command exitcode 0
The command is /agent_inst/bin/emctl stop blackout AGT_CNT_BLK_OUT
The command exitcode 0
The command is mv /agent_inst/bin/emctl /agent_inst/bin/emctl_converted
The command exitcode 0
Move of File :  /agent_inst/bin/emctl to File : /agent_inst/bin/emctl_converted is successfully done
Modifying the oragchomelist to include the current agent home with the instancehome
The migration is completed Successfully. Run /core//root.sh as root user manually.
Deinstall agent home /core/ manually.

Les messages « Permission denied » peuvent être ignorés.
– Se connecter avec le compte root et exécuter les commandes suivantes :

/core//root.sh

– Se connecter avec le compte oracle et désinstaller l’ancien agent :

/agent_inst/bin/emctl status agent
/core//perl/bin/perl /core//sysman/install/AgentDeinstall.pl -agentHome /core// -skipRemoval
Agent Oracle Home: /core/
agentHome = /core/
NOTE: The agent base directory:  will be removed after successful deinstallation of agent home.
DetachHome Command executed:/core//oui/bin/runInstaller -detachHome -force -depHomesOnly -silent ORACLE_HOME=/core/ -waitForCompletion -invPtrLoc /core//oraInst.loc
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB.   Actual 24575 MB    Passed
The inventory pointer is located at /core//oraInst.loc
'DetachHome' was successful.
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB.   Actual 24575 MB    Passed
The inventory pointer is located at /core//oraInst.loc
The Oracle home '/sbin' could not be updated as it does not exist.
Deinstall Command executed:/core//oui/bin/runInstaller -deinstall -silent "REMOVE_HOMES={/core/}" -waitForCompletion -removeAllFiles -invPtrLoc /core//oraInst.loc
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB.   Actual 24575 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-07-20_04-27-41PM. Please wait ...Oracle Universal Installer, Version 11.1.0.12.0 Production
Copyright (C) 1999, 2014, Oracle. All rights reserved.
Starting deinstall
Deinstall in progress (Monday, July 20, 2015 4:27:44 PM CEST)
Configuration assistant "Agent Deinstall Assistant" failed
............................................................... 100% Done.
Deinstall successful
End of install phases.(Monday, July 20, 2015 4:27:46 PM CEST)
End of deinstallations
Please check '/u01/app/oraInventory/logs/silentInstall2015-07-20_04-27-41PM.log' for more details.
NOTE: The targets monitored by this Management Agent will not be deleted in the Enterprise Manager Repository by this deinstall script. Make sure to delete the targets manually from the Cloud Control Console for a successful deinstallation.

– Pour modifier le port de l’agent, se connecter avec le compte oracle sur le serveur et exécuter les commandes suivantes :

export AGENT_INST=/agent_inst
$AGENT_INST/bin/emctl getproperty agent -name EMD_URL
$AGENT_INST/bin/emctl start blackout AGT_CNT_BLK_OUT -nodeLevel
$AGENT_INST/bin/emctl stop agent
$AGENT_INST/bin/emctl setproperty agent -name EMD_URL -value https://:/emd/main/
$AGENT_INST/bin/emctl start agent
$AGENT_INST/bin/emctl status agent
$AGENT_INST/bin/emctl stop blackout AGT_CNT_BLK_OUT