Rezha Julio

Hi!
My name is Rezha Julio
I am a chemist graduate from Bandung Institute of Technology. Currently working as Data Engineer at Traveloka.
You can reach me by email:

contact@rezhajulio.id

, @ Q Q

Powered by Hugo

filter by tags

Remove Entry from Known Host

time to read 1 min | 87 words

Sometimes I am moving my domain from one server to another and facing this problem

Add correct host key in /home/rezha/.ssh/known_hosts to get rid of this message.
Offending key in /home/rezha/.ssh/known_hosts:60
RSA host key for rezhajulio.id has changed and you have requested strict checking.
Host key verification failed.

I am just too lazy to find line 60 of known_host I ended up deleting the entire known_host. Use this command to remove entries from known_hosts:

ssh-keygen -R rezhajulio.id

Change it with your own conflicted hostname or IP address

Installing or Upgrading PostgreSQL 9.4 on Ubuntu 14.04

time to read 1 min | 131 words

I am currently having a side project that requiring JSON Blob feature on PostgreSQL 9.4. But Ubuntu 14.04 only delivering PostgreSQL 9.3 on their repositories. Now I’ll posting step by step how to install or upgrade if you already using PostgreSQL 9.3 on ubuntu 14.04 to PostgreSQL 9.4.

Add PostgreSQL 9.4 repository and Import repository signing key, and update the package lists

sudo echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' > /etc/apt/sources.list.d/pgdg.list

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
  sudo apt-key add -

sudo apt-get update

Install PostgreSQL 9.4 and pgAdmin III

sudo apt-get install postgresql-9.4 pgadmin3

Check current clusters

pg_lsclusters

Stop PostgreSQL 9.4 cluster, drop it, and upgrade PostgreSQL 9.3 cluster to 9.4

sudo pg_dropcluster 9.4 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main

Confirm only 9.4 cluster remains

pg_lsclusters

Fix Locale Settings Error On Ubuntu Server 14.04

time to read 1 min | 127 words

We are just migrating our cloud from Amazon Web Service to SoftLayer, and we feel really happy with performance improvement. But, somehow the new system has error like this.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US:",
	LC_ALL = (unset),
	LC_PAPER = "id_ID.UTF-8",
	LC_ADDRESS = "id_ID.UTF-8",
	LC_MONETARY = "id_ID.UTF-8",
	LC_NUMERIC = "id_ID.UTF-8",
	LC_TELEPHONE = "id_ID.UTF-8",
	LC_IDENTIFICATION = "id_ID.UTF-8",
	LC_MEASUREMENT = "id_ID.UTF-8",
	LC_CTYPE = "en_US.UTF-8",
	LC_TIME = "id_ID.UTF-8",
	LC_NAME = "id_ID.UTF-8",
	LANG = "en_US"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Apparently our OS doesn’t know about en_US.UTF-8, and we can easily fix this just by running this few line of commands

export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
sudo locale-gen
sudo dpkg-reconfigure locales

Installing Varnish with nginx on Ubuntu 14.04

time to read 2 min | 418 words

About Varnish

Varnish is an HTTP accelerator and a useful tool for speeding up a server, especially during a times when there is high traffic to a site. It works by redirecting visitors to static pages whenever possible and only drawing on the server itself if there is a need for an active process.

Installing Varnish

I assume you already have a web working with nginx. On your terminal, run this command one by one

sudo apt-get install apt-transport-https
curl https://repo.varnish-cache.org/ubuntu/GPG-key.txt | apt-key add -
echo "deb https://repo.varnish-cache.org/ubuntu/ trusty varnish-4.0" >> /etc/apt/sources.list.d/varnish-cache.list
sudo apt-get update
sudo apt-get install varnish

This will install the latest varnish 4 to your system. If you don’t add varnish repo, you’ll only get varnish 3 from official ubuntu repo. Just replace trusty with your version of ubuntu if you don’t use 14.04.

Configuring Varnish

Once you have varnish installed, you can start to configure them to ease the load on your virtual private server.

