DBA Hub

📋Steps in this guide1/7

EMCLI : Installing Enteprise Manager Command Line Interface for Cloud Control 12c and 13c

Learn how to install EMCLI for Enterprise Manager Cloud Control 12c and 13c on Windows and Linux.

oracle miscconfigurationintermediate
by OracleDba
13 views
1

Download EMCLI

From the Cloud Control console, navigate to the "Enterprise Manager Command Line Tools Download" page using the "Setup > Command Line Interface" menu option. Click on the "Download the EMCLI with Scripting option kit to your workstation." link under the "EMCLI with Scripting option" section. Once you have the JAR file you can install EMCLI. Remember, this is a client tool, so the location you install it is independent of the location of the management server. You may have a management server running on Linux, but choose to install the EMCLI on your desktop PC running Windows.
2

Linux Installation

The typical procedure for installing EMCLI on Linux is shown below. Adjust the and the install location of EMCLI as required. The "-autologin" flag means that once you've logged in for the first time you will not have to log in again. If you think this is too risky, you can omit it and log in each time you use the tool. The "-url" parameter should be set to the fully qualified URL of your management server.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
mkdir /home/oracle/emcli
export JAVA_HOME=/usr/java/jdk1.8.0_211
export PATH=$JAVA_HOME/bin:$PATH
java -jar emcliadvancedkit.jar client -install_dir=/home/oracle/emcli
cd /home/oracle/emcli
export EMCLI_STATE_DIR=/home/oracle/emcli
emcli setup -url=https://ol7-em13cr3.localdomain:7802/em -username=sysman -trustall -autologin -dir=/home/oracle/emcli
emcli sync
3

Windows Installation

The typical procedure for installing EMCLI on Windows is shown below. Adjust the and the install location of EMCLI as required. The "-autologin" flag means that once you've logged in for the first time you will not have to log in again. If you think this is too risky, you can omit it and log in each time you use the tool. The "-url" parameter should be set to the fully qualified URL of your management server.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
mkdir c:\emcli
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_211
set PATH=%JAVA_HOME%\bin;%PATH%
java -jar emcliadvancedkit.jar client -install_dir=c:\emcli
cd c:\emcli
set EMCLI_STATE_DIR=C:\emcli
emcli setup -url=https://ol7-em13cr3.localdomain:7802/em -username=sysman -trustall -autologin -dir=C:\emcli
emcli sync
4

Starting EMCLI

Once EMCLI is installed, you can either use interactive mode or standard invocation. To work in interactive mode, simply issue the command with no parameters. For standard invocation, issue the same command, but include the relevant parameters, or verbs, for the required action. It's always a good idea to start off any action with a sync call, to make sure the connection to the admin server is working.

Code/Command (click line numbers to comment):

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
# Linux
export JAVA_HOME=/usr/java/jdk1.8.0_211
export PATH=$JAVA_HOME/bin:$PATH
cd /home/oracle/emcli
export EMCLI_STATE_DIR=/home/oracle/emcli
emcli sync
emcli

Rem Windows
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_211
set PATH=%JAVA_HOME%\bin;%PATH%
java -jar emcliadvancedkit.jar client -install_dir=c:\emcli
cd c:\emcli
set EMCLI_STATE_DIR=C:\emcli
emcli sync
emcli

# Linux
export JAVA_HOME=/usr/java/jdk1.8.0_211
export PATH=$JAVA_HOME/bin:$PATH
cd /home/oracle/emcli
export EMCLI_STATE_DIR=/home/oracle/emcli
emcli sync
emcli help

Rem Windows
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_211
set PATH=%JAVA_HOME%\bin;%PATH%
java -jar emcliadvancedkit.jar client -install_dir=c:\emcli
cd c:\emcli
set EMCLI_STATE_DIR=C:\emcli
emcli sync
emcli help

emcli sync
5

Verb Reference

The list of available commands, or verbs, is available in the documentation. You can get much of this information from the EMCLI help.
6

Getting Help

Not surprisingly, the way you get help in EMCLI is to use the command. Like most commands, it can be called interactively or using standard invocation. The basic command produces a lot of output, with a brief explanation of each verb. An example of the output is shown here . You can drill down further into the help by specifying the verb of interest. Some of the help pages suggest additional help commands to get more detailed information, or even example parameter files.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
emcli># Interactive
emcli>help()

$ # Standard Invocation
$ emcli help

emcli># Interactive
emcli>help("create_job")

$ # Standard Invocation
$ emcli help create_job
7

Example

Rather than trying to present lots of examples, I'll show you the approach you need to take to figure out how to use specific commands. First, check the basic help to see if there is a verb that sounds like it could suit your purpose. For example, let's say we need to create a new job. We issue the command and check the output ( 12c , 13c ) for anything that looks like it might be related to jobs. We can see a verb called , which looks promising, so we drill down into that. The help tells us to use the verb to get a template property file. We can now create property file using the template and fill in the values. In this case I created the property file with the name "/tmp/property_file.txt" and the following contents. With the property file in place we can run the command as follows. We can remove the job with the following command. The job is scheduled for an immediate run. If you want to schedule a repeated task, you have the following parameter available that can be added to the propery file. If we wanted to schedule the previous backup job to run every day at 8:00 PM, we might add the following to the propery file before creating the job using it. To remove a job with a regular schedule, we must first delete all scheduled runs, then delete the job. This type of approach, coupled with the documentation should allow you to quickly figure out any available command. For more information see: Hope this helps. Regards Tim...

Code/Command (click line numbers to comment):

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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
$ emcli help
.
.
.
  Job Verbs
    add_chef_cookbook        -- Create chef cookbook entities
    create_job               -- Create a job
    create_job_from_library  -- Create a job using a library job as a template
    create_library_job       -- Create a library job
    delete_chef_cookbook     -- Delete chef cookbook entities
    delete_job               -- Delete the specified job
    delete_library_job       -- Delete a library job
    describe_job             -- Describe a job
    describe_job_type        -- Describe a job type
    describe_library_job     -- Describe a library job
    export_jobs              -- Export job details in to an xml file
    get_job_execution_detail -- Display details of job execution
    get_job_types            -- Lists all job types supported by EMCLI
    get_jobs                 -- Get a list of existing jobs
    import_jobs              -- Import job definitions from an xml file
    job_input_file           -- Supply details for a job verb in a property file
    job_target_criteria
    resume_job               -- Resume a job or set of jobs
    retry_job                -- Restart a previously failed job execution
    stop_job                 -- Stop the specified job
    submit_job               -- Submit a job (Deprecated - use create_job)
    suspend_job              -- Suspend a job or set of jobs
.
.
.

$ emcli help create_job
emcli create_job
     -name=<job_name>
     -type=<job_type>
     -input_file="property_file:<filename>"
Description:
 Create and schedule a job.

Options:
     -name: Optional parameter. The name may be specified in the input file instead.
     -type: Optional parameter. The type may be specified in the input file instead.
     -input_file : Required parameter. <filename> must be provided to load the properties for creating and scheduling the job.

 A template property file for the job_type can be obtained using EMCLI verb "describe_job_type".
 Another job of the same job type could also be used to generate the property file using EMCLI verb "describe_job".
 Please make sure that the property file is accessible to the EMCLI client for reading.

Sample:
 Create and schedule a job with name MYJOB1 and of job type MyJobType1 with property file present at location /tmp/myjob1_prop.txt
     emcli create_job -name=MYJOB1 -job_type=MyJobType1 -input_file="property_file:/tmp/myjob1_prop.txt"

$

$ emcli describe_job_type -type=RMANScript

# Description: (Optional) The user specified name of the job
name=

