Advertisement

Showing posts with label Cloud. Show all posts
Showing posts with label Cloud. Show all posts

Thursday, December 5, 2019

AWS: Boto3: Send Message Queue

In this simple example, I configure AWS Boto3 to send a message to known queue.


import boto3
sqs = boto3.resource('sqs')
queue = sqs.get_queue_by_name(QueueName='Your_Queue_Name')
response = queue.send_message(MessageBody='BodyText')
print(response.get('MD5OfMessageBody'))


Note - you must configure your Access Credentials, the way they can be done is given in the URL Below 
I generally prefer to set it as my shell variable, but it is totally up to you.
The user/object with which you are accessing should have SQS Policy Attached so that it can write to the Queue.

AWS : Lambda: Add IP to Security Group Using Boto3

In this blog I am going to show example on adding an IP address to AWS security group using Boto3.

The way is simple, just create your own Lambda and add the below Code. 
You can have trigger of SQS and put an example IP in the Body . 


import json
import boto3

ec2 = boto3.resource('ec2')
s_group = ec2.SecurityGroup('sg-0308cd0e895d42ac2')
# This is your Security group unique ID


def lambda_handler(event, context):
    failed = False;
    
    try:
      print ("The value IS " + s_group.group_id)
      for record in event['Records']:
        ip = record["body"]
        print (str(ip))
        response = s_group.authorize_ingress(IpProtocol="tcp", CidrIp=str(ip),FromPort=80,ToPort=80)
    except Exception:
      logger.exception("Failed to Add IP")
      # Add your failure function 
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }


Sample Event to Use

{
  "Records": [
    {
      "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
      "receiptHandle": "MessageReceiptHandle",
      "body": "10.2.3.0/32",
      "attributes": {
        "ApproximateReceiveCount": "1",
        "SentTimestamp": "1523232000000",
        "SenderId": "123456789012",
        "ApproximateFirstReceiveTimestamp": "1523232000001"
      },
      "messageAttributes": {},
      "md5OfBody": "7b270e59b47ff90a553787216d55d91d",
      "eventSource": "aws:sqs",
      "eventSourceARN": "arn:aws:sqs:us-east-1:123456789012:MyQueue",
      "awsRegion": "us-east-1"
    }
  ]
}

Reference: https://docs.aws.amazon.com/code-samples/latest/catalog/python-ec2-create_security_group.py.html



Tuesday, September 3, 2019

Amazon Web Services (AWS) : Placement Groups

In this blog, I am going to discuss an important new features which AWS has released which is called as placement groups. 

So, what are placement groups.
Placement groups are basically directives given to AWS Kernel to place your EC2 instances at specific locations. 
And what are these locations
- specific AZ
- specific RAC
- Zone based
and etc

So, As of now (Sep -2019), AWS has come up with 3 types of placement groups 

  1. Cluster
  2. Spread
  3. Groups
Let's see what is what 
Cluster - Cluster Placement Group is basically a directive to launch EC2 instances within the same Rack.
Visualize thousands of servers placed in Amazon Data Centers and they are placed in different racks, so when you give 'Cluster' as placement group, all the instances will be launched within the same RAC (in same AZ).
Pros 
  1. Great in terms of networking (10Gbps between 2 instances)
  2. Gives low latency and high n/w throughput
  3. Jobs such as Big data benefit 

Cons 
There is one big issue, if the RAC fails, you loose all the instances. 


Spread
Now visualize within all the data centers and you want to distribute your highly available application within multiple data centers, so spread helps you with that - with instances spanning multiple AZs and different physical RAC if in the same AZ.

Pros 

  1. Reduced Risk in terms of failure
  2. All the instances are on different physical hardware 
  3. Provides High Availability for critical applications
Cons
  1. You are limited to 7 instances per AZ per placement group. 

Partition
Within one AZ , span  multiple partitions, and what is partition, an isolation created by AWS in their data centers which is a physical boundary and ensures one partition's availability does not affects others. 

Pros
  1. Instances do not share racks with other instances
  2. Safe from partition failure
  3. EC2 instance get access to partition information as metadata
  4. Can spawn 100s of instances
Cons
  1. The limitation put by AWS (as of now) is 7 partitions per AZ

Friday, August 23, 2019

Amazon Web Services (AWS) : Budget

One of the best feature of learners is the AWS budget feature. 
this feature sends alerts to you when you reach a certain criteria of Budget. 
For example if you budget for say 5 dollars, and can get alerted when you reach 50% of your limit. 

This can help reduce your spend cost, due to instances which might have been spin up and you totally forgot about it. 


You can follow the below process to create budget. 





Rest is mostly intuitive, (Most of it is intuitive by the way)

Tuesday, December 18, 2018

Oracle Database - Exadata and Exadata Cloud - Important MoS Doc ID's

In this blog  I will write on all the important links for Exadata which will be useful to you. 


This are very helpful links, which can help you keep updated with Exadata DB Machine in premise or if you are servicing one for a customer. 

So keep them handy.. :)

  1. Exadata Database Machine and Exadata Storage Server Supported Versions (Doc ID 888828.1)
  2. Engineered Systems Resource Center - Doc ID 1392174.1 
  3. Information Center: Oracle Exadata Database Machine - Doc ID 1306791.1  
  4. Information Center: Using Oracle Exadata Database Machine - Doc ID 1460198.2 
  5. Information Center: Upgrading Oracle Exadata Database Machine - Doc ID 1364356.2
  6. Exadata System Software Certification - Doc ID 2075007.1 
  7. Exadata Storage Software Versions Supported by the Oracle Enterprise Manager Exadata Plug-in - Doc ID 1626579.1 
  8. Exadata Software and Hardware Support Lifecycle- Doc ID 1570460.1 
  9. Oracle Exadata Best Practices – Doc ID 757552.1 
  10. Oracle Exadata Database Machine Setup/Configuration Best Practices - Doc ID 1274318.1
  11. Exadata Critial Issues - Doc ID 1270094.1
  12.  How To Collect Diagpack Diagnostic Package In Exadata - Doc ID 2226173.1
  13. Oracle Exadata Database Machine exachk or HealthCheck – Doc ID 1070954.1

    Exadata Cloud
  14. Information Center: Oracle Database Exadata Cloud - Doc ID 2334729.2
  15. Information Center: Patching and Maintaining Oracle Database Exadata Cloud - Doc ID 2334779.2
  16. Known Issues for Oracle Database Exadata Cloud Service - Doc ID 2249093.1
  17. Exadata Cloud Service Software Versions - Doc ID 2333222.1
  18. Known Issues for Oracle Database Exadata Cloud Machine - Doc ID 2252305.1
  19. Technology Cloud Services (PaaS and IaaS) Maintenance Schedule - Doc ID 2131053.2

Monday, September 17, 2018

Oracle Cloud (OCI) - Creating Compartments

In this blog I discuss on how to create compartments in Oracle Cloud.

Compartments are an essential component and one of the key differentiators of OCI compared to other cloud vendors in market. 

These act like containers of the resources within the same tenancy ID.

They help in separating resources and policies on resources which can be a real useful feature in a big environment.

Now let's see how to create a compartment (and how simple it is indeed to create one)

They can be simply created in 4 steps as you can see below.

Step 1 - Go to Compartments (Identity --> Compartments)


Step 2 - Click Create Compartment

Step 3 - Enter Details of the compartment and Click "Create Compartment"


Step 4  -Verify the name of the compartment and details.
You must note a compartment cannot be deleted as per this version of OCI, so unless you have a test account, do not end up creating junk :)


Tuesday, August 28, 2018

Oracle Cloud (OCI) - VM RAC Database Creation - Part 2/2

This blog is in continuation with my previous blog on VM RAC DB Creation.
You had created a VM RAC and it was in provisioning state.

In this blog we look into how to see details of the instances and access them. 

Wait for the system to become available from provision state - Wait time is about 1 hour for me.
Step 1 - Click on "View DB System Details" to view details of the system. 


Step 2 - Note down DB Details such as scan name, IP addresses etc for your usage. 



Step 3 - Bottom Left click on Nodes to see Nodes of the database


