Oracle 11g RAC 安装EM

emca帮助信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
[oracle@11rac2 ~]$ emca -h
/u01/app/oracle/product/11.2.0/dbhome_1/bin/emca [operation] [mode] [dbType] [flags] [parameters]

-h | --h | -help | --help: prints this help message
-version: prints the version

-config dbcontrol db [-repos (create | recreate)] [-cluster] [-silent] [-backup] [parameters]: configure Database Control for a database
-config centralAgent (db | asm) [-cluster] [-silent] [parameters]: configure central agent management
-config all db [-repos (create | recreate)] [-cluster] [-silent] [-backup] [parameters]: configure both Database Control and central agent management

-deconfig dbcontrol db [-repos drop] [-cluster] [-silent] [parameters]: de-configure Database Control
-deconfig centralAgent (db | asm) [-cluster] [ -silent] [parameters]: de-configure central agent management
-deconfig all db [-repos drop] [-cluster] [-silent] [parameters]: de-configure both Database Control and central agent management

-addNode (db | asm) [-silent] [parameters]: configure EM for a newly added node for a database

-deleteNode (db | asm) [-silent] [parameters]: de-configure EM for for a database on node getting deleted

-addInst (db | asm) [-silent] [parameters]: configure EM for a new RAC instance
-deleteInst (db | asm) [-silent] [parameters]: de-configure EM for a specified RAC instance

-reconfig ports [-cluster] [parameters]: explicitly reassign Database Control ports
-reconfig dbcontrol -cluster [-silent] [parameters]: reconfigures RAC Database Control deployment

-displayConfig dbcontrol -cluster [-silent] [parameters]: displays information about the RAC Database Control configuration

-migrate -from dbcontrol -to centralAgent [-repos drop] [-cluster] [-silent] [parameters]: migrates EM configuration from Database Control to central agent

-upgrade (db | asm | db_asm) [-cluster] [-silent] [parameters]: upgrades an earlier version of the EM configuration to the current version

-updateTargets crs [-silent] [parameters]: updates new crs home for all dbcontrol and central agents on crs upgrade

-restore (db | asm | db_asm) [-cluster] [-silent] [parameters]: restores the current version of the EM configuration to an earlier version

Parameters and Options:
[parameters]: [ -respFile fileName ] [ -paramName paramValue ]*
db: perform configuration operation for a database (including databases that use ASM)
asm: perform configuration operation for an ASM-only instance
db_asm: perform upgrade/restore operation for a database and an ASM instance
-repos create: create a new Database Control repository
-repos drop: drop the current Database Control repository
-repos recreate: drop the current Database Control repository and recreate a new one
-cluster: perform configuration operation for a RAC database
-silent: perform configuration operation without prompting for parameters
-backup: configure automatic backup for a database

Parameters for single instance databases
ORACLE_HOSTNAME: Local hostname
SID: Database SID
PORT: Listener port number
ORACLE_HOME: Database ORACLE_HOME
LISTENER_OH: Listener ORACLE_HOME
HOST: Listener Host
HOST_USER: Host username for automatic backup
HOST_USER_PWD: Host user password for automatic backup
BACKUP_SCHEDULE: Automatic backup schedule (HH:MM)
EMAIL_ADDRESS: Email address for notifications
MAIL_SERVER_NAME: Outgoing Mail (SMTP) server for notifications
ASM_OH: ASM ORACLE_HOME
ASM_SID: ASM SID
ASM_PORT: ASM port
ASM_USER_ROLE: ASM user role
ASM_USER_NAME: ASM username
ASM_USER_PWD: ASM user password
SRC_OH: ORACLE_HOME for the database to be upgraded
DBSNMP_PWD: Password for DBSNMP user
SYSMAN_PWD: Password for SYSMAN user
SYS_PWD: Password for SYS user
DBCONTROL_HTTP_PORT: Database Control HTTP port
AGENT_PORT: EM agent port
RMI_PORT: RMI port for Database Control
JMS_PORT: JMS port for Database Control
EM_SWLIB_STAGE_LOC: Software library location
PORTS_FILE: Path to a static file specifying the ports to use (Default value : ${ORACLE_HOME}/install/staticports.ini).

