Tuesday, December 31, 2019

Happy-new-year-2020

Real happiness is in ..
  1. unconditional love
  2. sharing knowledge 
  3. Forget & Forgive
  4. Be listenable 
  5. winning yourself
  6. smile  at others
  7. daily exercise
  8. Involve in sports
  9. Play with kids
  10. Talk over texting
  11. Live the moment
  12. Failing and rising  
  13. brush twice a day
  14. take a family  medical insurance
  15. Take a term policy
  16. Involve in your passion or hobby daily
  17. Improve on a second profession
  18. Music On - Dance alone 
  19. listen to  light music
  20. Go office  early ðŸ˜€ and reach home safe (wear seat belt and helmet)
  21. Happy new year 2020 wishes to all my friends and family members

Friday, May 10, 2019

How to remap/restore the openstack volume data

How to remap/restore the openstack volume data, post rebuilding the instance (by preserving/restoring its old IP address):

Issue: 
If an instance went to non-recoverable state, due to back-end hypervisor hardware (or) software failure, application team are forced to create a new instance from the base image by restoring its IP address and volume data to bring the application back online.

Message/logs/symptoms of Hypervisor Failure:

[Errno 30] Read-only file system: '/var/lib/nova/instances/.directio.test'

Name
prod-app1-os-chn-web-1
ID
ddd878bd-a3434-333-a3fb-a45r456yy432
Status
Error
Availability Zone
nova
Created
Jul. 07, 2018, 6:01 A.m.
Time Since Created
10 months
Fault

  • Instance is in an unrecoverable state.
  • Instance was not accessible. Soft/Hard reboot did not fix, and now instance is in a "No State" status.
  • Instance hosted on oscomp-chn-h01 which is currently down due to disk failure. Disk replacement required which results to data loss. Openstack team recommends to destroy and rebuild the instance.

Importance of Preserving the IP of an cloud instance:-

  • Any firewall changes by firewall team done for enabling the infra  access (such as Database) with this instance IP, will not have to be repeated. 
  • Any front-end server (haproxy) which is mapped to this backend instance IP (in haproxy.cfg), don't have to be changed.
  • Any changes to GSLB (Global Server Load Balancing) for mapping the global domain name (eg: redhat.com) backend server ip address, need not be changed.
Background of Openstack:

Openstack is a public/private cloud platform  for hosting the virtual machines in an hypervisor, for an application to be hosted in cloud, with the below list of essential cloud infrastructure services and its purpose.


  • Keystone - Authentication/Authorization
  • Neutron - Networking
  • Glance - Instance Images
  • Swift -  Unstructured Storage / Object BLOB (Binary Large Object)
  • Cinder - Block Storage
  • Heat - Openstack Orchestration 
  • Horizon - Openstack Dashboard
  • Ceilometer - Monitoring / Metering
  • Nova - Computing (cpu/memory/disk)


If you would like to take a look at the additional services of openstack , refer to openstack-components

Steps to restore openstack volume data (once the instance is back online after preserving the IP address):

Assuming the application team restored the instance and mapped the openstack volume data of the instance under disk name /dev/vdb.

Our aim is to restore the 500GB volume data (in the original server path /var/logs/webserver_logs ) and bring back the application online.

In the Linux instance explained in this scenario, the data in the original server path /var/logs/webserver_logs is organized in terms of physical volume / volume group / logical volumes / application mount point/folder name/path. 

In our case 500GB volume data is stored in terms of:

  • physical volume name: /dev/vdb
  • volume group name: vg_web_logs
  • logical volume name: lv01_web_logs
  • application mount point/folder name/path in linux : /var/logs/webserver_logs
  1. Makes sure the newly re-built (centOS 7.x is the operating system image) instance has the lvm2 (Logical Volume Manager) package installed.

      2. lvmdiskscan command : Scans all SCSI, (E)IDE disks, multiple devices and a bunch of other block devices in the system looking for LVM physical volumes.


 3. lvscan command : Scans all known volume groups or all supported LVM block devices in the system for defined Logical Volumes. The output consists of one line for each Logical Volume indicating whether or not it is active, a snapshot or origin, the size of the device and its allocation policy. 



4. modprobe command : To trigger the kernel module. Scan your system for LVM volumes and identify in the output the volume group name that has your Centos 7.x volume (in this case volume group name from old instance is vg_app1_logs):


5. vgchange command: Sets the availability of a volume group to yes or no


6. Issue lvscan command again to activate the logical volume

7.  The Device-mapper is a component of the Linux kernel (since version 2.6) that supports logical volume management. It is required by LVM2 and EVMS Enterprise Volume Management System. The original LVM (included in stock 2.4 kernels) does not use it.If you intend to use Device-mapper, as well as including it in your kernel, you should install the userspace configuration tool (dmsetup) and library (libdevmapper).


8. And finally mount the volume data from the logical volume device path /dev/vg_web_logs/lv01_web_logs to file system mount point/path /var/logs/webserver_logs ,we have restored in the application volume  path /var/logs/webserver_logs a data of 22GB data present out of 500GB disk space.


