Sunday, August 20, 2017

Set local time zone for Ubuntu / Debian

Local time zone is important for many application to work properly. Proper time zone is also very important so that when you type 'date' it will not show your date and time in 'utc' time zone.

Here is the command you need to configure time zone on your Ubuntu / Debian:
dpkg-reconfigure tzdata

Tuesday, July 18, 2017

Setting LOCALE for Ubuntu Server from command line CLI

I was getting this type of messages (warning about locale not being set):

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").


Doing the following commands will set LOCALE settings for your Ubuntu Server so that you will not see those message anymore.

locale-gen "en_US.UTF-8"

The command above will generate locale settings. The output should look like this:

Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete. 


Next you need to pick the right LOCALE and it will reconfigure your server to use that LOCALE.

dpkg-reconfigure locales

The command above will output something like this:

Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.


>> You may also like to set the local time zone at this time, click the list below to see how to set your local time zone:

https://ubuntu-server-how-to-tips-tricks.blogspot.com/2017/08/set-local-time-zone-for-ubuntu-debian.html

Wednesday, April 5, 2017

Extending / increasing LVM partition size quickly and while staying online

This guide will show you how to increase the partition or LVM logical volume space.

This quick method only uses 2 commands in CLI, one to extend the Logical Volume (LV) and the other to extend the file system partition itself.

In my experience... I have been able to execute STEP 3 and STEP 4 without having to unmount my file system or partition. Even my server application which is using the /dev/ssd/ssd_data file system stayed online during this process.

STEP 1 - EXAMINE YOUR VOLUME GROUP (VG) SIZE


vgdisplay

  --- Volume group ---
  VG Name               ssd
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               159.68 GiB
  PE Size               4.00 MiB
  Total PE              40878
  Alloc PE / Size       20480 / 80.00 GiB
  Free  PE / Size       20398 / 79.68 GiB
  VG UUID               5hhU7Y-fllL-OCn1-UMaa-3IO2-FEX1-8a6daw


STEP 2 - EXAMINE YOUR LOGICAL VOLUME GROUP (LV) SIZE


lvdisplay

  --- Logical volume ---
  LV Path                /dev/ssd/ssd_data
  LV Name                ssd_data
  VG Name                ssd
  LV UUID                v9EA2K-lH9F-eKyq-OtUm-f6Lo-KHVH-qglyQc
  LV Write Access        read/write
  LV Creation host, time a31, 2013-11-21 13:32:47 -0600
  LV Status              available
  # open                 1
  LV Size                80.00 GiB
  Current LE             20480
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1


STEP 3 - INCREASING / EXTENDING LOGICAL VOLUME


lvextend -L +20G /dev/ssd/ssd_data


The above lvextend command will add 20GB to the ssd_data, so the new size should be 100GB.


STEP 4 - RESIZING / INCREASING FILE SYSTEM SIZE


resize2fs /dev/ssd/ssd_data


The above resize command will resize (to maximize the size of the file system to its max capacity which is now +20GB to 100GB).



Tuesday, February 7, 2017

Installing ElasticSearch into Ubuntu 16.04 LTS Xenial - easy list of commands

This is an easy to follow how-to and list of commands to install ElasticSearch into Ubuntu 16.04 LTS (xenial) server

Pre-requisites:

apt-get update


Install Java JRE:

apt-get install default-jre


Download & Install Elasticsearch Debian Package (.deb):

cd /usr/local/src

wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.3.3/elasticsearch-2.3.3.deb

dpkg -i elasticsearch-2.3.3.deb


Enable Elasticsearch Service (to be able to autostart)

systemctl enable elasticsearch.service



DONE - How to use your new ElasticSearch server

Edit configuration file:

nano /etc/elasticsearch/elasticsearch.yml

Default LOG file location:

/var/log/elasticsearch

Default DATA location:

/var/lib/elasticsearch


To Start ElasticSearch:

systemctl start elasticsearch

To Stop ElasticSearch:

systemctl stop elasticsearch

To Check Status of ElasticSearch:

systemctl status elasticsearch

List of commands to install MongoDB 3.2 to Ubuntu 16.04 LTS Xenial

Here are a list of commands that I have executed to install MongoDB into Ubuntu 16.04 LTS Xenial server.


Pre-requisites:


apt install software-properties-common

apt-get update




Add MongoDB repository:


apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
apt-get update




Install MongoDB Server Files:


apt-get install -y mongodb-org


Setup start-up script:


nano /etc/systemd/system/mongodb.service

Insert the following lines of content:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Enable start-up script:


systemctl enable mongodb


DONE - how to use your new MongoDB:

Configuration file is located here:
/etc/mongodb.conf

To Start service:
systemctl start mongodb

To Stop service:
systemctl stop mongodb

To Check Status of service:
systemctl status mongodb



MongoDB will start automatically on your next server boot process.


Enjoy! -  if you experience any issue - pls leave me a comment. Thanks

Tuesday, August 23, 2016

Set timezone from command line (CLI) - Easiest and Quickest way for Ubuntu

To set your Ubuntu system to your local timezone:

dpkg-reconfigure tzdata

You will see the following screens - just follow and answers the questions.
You will be done in about 30 seconds :-)






Let me know anybody find a simpler way than this. Thanks

Sunday, June 28, 2015

How to listen on 2 or more ports for SSH daemon

SSH daemon (open SSH) can easily be configured to listen on 2 or more / multiple ports simultaneously.

To do so all you have to do is add another Port #### line in the configuration file.

For example:

Usually you will have something like this in your sshd_config file:

Port 22

Lets say you want to "also" listen on port 8822, so you should add:

Port 8822

the end result, you will have two lines of Port #### which will look like this:

Port 22
Port 8822

I have added as many as 3 ports, I am not sure what is the limit of how many ports you can listen to for SSH simultaneously.

Then you simply need to restart the SSH daemon by executing:

service ssh restart

or 

/etc/init.d/ssh restart


How to check to make sure it is working?

The easiest is just to try out if the new port is working. :-)

but you can also execute this statement in command line:

netstat -nap | grep ssh

You should see something like this:

tcp        0      0 0.0.0.0:58251           0.0.0.0:*               LISTEN      7977/sshd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7977/sshd
tcp6       0      0 :::58251                :::*                    LISTEN      7977/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      7977/sshd

The above output shows that server is listening for SSH on port 22 and 58251.