Additional Parameters for cluster databases
CLUSTER_NAME: Cluster name
DB_UNIQUE_NAME: Database unique name
SERVICE_NAME: Service name
EM_NODE: Database Control node name
EM_NODE_LIST: Agent Node list [comma separated]

Note: For Desktop Class Install always pass parameter ORACLE_HOSTNAME
as "localhost" to any emca command

emctl帮助信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[oracle@11rac2 ~]$ emctl -h
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
Oracle Enterprise Manager 10g Database Control commands:
emctl start | stop dbconsole
emctl status | secure | setpasswd dbconsole
emctl config dbconsole -heap_size <size_value> -max_perm_size <size_value>
emctl status agent
emctl status agent -secure [-omsurl <http://<oms-hostname>:<oms-unsecure-port>/em/*>]
emctl getversion
emctl reload | upload | clearstate | getversion agent
emctl reload agent dynamicproperties [<Target_name>:<Target_Type>]....
emctl config agent <options>
emctl config agent updateTZ
emctl config agent getTZ
emctl resetTZ agent
emctl config agent credentials [<Target_name>[:<Target_Type>]]
emctl gensudoprops
emctl clearsudoprops
Blackout Usage :
emctl start blackout <Blackoutname> [-nodeLevel] [<Target_name>[:<Target_Type>]].... [-d <Duration>]
emctl stop blackout <Blackoutname>
emctl status blackout [<Target_name>[:<Target_Type>]]....

The following are valid options for blackouts
<Target_name:Target_type> defaults to local node target if not specified.
If -nodeLevel is specified after <Blackoutname>,the blackout will be applied to all targets and any target list that follows will be ignored.
Duration is specified in [days] hh:mm

emctl getemhome
emctl ilint
Em Key Commands Usage :
emctl config emkey -emkeyfile <emkey.ora path> [-force] [-sysman_pwd <sysman password>]
emctl config emkey -emkey [-emkeyfile <emkey.ora path>] [-force] [-sysman_pwd <sysman password>]
emctl config emkey -repos [-emkeyfile <emkey.ora path>] [-force] [-sysman_pwd <sysman password>]
emctl config emkey -remove_from_repos [-sysman_pwd <sysman password>]
emctl config emkey -copy_to_repos [-sysman_pwd <sysman password>]
emctl status emkey [-sysman_pwd <sysman password>]

Secure DBConsole Usage :
emctl secure dbconsole -sysman_pwd <sysman password> [-passwd_file <abs file loc>]
[-host <slb hostname>] [-sid <service name>] [-reset] [-secure_port <secure_port>]
[-cipher_suites <comma_separated_list_of_suites>] [-sign_alg <md5|sha1|sha256|sha384|sha512>]
[-root_dc <root_dc>] [-root_country <root_country>] [-root_state <root_state>] [-root_loc <root_loc>]
[-root_org <root_org>] [-root_unit <root_unit>] [-root_email <root_email>]
[-wallet <wallet loc>] [-wallet_pwd <wallet pwd>] [-trust_certs_loc <certs loc>]
emctl secure status dbconsole
Register Targettype Usage :
emctl register oms targettype [-o <Output filename>] <XML filename> <rep user> <rep passwd> <rep host> <rep port> <rep sid> OR
emctl register oms targettype [-o <Output filename>] <XML filename> <rep user> <rep passwd> <rep connect descriptor>

em运行日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[oracle@11rac2 config]$ ll /u01/app/oracle/product/11.2.0/dbhome_1/11rac2_racdb/sysman/log/
total 4252
-rw-r-----. 1 oracle oinstall 1832583 Apr 2 21:05 emagentfetchlet.log
-rw-r-----. 1 oracle oinstall 1832583 Apr 2 21:05 emagentfetchlet.trc
-rw-r-----. 1 oracle oinstall 5744 Apr 2 21:04 emagent.log
-rw-r-----. 1 oracle oinstall 62755 Apr 2 21:04 emagent_perl.trc
-rw-r-----. 1 oracle oinstall 567330 Apr 2 21:16 emagent.trc
-rw-r-----. 1 oracle oinstall 2693 Apr 2 21:13 emctl.log
-rw-r-----. 1 oracle oinstall 7283 Apr 2 21:04 emdb.nohup
-rw-r-----. 1 oracle oinstall 0 Apr 2 15:52 emdctl.log
-rw-r-----. 1 oracle oinstall 19510 Apr 2 21:00 emdctl.trc
-rw-r-----. 1 oracle oinstall 0 Apr 2 15:53 nfsPatchPlug.log
-rw-r-----. 1 oracle oinstall 0 Apr 2 15:52 patchAgtStPlugin.log
-rw-r-----. 1 oracle oinstall 252 Apr 2 16:55 secure.log
[oracle@11rac2 config]$

手动清除并新建

1
emca -deconfig dbcontrol db -repos drop -cluster

注意:以上命令清除RAC数据库旧配置信息,但是会使数据库进入静默模式,锁定所有用户,在生产环境是不允许的。因此需要分两步进行配置:(不会进入静默模式)

  1. 手动删除旧配置信息

    1
    2
    3
    4
    5
    6
    7
    su - oracle
    sqlplus / as sysdba
    drop user sysman cascade;
    drop role MGMT_USER;
    drop user MGMT_VIEW cascade;
    drop public synonym MGMT_TARGET_BLACKOUTS;
    drop public synonym SETEMVIEWUSERCONTEXT;
  2. 重新建立RAC数据库db control 配置信息

    1
    2
    su - oracle
    emca -config dbcontrol db -repos create -cluster

重建

注意:重建会先删除再创建,删除过程会将数据库进入静默状态,生产库切勿如此。因此要么直接创建,要么使用上面的两步骤方式,手动删除旧配置信息,然后再创建。

  1. 节点hosts文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    [oracle@11rac1 ~]$ cat /etc/hosts
    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
    # Public
    10.10.10.171 11rac1
    10.10.10.172 11rac2
    # Private
    172.16.1.171 11rac1-priv
    172.16.1.172 11rac2-priv
    # Virtual
    10.10.10.173 11rac1-vip
    10.10.10.174 11rac2-vip
    # SCAN
    10.10.10.175 rac-scan
    10.10.10.176 rac-scan
    10.10.10.177 rac-scan
    [oracle@11rac1 ~]$
  2. 创建asmsnmp用户:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    -- grid用户
    [grid@11rac1 ~]$ sqlplus / as sysasm

    SQL*Plus: Release 11.2.0.4.0 Production on Wed Apr 2 14:47:35 2025

    Copyright (c) 1982, 2013, Oracle. All rights reserved.


    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Real Application Clusters and Automatic Storage Management options

    SQL> create user asmsnmp identified by SysPassword1;
    create user asmsnmp identified by SysPassword1
    *
    ERROR at line 1:
    ORA-15306: ASM password file update failed on at least one node
    ORA-15321: cannot set attribute with connected clients


    SQL>

    解决方法如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    [grid@11rac1 dbs]$ pwd
    /u01/app/11.2.0/grid/dbs
    [grid@11rac1 dbs]$ ll
    total 12
    -rw-rw---- 1 grid oinstall 931 Mar 27 16:26 ab_+ASM1.dat
    -rw-rw---- 1 grid oinstall 1544 Mar 27 16:27 hc_+ASM1.dat
    -rw-r--r-- 1 grid oinstall 2851 May 15 2009 init.ora
    [grid@11rac1 dbs]$

    # 创建密码文件
    [grid@11rac1 dbs]$ orapwd file='orapw+ASM1' entries=5 password=SysPassword1
    [grid@11rac1 dbs]$ ll
    total 16
    -rw-rw---- 1 grid oinstall 931 Mar 27 16:26 ab_+ASM1.dat
    -rw-rw---- 1 grid oinstall 1544 Mar 27 16:27 hc_+ASM1.dat
    -rw-r--r-- 1 grid oinstall 2851 May 15 2009 init.ora
    -rw-r----- 1 grid oinstall 2048 Apr 2 14:54 orapw+ASM1
    [grid@11rac1 dbs]$

    # 复制到其它节点
    [grid@11rac1 dbs]$ scp orapw+ASM1 grid@11rac2:/u01/app/11.2.0/grid/dbs/
    orapw+ASM1 100% 2048 542.7KB/s 00:00

    # 节点2更改文件名
    [grid@11rac2 dbs]$ pwd
    /u01/app/11.2.0/grid/dbs
    [grid@11rac2 dbs]$ mv orapw+ASM1 orapw+ASM2
    [grid@11rac2 dbs]$ ll
    total 16
    -rw-rw----. 1 grid oinstall 931 Mar 27 16:27 ab_+ASM2.dat
    -rw-rw----. 1 grid oinstall 1544 Mar 27 16:27 hc_+ASM2.dat
    -rw-r--r--. 1 grid oinstall 2851 May 27 2024 init.ora
    -rw-r-----. 1 grid oinstall 2048 Apr 2 14:55 orapw+ASM2
    [grid@11rac2 dbs]$

    再次执行:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    SQL> create user asmsnmp identified by SysPassword1;

    User created.

    SQL> grant sysdba to asmsnmp;

    Grant succeeded.

    SQL> select * from v$pwfile_users;

    USERNAME SYSDB SYSOP SYSAS
    ------------------------------ ----- ----- -----
    SYS TRUE TRUE FALSE
    ASMSNMP TRUE FALSE FALSE

    SQL>
  3. ASM实例注册于listener_scan1:

    1
    2
    alter system set remote_listener='rac-scan:1521' scope=both sid='*';
    alter system register;
  4. 查看cluster name:

    1
    2
    3
    [grid@11rac1 dbs]$ /u01/app/11.2.0/grid/bin/cemutlo -n
    rac11-cluster
    [grid@11rac1 dbs]$
  5. 重建EM:

    1
    2
    su - oracle
    emca -config dbcontrol db -repos recreate -cluster

    示例输出:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    [oracle@11rac1 ~]$ emca -config dbcontrol db -repos recreate -cluster

    STARTED EMCA at Apr 2, 2025 3:09:18 PM
    EM Configuration Assistant, Version 11.2.0.3.0 Production
    Copyright (c) 2003, 2011, Oracle. All rights reserved.

    Enter the following information:
    Database unique name: racdb # 注意这里是db_name,而非dg环境中的db_unique_name
    Service name: racdb_primary
    Listener port number: 1521
    Listener ORACLE_HOME [ /u01/app/11.2.0/grid ]:
    Password for SYS user:
    Password for DBSNMP user: # 这几个账户默认是锁定的,需要手动解锁
    Password for SYSMAN user:
    Password for SYSMAN user:
    Cluster name: rac11-cluster
    Email address for notifications (optional):
    Outgoing Mail (SMTP) server for notifications (optional):
    ASM ORACLE_HOME [ /u01/app/11.2.0/grid ]:
    ASM port [ 1521 ]:
    ASM username [ ASMSNMP ]:
    ASM user password:
    -----------------------------------------------------------------

    You have specified the following settings

    Database ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/dbhome_1

    Database instance hostname ................ Listener ORACLE_HOME ................ /u01/app/11.2.0/grid
    Listener port number ................ 1521
    Cluster name ................ rac11-cluster
    Database unique name ................ racdb
    Email address for notifications ...............
    Outgoing Mail (SMTP) server for notifications ...............
    ASM ORACLE_HOME ................ /u01/app/11.2.0/grid
    ASM port ................ 1521
    ASM user role ................ SYSDBA
    ASM username ................ ASMSNMP

    -----------------------------------------------------------------
    ----------------------------------------------------------------------
    WARNING : While repository is dropped the database will be put in quiesce mode.
    ----------------------------------------------------------------------
    Do you wish to continue? [yes(Y)/no(N)]: Y
    Apr 2, 2025 3:11:05 PM oracle.sysman.emcp.EMConfig perform
    INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/racdb/emca_2025_04_02_15_09_17.log.
    Apr 2, 2025 3:11:13 PM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Dropping the EM repository (this may take a while) ...
    Apr 2, 2025 3:22:36 PM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Repository successfully dropped
    Apr 2, 2025 3:22:37 PM oracle.sysman.emcp.EMReposConfig createRepository
    INFO: Creating the EM repository (this may take a while) ...
    Apr 2, 2025 3:44:17 PM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Repository successfully created
    Apr 2, 2025 3:44:30 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
    INFO: Uploading configuration data to EM repository (this may take a while) ...
    Apr 2, 2025 3:48:05 PM oracle.sysman.emcp.EMReposConfig invoke
    INFO: Uploaded configuration data successfully
    Apr 2, 2025 3:48:06 PM oracle.sysman.emcp.EMDBCConfig instantiateOC4JConfigFiles
    INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_11rac1_racdb to remote nodes ...
    Apr 2, 2025 3:48:11 PM oracle.sysman.emcp.EMDBCConfig instantiateOC4JConfigFiles
    INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/oc4j/j2ee/OC4J_DBConsole_11rac2_racdb to remote nodes ...
    Apr 2, 2025 3:48:22 PM oracle.sysman.emcp.EMAgentConfig deployStateDirs
    INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/11rac1_racdb to remote nodes ...
    Apr 2, 2025 3:48:29 PM oracle.sysman.emcp.EMAgentConfig deployStateDirs
    INFO: Propagating /u01/app/oracle/product/11.2.0/dbhome_1/11rac2_racdb to remote nodes ...
    Apr 2, 2025 3:48:39 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
    INFO: Securing Database Control (this may take a while) ...
    Apr 2, 2025 3:49:59 PM oracle.sysman.emcp.util.DBControlUtil startOMS
    INFO: Starting Database Control (this may take a while) ...
    Apr 2, 2025 3:53:11 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
    INFO: Database Control started successfully
    Apr 2, 2025 3:53:11 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
    INFO: >>>>>>>>>>> The Database Control URL is https://11rac1:1158/em <<<<<<<<<<<
    Apr 2, 2025 3:53:29 PM oracle.sysman.emcp.EMDBPostConfig showClusterDBCAgentMessage
    INFO:
    **************** Current Configuration ****************
    INSTANCE NODE DBCONTROL_UPLOAD_HOST
    ---------- ---------- ---------------------

    racdb 11rac1 11rac1
    racdb 11rac2 11rac1


    Apr 2, 2025 3:53:29 PM oracle.sysman.emcp.EMDBPostConfig invoke
    WARNING:
    ************************ WARNING ************************

    Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted. The encryption key has been placed in the file: /u01/app/oracle/product/11.2.0/dbhome_1/11rac1_racdb/sysman/config/emkey.ora. Ensure this file is backed up as the encrypted data will become unusable if this file is lost.

    ***********************************************************
    Enterprise Manager configuration completed successfully
    FINISHED EMCA at Apr 2, 2025 3:53:29 PM
    [oracle@11rac1 ~]$

    # 看下状态,如下可以看到已经自动启动,但仅在节点1上运行
    [oracle@11rac1 ~]$ emctl status dbconsole
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
    Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
    https://11rac1:1158/em/console/aboutApplication
    Oracle Enterprise Manager 11g is running.
    ------------------------------------------------------------------
    Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/11rac1_racdb/sysman/log
    [oracle@11rac1 ~]$
    [oracle@11rac2 ~]$ emctl status dbconsole
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
    Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
    https://11rac1:1158/em/console/aboutApplication
    EM Daemon is running.
    ------------------------------------------------------------------
    Logs are generated in directory /u01/app/oracle/product/11.2.0/dbhome_1/11rac2_racdb/sysman/log
    [oracle@11rac2 ~]$
  6. 访问

    注意:建议适用节点IP进行访问,因为如果适用SCAN-IP或VIP,可能会被切换到没有运行em的节点上。

    1
    https://node-ip:1158

    如下所示: