记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

oracle 数据库主机账号修改密码后,关于EM企业管理器中的主机 首选身份证明,密码也需要变更,

不然在EM中的 可用性,调度备份,就会不能正常使用了。

需要修改,就比较麻烦了。如果主机没法使用EM后,就只有使用EM CLI命令行来修改了。

先要安装EM Cli 工具。

可以使用下面命令查看 EM所登陆的rman 备份任务


SELECT a.job_name, b.execution_hours, b.execution_minutes
  FROM sysman.mgmt_job a, sysman.mgmt_job_schedule b
 WHERE a.schedule_id = b.schedule_id AND a.job_type = 'Backup';


附件是emcli工具软件


SettingPreferred Credentials UsingEM CLI

When you provide the agent credentials, you can choose to enter the preferred credentials registered with the Enterprise Manager system.However, ensure that the credentials were registered using EM CLI.

  • Toregister the credentials as preferred credentials for one host at a time, run the following command on the host where the Management Agent is running:

    emcli set_credential -target_type=host -target_name="<host_name>" -credential_set=OHCreds -column="OHUsername:<em_job_user>;OHPassword:<em_job_pwd>" -oracle_homes="<agent_home>"

    For example,

    emcli set_credential -target_type=host -target_name="example.com" -credential_set=OHCreds -column="OHUsername:myuser;OHPassword:2bornot2b" -oracle_homes="/home/john/programs/EM/agent10g"

  • Toregister the credentials as default preferred credentials for all hosts at a time, run the following command on one of the hosts where the Management Agent is running.Ensure that the user is a shared user on all the hosts.

    emcli set_credential -target_type=host -credential_set=OHCreds -column="OHUsername:<em_job_user>;OHPassword:<em_job_pwd>" -oracle_homes="<agent_home>"

    For example,

    emcli set_credential -target_type=host -credential_set=OHCreds -column="OHUsername:myuser;OHPassword:2bornot2b"

Note:

To run these commands, you must have the EM CLI Client installed on the hosts.If you do not have EM CLI, install one following the instructions outlined inOracle Enterprise Manager Command Line Interface Guide.






EMCLI : Manage Credentials using Enterprise Manager Command Line Interface (Cloud Control)

The Enterprise Manager Command Line Interface (EMCLI) allows you to script your Cloud Control setup, rather than using the Cloud Control console. This article describes how to manage credentials in Cloud Control using EMCLI, rather than using the web interface.

We can add all our credentials before pushing out agents or discovering targets, but we can only set preferred credentials once the targets are discovered.

For more information see:

Setup

You can perform these actions from anywhere with an EMCLI client, but for this example we're going to use the EMCLI client on the Cloud Control server. We use the following commands to connect to the OMS and sync the EMCLI client.

unset SSH_ASKPASS
export OMS_HOME=/u01/app/oracle/middleware
export AGENT_HOME=/u01/app/oracle/agent/agent_inst
alias emcli='${OMS_HOME}/bin/emcli'

emcli login -username=sysman
emcli sync

Add Host Credential

The create_named_credential verb allows you to create a named credential. The -auth_target_type and -cred_type properties determine what type of credential it is. The following example adds a named host credential (HostCreds).

HOST_CREDENTIAL_NAME="NC_HOST_MY_HOST"
HOST_USERNAME="oracle"
HOST_PASSWORD="MyPassword123"

emcli create_named_credential \
  -cred_name="${HOST_CREDENTIAL_NAME}" \
  -auth_target_type="host" \
  -cred_type="HostCreds" \
  -attributes="HostUserName:${HOST_USERNAME};HostPassword:${HOST_PASSWORD}"

Add Database Credential

The following examples use the create_named_credential verb to create database credentials (DBCreds). In addition to the username (DBUserName) and password (DBPassword), we must specify the role (DBRole). There are examples for non-CDB and CDB credentials.

DB_CREDENTIAL_NAME="NC_DB_NORMAL"
DB_USERNAME="MY_USER"
DB_PASSWORD="MyPassword123"
DB_ROLE="normal"

emcli create_named_credential \
  -cred_name="${DB_CREDENTIAL_NAME}" \
  -auth_target_type="oracle_database" \
  -cred_type="DBCreds" \
  -attributes="DBUserName:${DB_USERNAME};DBPassword:${DB_PASSWORD};DBRole:${DB_ROLE}"