# Description: (Optional) The job type for this job
type=RMANScript

# Description: (Optional) The user specified description of the job
description=

# Description: The job owner. The job owner is the user who creates the job.
# Default: the logged in user
# The job owner information displayed here is for documentation only and user is not expected to change it.
owner=

# Description: (Optional) The kind of job
# Legal Values: active, library
kind=


# Fill in the target list before submitting.
# For Example:
#     target_list=MyTarget:oracle_database
target_list=<target_name>:<target_type>


# Credential Usage: defaultDBCred
# Description:
cred.defaultDBCred.<target_name>:<target_type>=

# Credential Usage: defaultHostCred
# Description:
cred.defaultHostCred.<target_name>:<target_type>=

# Description: (Required) Enter RMAN commands or a fully qualified script name on the remote hosts, for example, "@script.rcv"
variable.rman_perl_script=


# Description: (Optional) Notify the job owner when a selected state occurs
# Allowed Values:  SCHEDULED, RUNNING, ACTION_REQUIRED, SUSPENDED, SUCCEEDED, PROBLEMS
notification=

$

# Description: (Optional) The user specified name of the job
name=test_emcli_job_1

# Description: (Optional) The job type for this job
type=RMANScript

# Description: (Optional) The user specified description of the job
description=A test job created using EMCLI

# Description: The job owner. The job owner is the user who creates the job.
# Default: the logged in user
# The job owner information displayed here is for documentation only and user is not expected to change it.
owner=sysman

# Description: (Optional) The kind of job
# Legal Values: active, library
kind=active


# Fill in the target list before submitting.
# For Example:
#     target_list=MyTarget:oracle_database
target_list=db12c:oracle_database


# Credential Usage: defaultDBCred
# Description:
#cred.defaultDBCred.<target_name>:<target_type>=

# Credential Usage: defaultHostCred
# Description:
#cred.defaultHostCred.<target_name>:<target_type>=

# Description: (Required) Enter RMAN commands or a fully qualified script name on the remote hosts, for example, "@script.rcv"
variable.rman_perl_script=<<MULTILINEVALUE
run {
recover copy of database with tag 'MYDB_INCR_BACKUP' until time 'SYSDATE-7';
backup incremental level 1 for recover of copy with tag 'MYDB_INCR_BACKUP' database;
backup device type disk tag 'MYDB_INCR_BACKUP' archivelog all not backed up delete all input;
delete noprompt obsolete device type disk;
}
MULTILINEVALUE

# Description: (Optional) Notify the job owner when a selected state occurs
# Allowed Values:  SCHEDULED, RUNNING, ACTION_REQUIRED, SUSPENDED, SUCCEEDED, PROBLEMS
notification=SUCCEEDED,PROBLEMS

$ emcli create_job -input_file="property_file:/tmp/property_file.txt"
Creation of job "TEST_EMCLI_JOB_1" was successful.

$

$ emcli delete_job -name=test_emcli_job_1
Job "TEST_EMCLI_JOB_1" deleted successfully

$

schedule.frequency=
schedule.startTime=
schedule.endTime=
schedule.gracePeriod=
schedule.months=
schedule.days=
schedule.interval=
schedule.timezone.type=
schedule.timezone.targetIndex=
schedule.timezone.zoneOffset=
schedule.timezone.region=

schedule.frequency=REPEAT_BY_DAYS
schedule.startTime=2013-08-31 20:00:00
schedule.interval=1
schedule.timezone.type=TIMEZONE_REGION_SPECIFIED
schedule.timezone.targetIndex=1
schedule.timezone.region=Europe/London

$ emcli stop_job -name=test_emcli_job_1
Job "TEST_EMCLI_JOB_1" stopped successfully

$ emcli delete_job -name=test_emcli_job_1
Job "TEST_EMCLI_JOB_1" deleted successfully

$

Comments (0)

Please to add comments

No comments yet. Be the first to comment!