Thursday 20 October 2016

Adding IP aliases in FreeBSD - Freebsd ifconfig add Remove Alias IPv4 / IPv6 / inet6

FreeBSD Assign IPv4 address
: # ifconfig em0 inet 192.168.10.5 netmask 255.255.255.0
FreeBSD ifconfig add alias for IPv4
: # ifconfig em0 inet 192.168.10.10/24 add
FreeBSD ifconfig remove alias for IPv4
: # ifconfig em0 inet 192.168.10.10/24 -alias
For IPv6
FreeBSD Enable IPv6 functionality of the interface:
: # ifconfig em0 inet6 -ifdisabled
FreeBSD Add the IPv6 address 2001:DB8:DBDB::123/48 to the interface em0:
: # ifconfig em0 inet6 2001:db8:bdbd::123 prefixlen 48 alias
FreeBSD ifconfig remove/delete Alias for IPv6 inet6
: # ifconfig em0 inet6 2001:db8:bdbd::123/48 delete

Monday 22 August 2016

PostgreSQL setval Sequence - PostgreSQL manually alter sequence - Reset sequence of setval in PostgreSQL - Ali Raza Bhayani


In one of the my PostgreSQL tables, I used a very handy builtin Sequence Manipulation function setval() of PostgreSQL to generate Primary Keys in a sequential and controlled manner. But during a migration, I wanted to identify new records by Primary Key sequence greater than thousand. A very handy and tested recipe to restart the setval() function sequence for such cases is by using RESTART WITH in the following way:
ALTER SEQUENCE sequence_name RESTART WITH 1000;
is equivalent to:
    SELECT setval('sequence_name', 1000, FALSE);
Either of the statements may be used to restart the sequence and you can get the next value by:
    nextval('sequence_name')
The above recipe can also be used to reset PostgreSQL primary key sequence when it falls out of sync.

PostgreSQL setval Sequence - PostgreSQL manually alter sequence - Reset sequence of setval in PostgreSQL - Ali Raza Bhayani


In one of the my PostgreSQL tables, I used a very handy builtin Sequence Manipulation function setval() of PostgreSQL to generate Primary Keys in a sequential and controlled manner. But during a migration, I wanted to identify new records by Primary Key sequence greater than thousand. A very handy and tested recipe to restart the setval() function sequence for such cases is by using RESTART WITH in the following way:
ALTER SEQUENCE seq RESTART WITH 1000;
is equivalent to:
    SELECT setval('sequence_name', 1, FALSE);
Either of the above statements may be used to restart the sequence and for getting the next value following statement can be used:
    nextval('sequence_name')
The above recipe can also be used to reset PostgreSQL primary key sequence when it falls out of sync.

Wednesday 29 June 2016

Install and run Redis on Mac OS - Redis Server Installation and First Run

Following is the recipe to install Redis server on Mac OS using homebrew in a very simple manner:

 $ brew install redis


After installation, you may edit Redis configuration file by going to the path via Mac OS terminal:

$ /usr/local/etc/redis.conf

To start Redis Server using configuration file on Mac OS, use following command:
$ redis-server /usr/local/etc/redis.conf

After running the Redis Server on Mac OS, you can check whether Redis Server is running by opening a new terminal window and enter following command:
$ redis-cli ping

Install and run Redis on Mac OS - Redis Server Installation and First Run

Following is the recipe to install Redis server on Mac OS using homebrew in a very simple manner:

 $ brew install redis


After installation, you may edit Redis configuration file by going to the path via Mac OS terminal:

$ /usr/local/etc/redis.conf

To start Redis Server using configuration file on Mac OS, use following command:
$ redis-server /usr/local/etc/redis.conf

After running the Redis Server on Mac OS, you can check whether Redis Server is running by opening a new terminal window and enter following command:
$ redis-cli ping

The server should reply PONG which means that the server is pinging.