Step 4 - Note down the Private IP address and DNS name for the instances which have been launched. 




You can see as in RAC cluster, there is floating IP (VIP), Scan addresses and Public IPs.
There are obviously Private interfaces, which we will look shortly after logging on to the system. 

To Login to system you need to provide the rsa key. I will use the Windows VM which was launched as part of this series and login. To see details on login see my previous blog.

We will use any of the private ip address which was generated  - 10.10.11.4 and 10.10.11.5 to login.

ssh -i id_rsa opc@10.10.11.4

[opc@rac1 ~]$ ps -ef | grep pmon
grid      2206     1  0 05:46 ?        00:00:00 asm_pmon_+ASM1
grid     11892     1  0 05:48 ?        00:00:00 apx_pmon_+APX1

oracle   50457     1  0 06:19 ?        00:00:00 ora_pmon_db181

sudo su - 
[root@rac1 ~]# /u01/app/18.0/grid/bin/olsnodes -t
rac1    Unpinned

rac2    Unpinned

[root@rac1 ~]# /u01/app/18.0/grid/bin/oifcfg getif
eth0  10.10.11.0  global  public
eth1  192.168.16.0  global  cluster_interconnect,asm


[root@rac1 ~]#  /u01/app/18.0/grid/bin/crsctl stat res -t  | less
[root@rac1 ~]# /u01/app/18.0/grid/bin/srvctl config database
db18_iad2rj
[root@rac1 ~]# /u01/app/18.0/grid/bin/srvctl status database -d db18_iad2rj
Instance db181 is running on node rac1
Instance db182 is running on node rac2

[root@rac1 ~]# /u01/app/18.0/grid/bin/srvctl config scan
SCAN name: rac-scan.privatesubnet1.dbvcn.oraclevcn.com, Network: 1
Subnet IPv4: 10.10.11.0/255.255.255.0/eth0, static
Subnet IPv6:
SCAN 1 IPv4 VIP: 10.10.11.8
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
SCAN 2 IPv4 VIP: 10.10.11.9
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
SCAN 3 IPv4 VIP: 10.10.11.10
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:


ssh -i id_rsa opc@10.10.11.5

[opc@rac2 ~]$ ps -ef | grep pmon
oracle   12376     1  0 06:19 ?        00:00:00 ora_pmon_db182
opc      33405 33365  0 06:55 pts/0    00:00:00 grep pmon
grid     79123     1  0 05:45 ?        00:00:00 asm_pmon_+ASM2
grid     93356     1  0 05:48 ?        00:00:00 apx_pmon_+APX2



Oracle Cloud (OCI) - VM RAC Database Creation - Part 1/2

In this blog I talk about VM RAC Database Creation. 
Go to DB system Launch Page and click on Launch DB system. 

In this part we are going to launch VM standard 2.2 - 2node cluster. 
This is in continuation with my blog series of manual launch of OCI services.
You can track the complete series and my other blogs in my KB Blog.

Step 1 - Click on Launch DB system and provide the details.
IN case you are using a trial account then you will have to raise an SR with Oracle to increase your service limits to have 4 oCPUs to allow launch of 2 oCPU x 2 nodes.

Keep the size limited due to limitations put on service limits by OCI.



Step 2 - Name your cluster anything you want

Step 3 - Provide further details. 


Step 4 - Provide DB Password and click on Launch finally




Step 5 - Server will go to Provisioning takes - It can take up to 2-4 hours for the service to get launched and servers to be in available state.

In the next blog I discuss on how to access the servers and view your data.

Friday, August 24, 2018

Oracle Cloud (OCI) - Part 8 - DB Instance Verification and Access

In this blog we are going to access the newly created DB VM.

In order to do so 
Use ssh to ssh to the server 

ssh -i .ssh/id_rsa opc@10.10.11.3 

where 10.10.11.3 is the private IP of the machine You can do your normal operations as in Linux 

opc user has sudo access 

Verify Running processes. 

