db Archives - The Linux GURUS https://thelinuxgurus.com/tag/db/ Learn Linux & DevOPS from THE LINUX GURUS Mon, 14 Dec 2020 15:42:45 +0000 en-US hourly 1 https://i0.wp.com/thelinuxgurus.com/wp-content/uploads/2020/01/cropped-thelinuxgurus_transparent_name.png?fit=32%2C32&ssl=1 db Archives - The Linux GURUS https://thelinuxgurus.com/tag/db/ 32 32 148921671 Install Redis on CentOS / RHEL https://thelinuxgurus.com/install-redis-on-centos-rhel/ https://thelinuxgurus.com/install-redis-on-centos-rhel/#respond Mon, 14 Dec 2020 15:42:45 +0000 https://thelinuxgurus.com/?p=1268 Redis is an open-source in-memory key-value data structure store that can be used as a cache server, message broker, etc. We can use a number...

The post Install Redis on CentOS / RHEL appeared first on The Linux GURUS.

]]>
Redis is an open-source in-memory key-value data structure store that can be used as a cache server, message broker, etc. We can use a number of data types with redis like strings, lists, maps, sets, sorted sets, HyperLogs, bitmaps, streams, and spatial indexes.

It also provides a number of features like,

  • Replication
  • data persistence
  • LRU eviction
  • High availability using sentinel
  • Publish / Subscribe support for data
  • Keys with limited TTL
  • Automatic Failover
  • LUA scripting, etc

Recommended Read: Install Redis on Ubuntu

Also Read: How to Host Multiple Websites with Nginx in Linux

So let’s start the process to install Redis on CentOS or RHEL.


Install Redis on CentOS

Redis packages are available on EPEL repository, so we are required to install the EPEL repository on our CentOS/ RHEL system first. Install it with the following command,

# yum install epel-release

Once the epel repository has been installed, we can install redis with the following command,

# yum install redis

Start service using the following command,

# systemctl start redis


Another method to install Redis on CentOS

With this method, we can install the latest version of redis or for that matter any version we need. We will installing the latest version at this time, i.e. 6.0.9.. Download the redis package with the following command,

# wget https://download.redis.io/releases/redis-6.0.9.tar.gz

Next extract the redis package,

# tar -xvf  redis-6.0.9.tar.gz

Now goto the extracted folder,

# cd redis-6.0.9

& then goto folder ‘deps’,

$ cd deps

next compile packages, ,

$ make hiredis lua jemalloc linenoise

$ make geohash-int

Next, we will move back to the main directory i.e. ‘redis-6.0.9’

$ cd ../

execute  ‘make’ & ‘make install’ commands

$ make

$ make installation

Once these commands have been executed, we will install the init scripts, init script will setup a redis service with port number, config file, log file & a data directory. To run run init script,

$ cd utils\

& run the install_server.sh script,

$ ./install_server.sh

We will now be asked with some information regarding redis server, as shown below,

Welcome to the redis service installer

This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]

Selecting default: 6379

Please select the redis config file name [/etc/redis/6379.conf]

Selected default – /etc/redis/6379.conf

Please select the redis log file name [/var/log/redis_6379.log]

Selected default – /var/log/redis_6379.log

Please select the data directory for this instance [/var/lib/redis/6379]

Selected default – /var/lib/redis/6379

Please select the redis executable path [/usr/local/bin/redis-server]

Selected config:

Port : 6379

Config file : /etc/redis/6379.conf

Log file : /var/log/redis_6379.log

Data dir : /var/lib/redis/6379

Executable : /usr/local/bin/redis-server

Cli Executable : /usr/local/bin/redis-cli

Is this ok? Then press ENTER to go on or Ctrl-C to abort.

Copied /tmp/6379.conf => /etc/init.d/redis_6379

Installing service…

Successfully added to chkconfig!

Successfully added to runlevels 345!

Starting Redis server…

Installation successful!

Modify any settings as per your requirements & can also install more than one redis instances by just changing the redis port number.

Now to start the redis service, command is a bit different as service name will be different,

# systemctl start redis_6379

So just change the port number to start only a single redis instance.


Testing Redis installation

We can now check if the redis has been installed by running the following command,

$ redis-cli –version

We can also connect to the installed redis server with the following command,

$ redis-cli

then check the response to ping command for redis,

redis > PING

In response, we should get PONG as output.


Allowing remote connections to Redis installation

By default, we can only connect to redis server from the local server. To allow connections to redis installation from remote machines, we need to make changes to redis configuration file,

$ sudo vi /etc/redis/redis.conf

then look for section that says ‘bind 127.0.0.1’ & change it

bind 0.0.0.0 

to allow connections from all remote servers or we can also mention single or multiple IP addresses to allow connections from those servers only, like

bind 10.10.10.10 192.168.1.10

here, connections will be allowed from two machines with IP addresses 10.10.10.10 & from 192.168.1.10.

Once the changes have been made, we need to restart the redis service to apply changes,

$ sudo systemctl restart redis

This completes our tutorial on how to install Redis on CentOS & RHEL. Please do send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Install Redis on CentOS / RHEL appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/install-redis-on-centos-rhel/feed/ 0 1268
Beginner’s guide to Backup Postgres Database https://thelinuxgurus.com/beginners-guide-to-backup-postgres-database/ https://thelinuxgurus.com/beginners-guide-to-backup-postgres-database/#respond Tue, 28 Apr 2020 14:14:22 +0000 https://thelinuxgurus.com/?p=863 Backups are important & they are our only contingency for when we delete things that we should not or there are malfunctions hardware or otherwise....

The post Beginner’s guide to Backup Postgres Database appeared first on The Linux GURUS.

]]>
Backups are important & they are our only contingency for when we delete things that we should not or there are malfunctions hardware or otherwise. Backups at regular intervals are essential for any organization to maintain a proper working environment. Same goes for database, database backups are extremely essential as it holds transactional, user data among other things.