DB_CREDENTIAL_NAME="NC_DB_SYSDBA"
DB_USERNAME="MY_USER"
DB_PASSWORD="MyPassword123"
DB_ROLE="sysdba"

emcli create_named_credential \
  -cred_name="${DB_CREDENTIAL_NAME}" \
  -auth_target_type="oracle_database" \
  -cred_type="DBCreds" \
  -attributes="DBUserName:${DB_USERNAME};DBPassword:${DB_PASSWORD};DBRole:${DB_ROLE}"

DB_CREDENTIAL_NAME="NC_DB_CDB_NORMAL"
DB_USERNAME="C##MY_USER"
DB_PASSWORD="MyPassword123"
DB_ROLE="normal"

emcli create_named_credential \
  -cred_name="${DB_CREDENTIAL_NAME}" \
  -auth_target_type="oracle_database" \
  -cred_type="DBCreds" \
  -attributes="DBUserName:${DB_USERNAME};DBPassword:${DB_PASSWORD};DBRole:${DB_ROLE}"

DB_CREDENTIAL_NAME="NC_DB_CDB_SYSDBA"
DB_USERNAME="C##MY_USER"
DB_PASSWORD="MyPassword123"
DB_ROLE="sysdba"

emcli create_named_credential \
  -cred_name="${DB_CREDENTIAL_NAME}" \
  -auth_target_type="oracle_database" \
  -cred_type="DBCreds" \
  -attributes="DBUserName:${DB_USERNAME};DBPassword:${DB_PASSWORD};DBRole:${DB_ROLE}"

Remove Credential

The delete_named_credential verb can delete any named credential, host or database. The example below deletes a credential owned by the SYSMAN user.

CREDENTIAL_NAME="NC_HOST_MY_HOST"
CREDENTIAL_OWNER="SYSMAN"

emcli delete_named_credential \
  -cred_owner="${CREDENTIAL_OWNER}" \
  -cred_name="${CREDENTIAL_NAME}"

Set Host Preferred Credential

The set_preferred_credential verb allows you set a preferred credential. A host credential can be for a normal user (HostCredsNormal), or a privileged user (HostCredsPriv) that can perform sudo operations. The following examples show how to set each type of preferred credential.

HOST_NAME="my-host.localdomain"
HOST_CREDENTIAL="NC_HOST_MY_HOST"

emcli set_preferred_credential \
  -set_name="HostCredsNormal" \
  -target_type="host" \
  -credential_name="${HOST_CREDENTIAL}" \
  -target_name="${HOST_NAME}"

emcli set_preferred_credential \
  -set_name="HostCredsPriv" \
  -target_type="host" \
  -credential_name="${HOST_CREDENTIAL}" \
  -target_name="${HOST_NAME}"

Set Database Preferred Credential

An Oracle database has three distinct preferred credentials (DBCredsNormal, DBCredsSYSDBA and DBHostCreds). The following examples use the set_preferred_credential verb to set all of them.

DB_NAME="orcl"
DB_NORMAL_CREDENTIAL="NC_DB_NORMAL"
DB_SYSDBA_CREDENTIAL="NC_DB_SYSDBA"
DB_HOST_CREDENTIAL="NC_HOST_MY_HOST"

emcli set_preferred_credential \
  -set_name="DBCredsNormal" \
  -target_type="oracle_database" \
  -credential_name="${DB_NORMAL_CREDENTIAL}" \
  -target_name="${DB_NAME}"

emcli set_preferred_credential \
  -set_name="DBCredsSYSDBA" \
  -target_type="oracle_database" \
  -credential_name="${DB_SYSDBA_CREDENTIAL}" \
  -target_name="${DB_NAME}"

emcli set_preferred_credential \
  -set_name="DBHostCreds" \
  -target_type="oracle_database" \
  -credential_name="${DB_HOST_CREDENTIAL}" \
  -target_name="${DB_NAME}"

Help

The usage of the commands referenced in this article can displayed using the following commands.

emcli help create_named_credential
emcli help delete_named_credential
emcli help set_preferred_credential

You can also check out all the other credential verbs in the Help Command Output.

emcli help

For more information see:

Hope this helps. Regards Tim...

Back to the Top.




转载请标明出处【oracle 通过OEM企业管理器创建rman备份任务与首选身份证明】。

《www.92cto.com》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论