Sunday, August 30, 2020

Sending emails in Oracle Cloud using Email Delivery

 Few days back, i had a task to send emails from Oracle Cloud. My first pitstop was the Oracle Documentation oracle Notes which is very precise. 


1. The first step would be create a new non federated user. As a best practice, we should not use the user using which we do the console administration.


2. Create SMTP credentials for user



                                     






  Copy the password and keep it safe.


3.  Setup permissions and policy

The new user must be assigned to a group with permissions to manage approved-senders and suppressions


 





    4. Create an approved sender

     



     This user will be needed to send emails.

   








5.  Configure SPF on the approved sender domain






6. Configure the SMTP connection

 

Update the Postfix main.cf file.

 

To open the main.cf file, run the following command:

 

sudo vi /etc/postfix/main.cf

 

 

 

Add the following information to the end of the file:

 

smtp_tls_security_level = may

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtp_sasl_security_options =

 

If the following line is present, either remove the line or turn it off:

smtpd_use_tls = yes

 

 

Update relayhost to include your SMTP connection endpoint and port.

relayhost = smtp.us-ashburn-1.oraclecloud.com:587

 

 

 

 

Create the sasl_passwd file in the same directory as main.cf

 

 

 

sudo vi /etc/postfix/sasl_passwd

 

 

add the content

smtp.us-ashburn-1.oraclecloud.com:587 ocid1.user.oc1..aaaaaaaacnikk6yarhsyxhjre7wdlzpt6jyj43i473m2uley4tup27snvyaa@***********..aaaaaaaaposae6cowatr3hfig5t46rhds6eapjn5a2rmovousqs76cyo43ta.ov.com:E1##48;8EnY}rSxA;(9J

 

 

Run the following command:

 

sudo chown root:root /etc/postfix/sasl_passwd

sudo chmod 600 /etc/postfix/sasl_passwd

 

 

Generate the password hash.

 

Run the following command:

 

sudo postmap hash:/etc/postfix/sasl_passwd

 

7. At this moment, we have completed the email delivery configuration. Now we need a relay server through which we can send the emails. Postfix is one of them and we are using it here.

1.      Start Postfix using root user

postfix start



8. Test email outbound


1.      Test email( using root user)

echo "This is a test message for postfix" | mail -s "Test Email-Delivery in OCI using Postfix from Samrat" -r samsin16@in.***com samratsinha05@gmail.com 


Ahh!!.. thats it. it wasn't complicated at all. The main objective is to get the right documentations and follow the steps one by one. 

Note: In Oracle EBS, we can also use this setup to configure our outbound mail server.


Hope, this helps someone


Issue:-

When Setting Up Email Delivery Service In OCI Error: "Email Is Not Available With Your Current Permissions. Contact Support in OCI instance" (Doc ID 2478986.1)

 

References:- https://docs.cloud.oracle.com/en-us/iaas/Content/Email/Reference/gettingstarted.htm

 

https://www.cyberciti.biz/faq/linux-unix-start-stop-restart-postfix/






Sunday, May 24, 2020

Load balancer dns url for EBS 12.2 in OCI

This is in continuation to my previous blog https://samappsdba.blogspot.com/2020/05/configuring-oci-load-balancer-for-ebs.html. In this post, we will go through the steps on how we can customize the Oracle Cloud Load balancer public IP with a custom URL. This is important, where we don't want to expose the IP of the Oracle Cloud LB to the end user.


As per my previous post, our Oracle Cloud Load Balancer is sitting infront of the two Oracle EBS 12.2 application server and as the policy is set to weighted round robin, hitting the public ip of Oracle Cloud Load Balancer  redirects  to the first web server and next to the second web server and so forth.









Now, i am going to construct the Oracle Cloud Load balancer URL as http://ebs.ebspoc.tech. In this post, I have not covered the SSL part. It will be taken up in the future posts.

In DNS Zone management of Oracle Cloud





