DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Saturday, August 12, 2017

opatchauto failed with error code 2

Opatchauto:

In general, when we invoke opatchauto, opatch will patch both the GI stack and the database software stack. Since we do not have a database running, patch will skip the database software stack and only apply the PSU to the GI Home. Before we invoke the opatchauto command, let’s create the ocm.rsp response file by executing the OCM Installation Response Generator (emocmrsp).

Now we are going to patch the ORACLE_HOME,its automatically bounce the databases which are running under this ORACLE_HOME.We have to execute a command as a root user.

ERROR:

UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed while applying patch


While applying 12c patch, it failed with below error

[root@test.doy.com] /oracle/app/oracle/product/12.1.0/dbrac_1/OPatch/opatchauto apply  /orashare1/OPatch/psu/gipsu/25901062 -oh /oracle/app/oracle/product/12.1.0/dbrac_1 -ocmrf /oracle/app/oracle/ocm.rsp

OPatch Automation Tool
Copyright (c) 2015, Oracle Corporation.  All rights reserved.

OPatchauto version : 12.1.0.1.5
OUI version        : 12.1.0.2.0
Running from       : /oracle/product/grid/12.1.0

opatchauto log file: /oracle/product/grid/12.1.0/cfgtoollogs/opatchauto/20132450/opatch_gi_2017-02-24_03-25-09_deploy.log

Parameter Validation: Successful

Grid Infrastructure home:
/oracle/product/grid/12.1.0
RAC home(s):
/oracle/product/db/12.1.0

Configuration Validation: Successful

Patch Location: /oracle/archivelog/patch/20132450
Grid Infrastructure Patch(es): 19769473 19769479 19769480 19872484
RAC Patch(es): 19877336 19769479 19769480

Patch Validation: Successful

Stopping RAC (/oracle/product/db/12.1.0) ... Successful

Applying patch(es) to "/oracle/product/db/12.1.0" ...
Command "/oracle/product/db/12.1.0/OPatch/opatch napply -phBaseFile /tmp/OraDB12Home1_patchList -local  -invPtrLoc /oracle/product/grid/12.1.0/oraInst.loc -oh /oracle/product/db/12.1.0 -silent -ocmrf /oracle/archivelog/patch/unconfig_GI.rsp" execution failed:
UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed.

Log file Location for the failed command: /oracle/product/db/12.1.0/cfgtoollogs/opatch/opatch2017-02-24_03-26-10AM_1.log

For more details, please refer to the log file "/oracle/product/grid/12.1.0/cfgtoollogs/opatchauto/20132450/opatch_gi_2017-02-24_03-25-09_deploy.debug.log".

Apply Summary:

Following patch(es) failed to be installed:
GI Home: /oracle/product/grid/12.1.0: 19769473, 19769479, 19769480, 19872484
RAC Home: /oracle/product/db/12.1.0: 19877336, 19769479, 19769480

opatchauto failed with error code 2.


Checking the log it shows that

[Feb 24, 2017 3:26:17 AM]    Finish fuser command /sbin/fuser /oracle/product/db/12.1.0/lib/libclntsh.so.12.1 at Tue Feb 24 03:26:17 PST 2015
[Feb 24, 2017 3:26:17 AM]    Start fuser command /sbin/fuser /oracle/product/db/12.1.0/lib/libasmclntsh12.so at Tue Feb 24 03:26:17 PST 2015
[Feb 24, 2017 3:26:17 AM]    Finish fuser command /sbin/fuser /oracle/product/db/12.1.0/lib/libasmclntsh12.so at Tue Feb 24 03:26:17 PST 2015
[Feb 24, 2017 3:26:17 AM]    Following executables are active :
            7                /oracle/product/db/12.1.0/lib/libclntsh.so.12.1
[Feb 24, 2017 3:26:17 AM]    Prerequisite check "CheckActiveFilesAndExecutables" failed.
            7                The details are:
            7
            7
            7                Following executables are active :
            7                /oracle/product/db/12.1.0/lib/libclntsh.so.12.1
[Feb 24, 2017 3:26:17 AM]    OUI-67073:UtilSession failed: Prerequisite check "CheckActiveFilesAndExecutables" failed.
[Feb 24, 2017 3:26:17 AM]    Finishing UtilSession at Tue Feb 24 03:26:17 PST 2015
[Feb 24, 2017 3:26:17 AM]    Log file location: /oracle/product/db/12.1.0/cfgtoollogs/opatch/opatch2015-02-24_03-26-10AM_1.log
[Feb 24, 2017 3:26:17 AM]    Stack Description: java.lang.RuntimeException: Prerequisite check "CheckActiveFilesAndExecutables" failed.
[Feb 24, 2017 3:26:17 AM]    StackTrace: oracle.opatch.OPatchSessionHelper.runApplyPrereqs(OPatchSessionHelper.java:6516)
[Feb 24, 2017 3:26:17 AM]    StackTrace: oracle.opatch.opatchutil.NApply.process(NApply.java:1617)


Reason:

Someone is accessing Oracle library

Solution:

Using fuser, find who is accessing and kill it.

fuser  /oracle/app/oracle/product/12.1.0/dbrac_1/lib/libclntsh.so.12.1

kill -9 pid

[root@test.doy.com] fuser  /oracle/app/oracle/product/12.1.0/dbrac_1/lib/libclntsh.so.12.1
/oracle/app/oracle/product/12.1.0/dbrac_1/lib/libclntsh.so.12.1: 112053m

[root@test.doy.com] /oracle/home/oracle$ ps -ef|grep 112053
oracle   112053 111991  0 Feb23 pts/0    00:00:00 sqlplus

[root@test.doy.com] /oracle/home/oracle$ kill -9 112053

[root@test.doy.com] /oracle/app/oracle/product/12.1.0/dbrac_1/OPatch/opatchauto apply  /orashare1/OPatch/psu/gipsu/25901062 -oh /oracle/app/oracle/product/12.1.0/dbrac_1 -ocmrf /oracle/app/oracle/ocm.rsp

Sunday, August 6, 2017

Launch EC2 Instance from AWSCLI

Launch EC2 Instance from AWSCLI


In this blogpost, I will show you how to launch EC2 instance from AWSCLI (AWS command line).  This is very quick when compared to creating instances with console.  Please check my previous post about how to launch EC2 from AWS Console.

First, we need to install the AWS CLI, then configure it and finally launch EC2 using CLI.

Download appropriate AWS CLI MSI installer for your system, here I will be using Windows version.  Once installed, go to Windows command prompt and type aws.  If you are getting any output, then it means aws cli was installed.


Now, we need to configure AWS CLI with security credentials.  If you don’t have them, then we need to create them.   

For the sake of easiness, I am creating security credentials for root user, don't share the credentials with anyone and delete them or make them inactive after your activity.

In the navigation panel, choose user and  My Security Credentials



Press Continue to Security Credentials

 

Then click 'Create New Access Key' from Access Keys





Click Download Key File, the downloaded file will be in .csv format.  Keep the file in a safe location and don't share it with anyone.  It will contain AWSAccessKeyId and AWSSecretKey.




Now, we need to configure aws cli with the security credentials

In the command prompt, type:  aws configure
It will prompt you Access Key ID, Secret Access Key, Region and Output format; enter the first two from csv file that we have downloaded; enter region as us-west-2 - we will be using Oregon as our region; leave output as default.



We need few more details in order to launch ec2 instance from console.

They are:

1.    image-id:  The AWS AMI ID - OS media.  Here we will be using ami-6df1e514
2.    instance-type:  AWS is providing different types of instances optimized to fit different use cases.  They comprise varying combinations of CPU, memory, storage, and networking capacity and give us the flexibility to choose the appropriate mix of resources for our applications.  We will be launching t2.micro instance
3.    key-name:  Security key pair.  I had already created MyKeyPair key pair.
4.    region:  The region where we would like our instance to be hosted.  We will be hosting our instance in us-west-2 region (Oregon).

Now use the below command to launch EC2 instance from AWS CLI

aws ec2 run-instances --image-id ami-6df1e514 --count 1 --instance-type t2.micro --key-name MyKeyPair --region us-west-2


Here --count is number of instance we would like to launch

========================================================================
C:\Users\AVK>aws ec2 run-instances --image-id ami-6df1e514 --count 1 --instance-type t2.micro --key-name MyKeyPair --region us-west-2
{
    "Instances": [
        {
            "Monitoring": {
                "State": "disabled"
            },
            "PublicDnsName": "",
            "StateReason": {
                "Message": "pending",
                "Code": "pending"
            },
            "State": {
                "Code": 0,
                "Name": "pending"
            },
            "EbsOptimized": false,
            "LaunchTime": "2017-08-06T11:01:49.000Z",
            "PrivateIpAddress": "172.31.32.238",
            "ProductCodes": [],
            "VpcId": "vpc-deed20b8",
            "StateTransitionReason": "",
            "InstanceId": "i-09c9b5f291e9e63a6",
            "ImageId": "ami-6df1e514",
            "PrivateDnsName": "ip-172-31-32-238.us-west-2.compute.internal",
            "KeyName": "MyKeyPair",
            "SecurityGroups": [
                {
                    "GroupName": "default",
                    "GroupId": "sg-29ee3753"
                }
            ],
            "ClientToken": "",
            "SubnetId": "subnet-56facb1f",
            "InstanceType": "t2.micro",
            "NetworkInterfaces": [
                {
                    "Status": "in-use",
                    "MacAddress": "06:83:86:09:94:6a",
                    "SourceDestCheck": true,
                    "VpcId": "vpc-deed20b8",
                    "Description": "",
                    "NetworkInterfaceId": "eni-570b8669",
                    "PrivateIpAddresses": [
                        {
                            "PrivateDnsName": "ip-172-31-32-238.us-west-2.compute.internal",
                            "Primary": true,
                            "PrivateIpAddress": "172.31.32.238"
                        }
                    ],
                    "PrivateDnsName": "ip-172-31-32-238.us-west-2.compute.internal",
                    "Attachment": {
                        "Status": "attaching",
                        "DeviceIndex": 0,
                        "DeleteOnTermination": true,
                        "AttachmentId": "eni-attach-1460d0f8",
                        "AttachTime": "2017-08-06T11:01:49.000Z"
                    },
                    "Groups": [
                        {
                            "GroupName": "default",
                            "GroupId": "sg-29ee3753"
                        }
                    ],
                    "Ipv6Addresses": [],
                    "OwnerId": "xxxxxxxxxxxxx",
                    "SubnetId": "subnet-56facb1f",
                    "PrivateIpAddress": "172.31.32.238"
                }
            ],
            "SourceDestCheck": true,
            "Placement": {
                "Tenancy": "default",
                "GroupName": "",
                "AvailabilityZone": "us-west-2b"
            },
            "Hypervisor": "xen",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "RootDeviceType": "ebs",
            "RootDeviceName": "/dev/xvda",
            "VirtualizationType": "hvm",
            "AmiLaunchIndex": 0
        }
    ],
    "ReservationId": "r-075a4bba42ad67047",
    "Groups": [],
    "OwnerId": "xxxxxxxxxxxxx"
}

C:\Users\AVK>
========================================================================

Make a note of the InstanceID and go to AWS console and then to EC2 dashboard; our instance is launched and it is up and running.





Connect to it using the public DNS/IP.

Now we are able to launch an EC2 instance from AWS CLI successfully. 

Happy Learning!!!