[opc@ocdb ~]$ sudo su -
[root@ocdb ~]# su - oracle
[oracle@ocdb ~]$ ps -ef | grep pmon
oracle   25963 25883  0 08:24 pts/0    00:00:00 grep pmon
grid     70954     1  0 07:16 ?        00:00:00 asm_pmon_+ASM1
oracle   85219     1  0 07:39 ?        00:00:00 ora_pmon_db12

grid     86676     1  0 07:18 ?        00:00:00 apx_pmon_+APX1


Verify Connectivity using SQL Developer
Connect as sysdba and make sure to enter the details as given to me during BM / VM Creation


Oracle Cloud (OCI) - Part 7 - Database VM Creation

This is in continuation with last blog of Windows System access and Creation. 

In this blog we will create a Database VM. 

Step 1 - Click on "Bare Metal, VM, and Exadata"


Step 2 - Click on "Launch DB System"


Step 3 - Provide in DB System information. Select AD with Private IP address . 


Step 4 - Provide details of storage, licensing and network. 


Step 5 - Provide hostname prefix, DB name and other details.




Step 6 - Cick on Launch DB system.

Step 7 - Click on Launch DB system.
 Step 8 - Wait till the status turns green. 




Oracle Cloud (OCI) - Part 6 - Configure Windows System

In this blog I am going to access the newly added Windows System which is created. 


Step 1 - Open Mstsc and put in Public IP as found in last blog's page. 

Note down Public IP and Initial Password, you must change your password after first login. 



Step 2 - Verify IP address using cmd

Step 3 - Download Firefox, Mobaxteerm and puttygen
Technical Issue resolved in Downloading Firefox.


Oracle Cloud (OCI) - Part 5 - Create Compute Instance (Windows)

This blog is in continuation of my last blog of addition of Route Rules and Security ACL's. 

In this blog we create a Windows Instance on Public Network, this instance will be used to access the Database VM which we create in the later blogs. 


Step 1 - Click on Compute --> Instances

Step 2 - Click on "Create Instance" 

Step 3 - Provide Details of Instance (windows Server)



Step 4 - Choose Public Subnet, AssignPublic IP Address, Select Security List and finally cick on Create Instance.

 Step 5 - Provisioning Screen appears


 Step 6 - Wait till status becomes available and see password and Public IP from the highlighted boxes in the screenshot. 




Oracle Cloud (OCI) - Part 4 - Create Route Table and ACL Manually

This blog is in continuation with my last blog of Creation of creation of IGW

We continue our journey of creation and configuration of VCN. In this blog we create a route table for machines to access internet in Public Subnet. 

Step 1 - Click on Route Tables on the Left

Step 2 - Click Edit Route Table


 Step 3 - Create new route for machines to access internet using IGW - as shown below. 

Step 4 - Click on "Security Lists"

Step 5 - Click Edit and Add new Ingress rule as below for RDP access.


Step  6- Next Blog we discuss on how to create a compute instance of Windows

Oracle Cloud (OCI) - Part 3 - Creating Internet Gateway (IGW) Manually

This is continuation with last blog of creation of Subnet Manually.
We continue in this blog and create Internet Gateway for Internet Access. 

Step 1 - Click on "Internet Gateways" on the left.

Step 2 - Click on "Create Internet Gateway"


Step 3 - Provide Name to Internet Gateway 



Step 4 - Click Create Internet Gateway and wait for completion. 


Step 5- In next blog we create Route Table for Newly added Gateway.

Oracle Cloud (OCI) - Part 2 - Creating Subnet Manually

This is blog is in continuation with Part 1 - Creating VCN Manually

In this blog we continue with the last blog, and now create a Subnet in the newly created VCN. 

Step 1 - Click Create Subnet

Step 2 - Provide Details
Provide Name, CIDR Block , Route Table and mention this Subnet as Public Subnet. 



Step 3 - Provide DNS Label and choose default security list 


Step 4 - Click on Create Subnet. 



Step 5 - Click Create Subnet to create a new pvt Subnet 
This subnet will host our Database VM

Step 6 - Put in Details of Subnet as below. 
Make sure it is private Subnet.


Step 7 - Put in details and click "Create" 

Now we have 2 subnets, one designated public and other as private. 


Step 8 - Next Create Internet Gateway