Varnish will serve the content on port 80, while fetching it from nginx which will run on port 8080.

Go ahead and start setting that up by opening the /etc/default/varnish file:

sudo nano /etc/default/varnish

Find the lines under “DAEMON_OPTS”— in the Alternative 2 section, and change the port number by “-a” to 80. The configuration should match the following code:

 DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

Next edit the file located at /etc/varnish/default.vcl. Change to port to from 80 to 8080 like below:

backend default {
    .host = "127.0.0.1";
    .port = "8080";
    .connect_timeout = 60s;
    .first_byte_timeout = 60s;
    .between_bytes_timeout = 60s;
    .max_connections = 800;
}

Because this server run Wordpress and Ghost, I need to tell Varnish to not cache the admin area of wordpress and ghost. Still on /etc/varnish/default.vcl I need to modify sub vcl_recv block into this

sub vcl_recv {
        if (!(req.url ~ "wp-(login|admin)")) {
                unset req.http.cookie;
        }

        if (!(req.url ~ "ghost")) {
                unset req.http.cookie;
        }
}

Now the next step would be to edit the port used by nginx. Each server(it you have it configured that way) would need to be switched from 80 to 8080. The location of my config files are /etc/nginx/sites-available.

Once you have made all of the required changes, restart varnish and nginx.

sudo service nginx restart
sudo service varnish restart

Accessing your domain should instantly take you to the varnish cached version. To test, you can run varnishstat, and that should give you live data as you access the domain affected by varnish.

Disabling Apport Error Reporting on Ubuntu

time to read 2 min | 333 words

What is Apport ?

Apport is an Error Reporting Service provided by Ubuntu to intercept and analyze crashes and bugs as and when they occur. Crashes and Bugs may sound like bad things, but actually most operating systems will have several a day, and it doesn’t mean your computer is broken, nor does it necessarily stop working. As such, Apport can usually be safely disabled, as it doesn’t fix anything, it just tells developers that something went wrong.

Ubuntu 12.04 is the first release of Ubuntu that ships with Apport Error Reporting enabled by default, and as a result, you may get a large quantity of Internal System Error popups inside Ubuntu. Similar popups may also read Sorry, Ubuntu 12.04 has experienced an internal error. These popups are part of Apport, an internal debugger which automatically generate reports to submit for packages that crash. Many reports can’t be filed or have already been filed, and as such it is usually safe to turn off.

Stopping Apport

You can stop the currently running Apport service with the following command.

sudo service apport stop

Note that unless you remove it or disable it at boot it will start again the next time you turn on your computer.

Disable Apport at Boot

You need to manually edit a file to Stop Apport Running at Boot (when you turn on your machine. Open the Terminal, and paste the following command with Ctrl+Shift+V, or type it in manually.

sudo nano /etc/default/apport

Change the line that says enabled=1 to enabled=0 to disable Apport. To re-enable, change it back.

Uninstall Apport

It is fairly simple to uninstall Apport, as you can open the Ubuntu Software Centre, search for apport, and simply click Remove.

A similar process can be used for the package apport in both Synaptic and the Terminal.

sudo apt-get purge apport

Even thought it is safe to uninstall apport, I don’t really recommend it, just in case you want to enable it back, stopping apport is already enough.

PostgreSQL 9.4 failed to start on Manjaro

time to read 1 min | 71 words

After setting up Manjaro on my new working laptop, I installed PostgreSQL 9.4. When I want to start the service by running sudo systemctl start postgresql, postgresql keep failing to start.

Apparently before PostgreSQL can function correctly on Arch Linux based distro, the database cluster must be initialized by the postgres user. Fix this just by running the following command:

sudo -i -u postgres
initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'

RECENT SERIES

  1. java 101 (13):
    Apr 29, 2017 - Translating Scanner tokens into primitive types
  2. python data structure (5):
    May 03, 2017 - Enhance your tuples
  3. python function (2):
    Apr 16, 2017 - Lambda Functions in Python
  4. python generator (4):
    Apr 26, 2017 - Next, Function or Method ?

Friends of Rezha