In this tutorial, we will learn about PostgreSQL backup. Before we start this, you can also refer to our tutorials on installing Postgresql on CentOS/RHEL, also for installation on Ubuntu & installing Postgresql from the source.

Recommended Read: Important postgresql commands for beginners


Backup Postgres Database


Postgresql provides backup utilities when we install postgresql on the server, they are pg_dump & pg_dumpall. Pg_dump is most useful for taking postgresql backup of a single database, while pg_dumpall provides the postgresql backup for all databases on the server. Let’s see some examples.

Backup Postgres database, single DB

Start by switching to the user postgres,

# su – postgres

Now to back up a database, use the following command,

$ pg_dump -U user_name -d thelinuxgurus > thelinuxgurus.bak

Here, ‘thelinuxgurus’ is the name of the database we need to backup. We can also use .sql or .tar as extension to backup file.


Taking backup of one or more tables in postgres

Command to take the backup of a single table from a database is,

$ pg_dump -U User_name -d database_name -t public.users_table > users_table.bak

To take the backup of more tables,

$ pg_dump -U User_name -d database_name -t public.users_table public.test_table public.test_table_2 > 3_tables.bak


Restoring a database

Now if we need to restore the backup, we need to drop the old database & create an empty database,

$ dropdb thelinuxgurus

$ createdb new_db

Not to restore the backup, use the following command,

$ psql new_db < thelinuxgurus.bak

Or we can also use pg_restore utility to restore a database, use the following command to restore the database using pg_restore utility,

$ pg_restore -d db_name /path/to/your/file/thelinuxgurus.bak -c -U db_user


Restore one or more tables from backup

Similarly, we can also restore the backup of one or more tables,

$ pg_restore -U user_name –data-only -d target-db-name -t table_name /path/to/your/file/users_table.bak


Taking only schema backup

To take the backup of schema only, use the following command,

$ pg_dump –schema=schema_name db_name > schema.bak


Restoring schema backup

To restore schema backup, use the following command,

$ psql -d db_name -U user_name < schema.bak


Taking all database backup

The second backup utility i.e. pg_dumpall is used for taking backup of all the databases on postgreSQL. To take backup use the following command,

$ pg_dumpall > all_databases.bak


Restore all databases backup

To restore all database backup, use the following command,

$ psql -f all_databases.bak postgres

We can also use all or any of the above-mentioned commands & create a cron job for it to automate our backups. Please refer to our tutorial on Scheduling Cron jobs on Linux system. We now end this tutorial on backup Postgres database. Please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Beginner’s guide to Backup Postgres Database appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/beginners-guide-to-backup-postgres-database/feed/ 0 863
Install ROBO3T on Ubuntu (Install RoboMongo) https://thelinuxgurus.com/install-robo3t-on-ubuntu/ https://thelinuxgurus.com/install-robo3t-on-ubuntu/#comments Sun, 23 Feb 2020 05:12:08 +0000 https://thelinuxgurus.com/?p=1125 Robo 3T or Robomongo as it was called formerly, is a free, lightweight GUI MongoDB management tool. It provides GUI tools for managing & querying...

The post Install ROBO3T on Ubuntu (Install RoboMongo) appeared first on The Linux GURUS.

]]>
Robo 3T or Robomongo as it was called formerly, is a free, lightweight GUI MongoDB management tool. It provides GUI tools for managing & querying the MongoDB database. It embeds the actual mongo shell that allows for CLI as well as GUI access to the database.

Recommended Read: Simple guide to install MongoDB on Ubuntu 18.04

 Also Read: Complete guide to Install Django on Ubuntu

In this tutorial, we will learn to install Robo3T on Ubuntu (or we can also say install RoboMongo), we will be installing the latest version of ROBO 3T i.e. 1.3 which has support for MongoDB 4, an upgraded mongo shell, support for importing from MongoDB SRV connection strings, etc. So let’s start with the process to install Robo3t on Ubuntu servers.

Install Robo3T on Ubuntu

We are assuming that you have MongoDB installed on your system. If you still have not installed MongoDB, please refer to our tutorials for installing MongoDB on Ubuntu & CentOS. Now back to Robo 3T installation, we will be discussing two methods for the installation of Robo 3T,

1- Install using SNAP

2- Install using Official Packages


1- Install Robo3T using SNAP

Snap package manager is available by default on Ubuntu 16.04 & above, if it’s not installed on your system then you can install it using the tutorial HERE. Once the snap is installed, we can install Robo 3T on Ubuntu with the following command,

$ sudo snap install robo3t-snap

Once installed you can run it either from the menu or using the following command from the terminal,

$ robo3t


2- Install Robo3T using Official packages

Firstly, we need to download the Robo 3T, use the following command to download the latest packages,

$ wget https://download-test.robomongo.org/linux/robo3t-1.3.1-linux-x86_64-7419c406.tar.gz

You can create a folder for robo 3t,

$ mkdir -p /data/robo3t

Next, extract the files from tar to that folder,

$ tar -xvzf robo3t-1.3.1-linux-x86_64-7419c406.tar.gz -C /data/robo3t

Now go to the extracted folder,

$ cd /data/robot3t

Once in the folder, we can start the robot 3t with the following command,

$ ./robot3t

Robo 3T will now start & will keep running until the script is stopped or the session is closed. You can also start the script in background in the following command,

$ nohup ./robot3t &

That concludes our tutorial on how to install Robo3T on Ubuntu (install RoboMongo). Please do let us know if you have any questions, queries or suggestions using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Install ROBO3T on Ubuntu (Install RoboMongo) appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/install-robo3t-on-ubuntu/feed/ 4 1125