Author: Sreekumar Kj

  • Flush DNS cache in Ubuntu 20.xx and above

    On bash, run –

    sudo systemd-resolve --flush-caches

    Should be done.

  • Change the datacenter set in cassandra-rackdc on Ubuntu

    Problem: Changing just the datacenter name in cassandra-rackdc.properties gives the error:

    Cannot start node if snitch's data center [newName] differs from previous data center [oldName]. Please fix the snitch configuration, decommission and rebootstrap this node or use the flag -Dcassandra.ignore_dc=true.

    Solution:
    If you are just beginning to setup you cassandra cluster, and is ok to reset the data to bootstrapped state, do this

    sudo service cassandra stop
    sudo rm -R /var/lib/cassandra
    sudo mkdir /var/lib/cassandra
    sudo chown cassandra /var/lib/cassandra
    sudo service cassandra start
    

    If you need to persist the existing data, do this

    sudo vi /etc/cassandra/cassandra-env.sh
    # edit the JVM_OPTS line to make it look like below
    JVM_OPTS=\"$JVM_OPTS -Dcassandra.ignore_rack=true -Dcassandra.ignore_dc=true\"
    
    sudo service cassandra restart

    This should normally resolve the dc name correction in rack-dc properties file.

  • RabbitMQ installation fails in in the last leg of setting up in ubuntu 20.04

    Error:

    Setting up rabbitmq-server (3.8.16-1) …
    Job for rabbitmq-server.service failed because the control process exited with 
    error code.
    See "systemctl status rabbitmq-server.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript rabbitmq-server, action "start" failed.

    Reason: libtinfo.so library missing.

    Solution:

    sudo apt install libncurses5

    Note: No need to reattempt the installation.

  • An “eat dosa!” reminder for busy kids 🙂

    Here is a one hour HTML app that you can use to repeat recorded audio to remind your busy kids they have to finish that food on the table, while watching their favorite videos on YouTube.

    Launch Dosa Reminder HTML App

    To use the app is this simple –

    • Click on record button. Give permission to access microphone if it asks for it.
    • The recording automatically stops in 4 seconds and replays what it recorded. You can re-record till you are satisfied with the playback.
    • Now you can set the number of seconds of interval, between which the above audio has to be repeated.
    • Click on “Start Reminder” button to start the reminders.
    • When your kid is done eating, you can stop the reminders by clicking “Stop Reminder” button

    Happy parenting !

  • Enable dark mode for Chrome on desktop

    Here is how you can apply dark more on chrome on your desktop –

    • In the address bar paste this address : chrome://flags/#enable-force-dark
    • Change the setting “Force Dark Mode for Web Contents” from default to “enabled”

    That’s it. Now you can have easy on eyes theme on Chrome, just like your IDE !

  • NPM install gives error : Cannot find module ‘semver’

    Problem:
    We get this error when we do npm install –

    Error: Cannot find module ‘semver’
    Require stack:

    • /usr/share/npm/lib/utils/unsupported.js
    • /usr/share/npm/bin/npm-cli.js
      at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
      at Function.Module._load (node:internal/modules/cjs/loader:769:27)
      at Module.require (node:internal/modules/cjs/loader:996:19)
      at require (node:internal/modules/cjs/helpers:92:18)
      at Object. (/usr/share/npm/lib/utils/unsupported.js:2:14)


    Reason:
    Version issues

    Fix:
    Run these commands

    sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* ~/.npm
    sudo rm -rf /usr/local/lib/node*
    sudo rm -rf /usr/local/bin/node*
    sudo rm -rf /usr/local/include/node*
    
    sudo apt-get purge nodejs npm
    sudo apt autoremove
    sudo apt-get install nodejs npm

    Try now. Should be fixed !

    Note: In case the version didn’t get updated even after following the above command use these set of commands:

    sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* ~/.npm
    sudo rm -rf /usr/local/lib/node*
    sudo rm -rf /usr/local/bin/node*
    sudo rm -rf /usr/local/include/node*
    
    sudo apt-get purge nodejs npm
    sudo apt autoremove
    
    Download the latest installable archive for your OS from https://nodejs.org/en/download/
    
    tar -xf your-archiveFile
    sudo mv extracted-archiveFolder-name/bin/* /usr/local/bin/
    sudo mv extracted-archiveFolder-name/lib/node_modules/ /usr/local/lib/
  • Fix : Docker node down after restartIP Telephony – bit rates of audio formats, and other notes

    The bit rates for the most common audio formats –

    ALAW8 BITS
    ULAW8 BITS
    PCM16 BITS SIGNED/UNSIGNED
    ADPCM8 BITS

    The endian-ness for more than one byte systems:

    Motorola ProcessorsBig Endian
    Intel ProcessorsSmall Endian
  • Cannot connect to DB from a process inside Docker container ? This could fix it.

    I had recently hit a blocker to production deployment, when my processes just won’t connect to my Cassandra DB from within their containers.

    This is how I could fix it –

    • Start by checking if the target port is open. For eg, if it is the Cassandra DB that the processes cannot access, make sure that its host port 9042 is not blocked by any firewall rules (or security group settings in case of AWS)
    • From the host machine where your docker’ed process has a connectivity issue, use telnet or netcat to check if you can access the target machine and port.
     nc -vz dbhost 9042
    • Once you verify that you can access the port of the service you want to access, from the host machine where your docker process is failing, and still the problem persists, do these steps-
    • Verify the IP address of the problem container –
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' your-container-name-or-id
    172.32.15.36
    • If the IP address so obtained is found to be conflicting with the IP addresses of your network, provide a new sub-net for the the docker containers within the host as below-
      • vim /etc/docker/daemon.js
      • Add the following lines with the subnet address of your preference
    {
    "bip": "10.0.0.1/16"
    }
    • Restart docker service and start your containers.
    • Check your connectivity issue is solved.
    • If your application still cannot connect to your target service, lets reset docker by deleting the docker inventories and restarting it-
    sudo service docker stop

    sudo rm -rf /var/lib/docker

    sudo service docker start

    #init your swarm if needed
    docker swarm init

    pull your images

    start your containers
    • The above steps usually fixes the faulty bridge network created previously by deleting and recreating it.

  • Make a new disk available in Ubuntu on AWS or Azure

    To make a new disk you just added to the Ubuntu device, please go through the following steps –

    Check whats the /dev path of the disk. On terminal, run-

    lsblk
    
    NAME        MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    loop0         7:0    0  97M  1 loop /snap/core/9289
    loop1         7:1    0  18M  1 loop /snap/amazon-ssm-agent/1566
    nvme0n1     259:0    0   1T  0 disk 
    nvme1n1     259:1    0  10G  0 disk 
    

    You would have got a result as above. ( In Azure the disk names are the usual sda, sdb etc, unlike the nvme* in AWS.)

    In this case, the disk I wanted add is the 1 TB disk, which is /dev/nvme0n1

    Format the disk with a new compatible filesystem (XFS).

    sudo mkfs -t xfs /dev/nvme0n1

    Wait for the file-system creation to finish.

    sudo mkdir /data
    sudo mount /dev/nvme0n1 /data
    sudo cp /etc/fstab /etc/fstab.orig
    sudo blkid
    

    From the output of the last command, find the UUID of your disk

    sudo vim /etc/fstab

    Append the line –

    UUID=[your disk's UUID]  /data  xfs  defaults,nofail  0  2

    Note that in the above replace your disk’s UUID without the square brackets, and save the file.

    sudo umount /data
    sudo mount -a
    df -h

    Verify that /data is listed as a disk in the last command. If not, please check the /etc/fstab file, apply correction of UUID, spaces etc, and repeat the above test block again.

  • host-name getting reset after a reboot

    Problem:

    The newly set hostname reverts back to older one after reboot

    Reason :

    Hostname is reset by cloud-init

    Solution :

    Inactivate cloud-init.

    On terminal, key in –

    [bash] hostnamectl set-hostname YourNewHostName sudo touch /etc/cloud/cloud-init.disabled sudo reboot [/bash]