Category: Cloud

  • Allow ICMP (ping) in Oracle Cloud

    Allow ICMP (ping) in Oracle Cloud

    Oracle cloud do not allow ICMP/ping to compute instances. To enable ping, you need to enable ICMP in the security group.

    On your compute instance details page, you will see “Virtual Cloud Network”.

    oracle cloud vpc

    Click on Virtual Cloud Network link, that will take you to page with VPC details.

    Oracle Virtual Cloud Network

    Scroll down, you will see subnet.

    Oracle Cloud Public Subnet

    Click on Public Subnet, on next page, it shows details about the subnet. Under Security Lists, you will see Default Security List for VirtualCloudNetwork. Click on it to see your firewall rules.

    oracle cloud ingress rules

    Click Add Ingress Rules button to add new rule. By default port 22 (SSH) allowed from everyone. ICMP was blocked for everyone (rule 2 and 3).

    To allow ICMP, you can add a new Rule for ICMP.

    Oracle Cloud Add Ingress Rule

    On Add Ingress Rules page, select

    SOURCE TYPE = CIDR
    SOURCE CIDR = 0.0.0.0/0
    IP PROTOCOL = ICMP

    Click Add Ingress Rules button. Now you should be able to ping to any compute instances on this VPC. It is safe to remove 2 of the existing ICMP rules or edit them instead of adding new rule.

    See Oracle Cloud

  • Connect to Google Cloud SQL

    To connect to Google Cloud SQL, run

    gcloud sql connect DB_INSTANE_NAME
    

  • Amazon S3 CORS

    To enable CORS for Amazon S3 bucket, add

    
    
      
        *
        PUT
        POST
        DELETE
        1800
        *
      
    
    
  • Google Cloud App Engine

    To list instances in Google Cloud App Engine, run

    gcloud app instances list
    

    To create an application

    gcloud app create
    

    To deploy an application

    gcloud app deploy
    
  • Google Cloud SQL

    To create a Google Cloud SQL database, run

    gcloud sql instances create INSTANCE_NAME_HERE --activation-policy=ALWAYS --tier=db-n1-standard-1
    

    INSTANCE_NAME_HERE = this can be anything, lowercase letters, 0-9, for identification purpose only.

    db-n1-standard-1 => this is size of the server, you can change it as needed.

    To create a Database, run

    gcloud sql databases create DB_NAME_HERE --instance INSTANCE_NAME_HERE
    

    To create a User, run

    gcloud sql users set-password root --host=%  --instance INSTANCE_NAME_HERE  --password=PASSWORD_HERE
    

    To list all google cloud SQL instances, run

    gcloud sql instances list
    

    Google Cloud SQL

    To list all databases in a Google Cloud SQL server, run

    gcloud sql  databases list --instance INSTANCE_NAME_HERE
    

    list databases in google cloud sql

    To connect to Google Cloud SQL database, run

    gcloud sql connect INSTANCE_NAME_HERE
    

    This will open firewall rule and add your IP so you can connect to Google Cloud SQL server.

  • Set Permanant hostname on AWS EC2 CentOS 7 server

    On AWS EC2 when you boot, hostname set something like ip-172-31-41-172.eu-central-1.compute.internal

    To chaneg this, run

    hostnamectl set-hostname --static HOSTNAME_HERE

    Example

    hostnamectl set-hostname --static server1.serverok.in

    To disable change of hostname, run

    echo "preserve_hostname: true" > /etc/cloud/cloud.cfg.d/99_hostname.cfg

    Now reboot your server with

    reboot

    Back to hostname

  • Resize Amazon EC2 Boot Disk

    Resize Amazon EC2 Boot Disk

    Once you resize the disk in the Amazon AWS console, it gets auto resized on reboot. Sometimes this won’t happen, you have to manually resize the disk.

    Resize EC2 file system with LVM

    To resize the disk, do the following.

    1) Take a snapshot of the disk
    2) Create a new server in the same availability zone as the current server. Let’s call it tmpServer.
    3) Shutdown tmpServer.
    4) Shutdown the server that need disk resized. Lets call it mainServer. Make sure you have Elastic IP, if not shutting down changes IP of the server.
    5) Detach the disk.
    6) Attack the disk in tmpServer as /dev/xvdf
    7) Start tmpServer.

    Login to tempServer and do the following.

    Resize Partition

    Firt find the devices

    parted -l
    

    In this cause /dev/xvdf is the disk that need to be resized. Current Size is approx 107 GB.

    To see free disk space on this disk, run

    parted /dev/xvdf print free
    

    There is 21.5GB free space on the disk.

    To grow partition 1 to use up remaining disk space, run command

    growpart /dev/xvdf 1
    

    Verify free disk space after. Now you see there is not much free disk space left after partition 1.

    Resize FileSystem

    Resize file system depends on the type of file system you are using. For ext4, do the folllowing.

    Check disk using e2fsck

    e2fsck -f /dev/xvdf1
    

    If any errors found, you will be asked to press “y” to fix the errors. After e2fsck run, you can reszie filesystem with command

    resize2fs /dev/xvdf1
    

    You have completed resizeing the disk. All you need to do now is

    8) Shutdown tmpServer
    9) Detact the disk from tmpServer (/dev/xvdf)
    10) Attach the disk on original server mainServer as /dev/sda1.

    11) start the mainServer.

  • VMWare ESXI add SSH key

    To enable password less SSH login on VMWare ESXI server, add your SSH key to file

    /etc/ssh/keys-root/authorized_keys
    
  • VMWare esxcli

    To list all running VM, run

    esxcli vm process list
    

    To list all installed software

    esxcli software vib list
    

    Example

    [root@server:~] esxcli software vib list | grep esx-ui
    esx-ui                         1.33.1-12086396                       VMware   VMwareCertified   2019-02-24
    [root@server:~] 
    
  • Google Cloud open a port in firewall

    To open port 80 globally for all VMs on google cloud project, run

    gcloud compute firewall-rules create allow-port80-all --allow tcp:80 --source-ranges 0.0.0.0/0 --network default