Now create a A record with ebs.ebspoc.tech and lb public ip 150.XX.XX.XX and cname record with www.ebs.ebspoc.tech




And publish the changes.  Once the NS are added to the Domain Provider Zone management, it will take around 24 hours to get updated. We can do a nslookup to confirm if the changes have been updated or not.






Next, we need to modify the context file of the EBS web servers to point it to the LB.

s_webentryurlprotocol-http
s_webentryhost-ebs
s_webentrydomain-ebspoc.tech
s_active_webport-8001
s_login_page—http://ebs.ebspoc.tech/OA_HTML/AppsLogin
s_external_url- http://ebs.ebspoc.tech

shut down, autoconfig and start the services.

Now type the url

http://ebs.ebspoc.tech









next post, i will show how we can enable SSL and terminate it at the load balancer. 

Hope, this post helps someone. Happy learning cloud.









Saturday, May 16, 2020

Launch Compute instance using OCI-CLI

This is continuation to my previous post of on how to set up OCI-CLI in Oracle Cloud. In this post, i am going to create a compute instance using OCI-CLI.

Before we create a compute instance in Oracle cloud, we need to have basic details in hand.

The list of cli command reference can be retrieved from:-



1. Compartment id

oci iam user list –compartment-id

2. Availability Domain

[oracle@ebsapp01 .oci]$ oci iam availability-domain list --compartment-id ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a
{
  "data": [
    {
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a",
      "id": "ocid1.availabilitydomain.oc1..aaaaaaaatrwxaogr7dl4yschqtrmqrdv6uzis3mgbnomiagqrfhcb7mxsfdq",
      "name": "WDMA:US-ASHBURN-AD-1"
    },
    {
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a",
      "id": "ocid1.availabilitydomain.oc1..aaaaaaaauvt2n7pijol7uqgdnnsoojcukrijtmcltvfwxazmitk235wyohta",
      "name": "WDMA:US-ASHBURN-AD-2"
    },
    {
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a",
      "id": "ocid1.availabilitydomain.oc1..aaaaaaaaztunlny6ae4yw2vghp5go2zceaonwp6wiioe3tnh2vlaxjjl2n3a",
      "name": "WDMA:US-ASHBURN-AD-3"
    }
  ]




3. Compute Shape

oci compute shape list --compartment-id ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a


4. Image list

oci compute image list --compartment-id ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4



5. Subnet id

oci network subnet list --compartment-id ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a --vcn-id ocid1.vcn.oc1.iad.amaaaaaaj6x6wyqagy3kmguyjlv3ljjbxdov7p2s667mebh6mpcqnigis6wq


Now, we have all the details. We can create a json script and pass the retrieved values generated above 

Json script can be generated using

oci compute instance launch --generate-full-command-json-input >compute_template.json


In this post, i am not going to use the json script. I am just forming the command as below:-



oci compute instance launch --availability-domain "WDMA:US-ASHBURN-AD-3" -c ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a --shape "VM.Standard.E2.1" --display-name " ebsautoscale3" --image-id ocid1.image.oc1.iad.aaaaaaaasxwd6pbz6py3shznyfxuxexiatoxse7zyd7tz4tmra27wle6ydwq --ssh-authorized-keys-file "/home/oracle/.ssh/id_rsa.pub" --subnet-id ocid1.subnet.oc1.iad.aaaaaaaawridc2p4pnlzpra2rvoijzjevxvewgx7pwjn4ma4wwyu6oo6qala



{
  "data": {
    "agent-config": {
      "is-management-disabled": false,
      "is-monitoring-disabled": false
    },
    "availability-domain": "WDMA:US-ASHBURN-AD-3",
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaallneylfbz5g5l53nnbdnalamdwprd6les4fzmc22ylf2zb5diu4a",
    "dedicated-vm-host-id": null,
    "defined-tags": {},
    "display-name": " ebsautoscale3",
    "extended-metadata": {},
    "fault-domain": "FAULT-DOMAIN-1",
    "freeform-tags": {},
    "id": "ocid1.instance.oc1.iad.anuwcljsj6x6wyqcsl5v4tmkczngxzzi6wsc2wnzzkkvkx2jdx2i545ccjza",
    "image-id": "ocid1.image.oc1.iad.aaaaaaaasxwd6pbz6py3shznyfxuxexiatoxse7zyd7tz4tmra27wle6ydwq",
    "ipxe-script": null,
    "launch-mode": "PARAVIRTUALIZED",
    "launch-options": {
      "boot-volume-type": "PARAVIRTUALIZED",
      "firmware": "UEFI_64",
      "is-consistent-volume-naming-enabled": true,
      "is-pv-encryption-in-transit-enabled": false,
      "network-type": "PARAVIRTUALIZED",
      "remote-data-volume-type": "PARAVIRTUALIZED"
    },
    "lifecycle-state": "PROVISIONING",
    "metadata": {
      "ssh_authorized_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7yczf1oJki5RnHH97Bb2GDAxkYWc0R2OTPGTAXTmbN9Nsqh0KmckgoUa86rk2B8xT2dR2gezpjOVArva53ebrm3ciWZ3kcKoETG63VNoDdXCYQWIshbAn23Yyi9TLuP03iy9FLtsPT1vWeFq1hnFtqqiSOaUX/h5mcisZRhG9CrsTv+n+2HZjnGHSyf5ocmfBvbmwFBJX+8AnNq8Vj3m7mQb9ITVaFNOOSei5x9t1Rdfk/JhX2aOEmhiVHn/a8yD6OM7t1y02uxx+aZCOAn+2PzV+/R3MGDa5X0QPLPW7G+EJ8F/ek7/tyb2TrPWv8Fs4DRidHpDHsEp/Sy2TmgKb opc@ebsapp01\n"
    },
    "region": "iad",
    "shape": "VM.Standard.E2.1",
    "shape-config": {
      "gpu-description": null,
      "gpus": 0,
      "local-disk-description": null,
      "local-disks": 0,
      "local-disks-total-size-in-gbs": null,
      "max-vnic-attachments": 2,
      "memory-in-gbs": 8.0,
      "networking-bandwidth-in-gbps": 0.7,
      "ocpus": 1.0,
      "processor-description": "2.0 GHz AMD EPYC\u2122 7551 (Naples)"
    },
    "source-details": {
      "boot-volume-size-in-gbs": null,
      "image-id": "ocid1.image.oc1.iad.aaaaaaaasxwd6pbz6py3shznyfxuxexiatoxse7zyd7tz4tmra27wle6ydwq",
      "kms-key-id": null,
      "source-type": "image"
    },
    "system-tags": {},
    "time-created": "2020-05-13T09:30:12.144000+00:00",
    "time-maintenance-reboot-due": null
  },
  "etag": "e2630b3946def3135a89744a2e7c1b97abbf177141aa014ba14ee739b1903f49",
  "opc-work-request-id": "ocid1.coreservicesworkrequest.oc1.iad.abuwcljs5gowykihovdespl5vpj3aczance5nxzxchr2krarhpj573fv4bya"
}
[oracle@ebsapp01 .ssh]$

We can verify it from the console now














Saturday, May 2, 2020

Configuring OCI Load balancer for EBS 12.2

This is a step by step on how we can use Load balancer as a service for EBS 12.2 in OCI. I have a running EBS 12.2 instance running with two application nodes. The application is running on port number 8001 and to make it highly available, i will be using LbaaS sitting infront of them.

1. Create a load balancer security lists. We will not add any rules to it.



2. Create the route table and add the internet gateway to it.


3. Create two AD specific subnet



   




4.   Create load balancer. Here i am creating a public load balancer so it will be accepting requests from internet.







click on add backend servers


choose the port for ebs 8001







Click on submit.

Once the load balancer is created, add the below ingress and egress rule to the security list for load balancer(LB Security list)






Hope it helps someone. Happy learning.