9. df command: disk free command output below shows the restored volume data like Filesystem | Type | Size | Used | Available Space | Use % and Mount Point path in server/instance.


10. Congratulations!. Now we can go ahead and bring the application back online, in this case it is a web server.

References:

  1. https://www.openstack.org/software/project-navigator/openstack-components#openstack-services
  2. https://linux.die.net/man/8/


Thursday, April 25, 2019

Google Cloud SDK Install and Configure


How to install Google Cloud SDK and Configure for Google Cloud Platform (GCP).

  1. Get access to https://console.cloud.google.com by getting a free tier account activated with your google account and a valid credit card.
  2. Google Cloud SDK is a command-line interface for controlling Google Cloud Platform products and services. 
  3. Download the file GoogleCloudSDKInstaller.exe from https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe (For Windows Platform) . For other platforms, please refer to https://cloud.google.com/sdk/
  4. Once downloaded double-click the installer executable file from downloads folder and complete the installation.
  5. Hold on folks, we are not done with the job yet.!!
  6. Now configure the cloud SDK installer for google  using gcloud init console command,  similar to below one: 




  7. Test the working of gcloud CLI by the command below:
    • gcloud compute images list /*To list the operating System images available by default in GCP */
    • gcloud compute zones list
      /*To list the availability zones available by default in GCP */
    • gcloud compute instances create demo-jenkins-instance-1 --image-project centos-cloud --image centos-7-v20190423 --machine-type n1-standard-1 --zone asia-northeast1-a /* To create an instance in gcp by passing relevant parameters */
    • gcloud compute instances describe <instance name>  /*To check for existing instance in gcp, use the command similar to below*/ 
    • Sample Output
    • >gcloud compute instances describe demo-tomcat-instance-1 

    • canIpForward: false

      cpuPlatform: Intel Haswell

      creationTimestamp: '2019-03-16T04:33:56.843-07:00'

      deletionProtection: false

      description: ''
      disks:
      - autoDelete: true
        boot: true
        deviceName: demo-tomcat-instance-1
        index: 0
        interface: SCSI
        kind: compute#attachedDisk
        licenses:
        - https://www.googleapis.com/compute/v1/projects/centos-cloud/global/licenses/centos-7
        mode: READ_WRITE
        source: https://www.googleapis.com/compute/v1/projects/subtle-poet-231812/zones/us-east1-b/disks/demo-tomcat-instance-1
        type: PERSISTENT
      id: '7314555617687986636'
      kind: compute#instance
      labelFingerprint: 42WmSpB8rSM=
      machineType: https://www.googleapis.com/compute/v1/projects/subtle-poet-231812/zones/us-east1-b/machineTypes/n1-standard-1
      metadata:
        fingerprint: sKpdoLSMkQ8=
        kind: compute#metadata
      name: demo-tomcat-instance-1
      networkInterfaces:
      - accessConfigs:
        - kind: compute#accessConfig
          name: External NAT
          natIP: 34.73.246.154
          networkTier: PREMIUM
          type: ONE_TO_ONE_NAT
        fingerprint: mlzggKQryXg=
        kind: compute#networkInterface
        name: nic0
        network: https://www.googleapis.com/compute/v1/projects/subtle-poet-231812/global/networks/default
        networkIP: 10.142.0.5
        subnetwork: https://www.googleapis.com/compute/v1/projects/subtle-poet-231812/regions/us-east1/subnetworks/default
      scheduling:
        automaticRestart: true
        onHostMaintenance: MIGRATE
        preemptible: false
      selfLink: https://www.googleapis.com/compute/v1/projects/subtle-poet-231812/zones/us-east1-b/instances/demo-tomcat-instance-1
      serviceAccounts:
      - email: 443849179644-compute@developer.gserviceaccount.com
        scopes:
        - https://www.googleapis.com/auth/devstorage.read_only
        - https://www.googleapis.com/auth/logging.write
        - https://www.googleapis.com/auth/monitoring.write
        - https://www.googleapis.com/auth/servicecontrol
        - https://www.googleapis.com/auth/service.management.readonly
        - https://www.googleapis.com/auth/trace.append
      startRestricted: false
      status: RUNNING
      tags:
        fingerprint: 42WmSpB8rSM=
      zone: https://www.googleapis.com/compute/v1/projects/subtle-poet-231812/zones/us-east1-b
    • >gcloud compute instances create demo-jenkins-instance-1 --image-project centos-cloud --image centos-7-v20190423 --machine-type n1-standard-1 --zone asia-northeast1-a

    • >gcloud compute instances create demo-ansible-instance-1 --image-project centos-cloud --image centos-7-v20190423 --machine-type n1-standard-1 --zone asia-northeast1-a




      Congratulations you have successfully created an instance in google cloud in no time. ssh using your project private key , user name and External IP. I use git bash (for windows https://git-scm.com/download/win) for taking remote ssh connections of servers.

      Please feel free to add in comments if you face any difficulties. I will be happy to help you.