How to Install Redis on Linux Debian 9?

How to Install Redis on Linux Debian 9?

Redis is an Open Source NoSQL database. It is very popular, capable and remarkably fast In-Memory database. It stores the data in key-value pair and no doubtfully says it is a NoSQL database.

Installing Redis on Linux Debian 9, is very simple and follow the steps given below one by one to install the Redis on Linux Debian 9.

update all existing packages

Before Installing Redis, update all existing packages on the Linux Debian 9 by executing the below command.

sudo apt update
sudo apt-get update

install redis server

Install Redis Server by executing the below command on the Linux Debian 9.

sudo apt-get install redis-server

Redis will start installing on the Linux Debian 9 automatically and also starts the Redis service.

configure systemd process

There is an important configuration needs to be update after installing the Redis server. Open the Redis configuration file by using below command.

sudo vi /etc/redis/redis.conf

Find the word “supervised” and change the default value from “no” to “systemd” to manage and monitor the Redis service.

supervised process of Redis service

allow connections from anywhere

By Default, Redis is binding to localhost. Execute the below steps to allow the connections from anywhere to access the Redis. Open the Redis configuration file by using below command.

sudo vi /etc/redis/redis.conf

Find the word bind 127.0.0.1 and make sure it is un-commented out (remove the # if it exists)

binding to localhost

configure redis password

Follow the below steps to configure the Redis password. Open the Redis configuration file by using below command.

sudo vi /etc/redis/redis.conf

Find the word “requirepass” and set the secure password to access the Redis and make sure it is un-commented out (remove the # if it exists)

Require pass for Redis

Then, Restart the Redis service now by executing the below command.

sudo systemctl restart redis 

redis client

Execute the below command on the terminal to connect the Redis server by using Redis client.

redis-cli

The Redis client terminal will open on the same console and we can start execute the Redis commands.

set authentication on the redis client

Since we have secured the password, we should set the Authentication on the Redis client before start executing the Redis commands. Use the below command to set the password on the Redis client to access the Redis server.

auth foobared
Authentication on the Redis client

ping pong command

To check the connection between Redis server and client execute the following command on the Redis client terminal.

PING

If you get the acknowledgement, “PONG” on the console, then the connection between the server and client is stable.

ping and pong with Redis client

Execute the below Redis commands on the Redis client to store the data as Key-Pair value on the Redis server.

set employee John

get employee
set and get Redis key pair data

monitor and manage the redis service

By executing below commands, we can monitor and manage the Redis service on the Linux Debian 9.

To view the current status of the Redis service.

sudo systemctl status redis

To stop the Redis service.

sudo systemctl stop redis

To start the Redis service after it got stopped.

sudo systemctl start redis 

If any Redis configuration got update, we should restart the Redis service. Execute the below command to restart the Redis service.

sudo systemctl restart redis 

By default Redis service will start when the system starts. To disable that execute the below command.

sudo systemctl disable redis

Execute the below commands to enable the Redis service once again after it got disabled.

sudo systemctl enable redis-server.service
Advertisements

How to install MySQL on Linux Debian 9?

How to install MySQL on Linux Debian 9?

MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by Oracle Corporation. MySQL is a database management system. MySQL databases are relational. MySQL software is Open Source. The MySQL Database Server is very fast, reliable, scalable, and easy to use. MySQL Server works in client/server or embedded systems. A large amount of contributed MySQL software is available. – by dev.mysql.com

MySQL is a very famous and popular open source relational database management system. Installing MySQL on Linux Debian 9 is very easy and straight forward. This blog will help you the step by step procedure to install the MySQL on Linux Debian 9.

change directory

Execute the below command to change the directory to “/tmp”.

cd /tmp

download MySQL PPA

The MySQL PPA for Debian Linux is available on the MySQL official site. Execute the below commands to download the MySQL PPA.

sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config* 

During the installation of MySQL apt config package will prompt you to select the MySQL version to install. Select the MySQL 5.8 or 5.7 option to install on your system.

MySQL server & cluster
MySQL version

Select “OK” on package confirmation screen.

OK screen

Install MySQL

Update the existing packages once again and start to install the MySQL by executing the below commands.

sudo apt update 
sudo apt install mysql-server

Enter the root password to login into the MySQL as a root user.

Enter root password

Re-enter root password once again.

Re-enter root password

Select “Strong Password Encryption” on the screen for safe.

Strong Password Encryption

check the system control status

By executing the below command to check the MySQL running status on system control.

sudo systemctl status mysql
MySQL system control status

secure mysql

By executing the below command to secure your MySQL.

mysql_secure_installation

You should answer the questions prompted on the screen to secure your MySQL installation.

Would you like to setup VALIDATE PASSWORD component?
 Press y|Y for Yes, any other key for No: n
 Using existing password for root.
 Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
 … skipping.
 By default, a MySQL installation has an anonymous user,
 allowing anyone to log into MySQL without having to have
 a user account created for them. This is intended only for
 testing, and to make the installation go a bit smoother.
 You should remove them before moving into a production
 environment.
 Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
 Success.
 Normally, root should only be allowed to connect from
 'localhost'. This ensures that someone cannot guess at
 the root password from the network.
 Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
 Success.
 By default, MySQL comes with a database named 'test' that
 anyone can access. This is also intended only for testing,
 and should be removed before moving into a production
 environment.
 Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
 … skipping.
 Reloading the privilege tables will ensure that all changes
 made so far will take effect immediately.
 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
 Success.
 All done! 

test mysql

Execute below command to test the MySQL and check the version.

mysqladmin -u root -p version
MySQL version

MySQL has been successfully installed on Linux Debian 9.

How to install Apache Ant on Linux Debian 9?

How to install Apache Ant on Linux Debian 9?

Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks. – by ant.apache.org

PREREQUISITES

  1. JDK

DOWNLOAD

We can download the Apache Ant from the official site of Apache Ant. The download link has been given below.

https://ant.apache.org/bindownload.cgi

CHANGE DIRECTORY

Execute the following command to change the directory into “/usr/local” in your Linux Debian machine.

cd /usr/local  

WGET

By using WGET command, we can download the latest Apache Ant from the official site. The WGET command is given below.

sudo wget https://www-eu.apache.org/dist//ant/binaries/apache-ant-1.9.14-bin.tar.gz

EXTRACT THE FILE

By using below commands to extract the downloaded Apache Ant file.

sudo tar xzf apache-ant-1.9.14-bin.tar.gz 
sudo ln -s  apache-ant-1.9.14 apache-ant 

SET ENVIRONMENT VARIABLE

Use the below command to set the environment variable by using vi editor.

sudo vi /etc/profile.d/apache-ant.sh

Add the following lines to set the environment path for Apache Ant.

export ANT_HOME=/usr/local/apache-ant
export PATH=${ANT_HOME}/bin:${PATH}

LOAD THE ENVIRONMENT PATH

To load the environment path, execute the below source command.

source /etc/profile.d/apache-ant.sh 

CHECK ant VERSION

Execute the following command to check the Apache Ant version.

ant -version
Apache Ant version

Apache Ant 1.9.14 has been installed successfully on Linux Debian 9.

How to install Docker on Linux Debian 9?

How to install Docker on Linux Debian 9?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code. – by opensource.com

steps

First, update all existing packages list.

sudo apt update

Install prerequisites packages which supports “apt” use packages over HTTPS.

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Add the GPG Key from the official Docker repository site to your system.

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Add the Docker repository to APT sources.

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable"

Update the packages once again with the Docker packages.

sudo apt update 

Execute the below command to make sure installing the docker from official docker repository instead of default one from your Linux Debian.

apt-cache policy docker-ce

You will get the below message in your console about the Docker.

docker-ce:
   Installed: (none)
   Candidate: 5:19.03.0~3-0~debian-stretch
   Version table:
      5:19.03.0~3-0~debian-stretch 500
         500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
      5:18.09.8~3-0~debian-stretch 500
         500 https://download.docker.com/linux/debian stretch/stable amd64 Packages

Now this is the time to install the Docker. Execute the below command to install Docker in your Linux Debian 9.

sudo apt install docker-ce

After docker installation, check the daemon started and the docker process is enabled to start on boot.

sudo systemctl status docker

You will get the below message on the console and showing that service is started and running.

docker.service - Docker Application Container Engine
    Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    Active: active (running) since Thu 2019-07-25 15:08:26 UTC; 52s ago
      Docs: https://docs.docker.com
  Main PID: 10170 (dockerd)
    CGroup: /system.slice/docker.service
            └─10170 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.843745232Z" level=warning msg="Your kernel does not support swap memory limit"
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.844505558Z" level=warning msg="Your kernel does not support cgroup rt period"
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.845028493Z" level=warning msg="Your kernel does not support cgroup rt runtime"
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.845611976Z" level=info msg="Loading containers: start."
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.922639398Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.958337077Z" level=info msg="Loading containers: done."
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.984441997Z" level=info msg="Docker daemon" commit=aeac9490dc graphdriver(s)=overlay2 version=19.03.0
 Jul 25 15:08:25 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:25.985341692Z" level=info msg="Daemon has completed initialization"
 Jul 25 15:08:26 my-blog-vm systemd[1]: Started Docker Application Container Engine.
 Jul 25 15:08:26 my-blog-vm dockerd[10170]: time="2019-07-25T15:08:26.024181113Z" level=info msg="API listen on /var/run/docker.sock"

Now execute the below commands to run Hello World in docker by login as root user. Otherwise, add the “sudo” before the docker commands.

docker run hello-world

You will get the following output on the console.

Unable to find image 'hello-world:latest' locally
 latest: Pulling from library/hello-world
 1b930d010525: Pull complete 
 Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
 Status: Downloaded newer image for hello-world:latest
 Hello from Docker!
 This message shows that your installation appears to be working correctly.
 To generate this message, Docker took the following steps:
 The Docker client contacted the Docker daemon.
 The Docker daemon pulled the "hello-world" image from the Docker Hub.
 (amd64)
 The Docker daemon created a new container from that image which runs the
 executable that produces the output you are currently reading.
 The Docker daemon streamed that output to the Docker client, which sent it
 to your terminal. 
 To try something more ambitious, you can run an Ubuntu container with:
  $ docker run -it ubuntu bash
 Share images, automate workflows, and more with a free Docker ID:
  https://hub.docker.com/
 For more examples and ideas, visit:
  https://docs.docker.com/get-started/
 …

Execute few more docker commands and play with it.

To view the list of docker running containers.

docker ps

To view the list of docker images.

docker images

Docker has been installed successfully on the Linux Debian 9.

How to install Apache Maven 3.6.1 on Linux Debian 9?

How to install Apache Maven 3.6.1 on Linux Debian 9?

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information. It is a build automation tool and it is used by almost all Java projects. It automatically downloads the libraries and dependencies from the Maven repositories and store it into local machine cache. – by maven.apache.org

PREREQUISITES

  1. JDK

DOWNLOAD

We can download the latest version of Apache Maven from the Maven official site. The Official site link has been given below.

https://maven.apache.org/download.cgi

change directory

Execute the following command to change the directory into “/usr/local” in your Linux Debian machine.

cd /usr/local 

wget

By using wget command we can download the latest Apache maven from the Maven official site. Execute the below command to download the maven.

sudowget http://www-eu.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz 

extract the file

By using below commands to extract the downloaded Maven file.

sudo tar xzf apache-maven-3.6.1-bin.tar.gz
sudo ln -s apache-maven-3.6.1 apache-maven 

set environment variable

Use the below command to set the environment variable by using vi editor.

sudo vi /etc/profile.d/apache-maven.sh

Add the following lines to set the environment path for maven.

export MAVEN_DOWNLOAD_PATH=/usr/local/apache-maven
export PATH=${MAVEN_DOWNLOAD_PATH}/bin:${PATH}

LOAD THE ENVIRONMENT PATH

To load the environment path, execute the below source command.

source /etc/profile.d/apache-maven.sh 

M2_HOME

The mvn script computes M2_HOME automatically. No need to set the M2_HOME environment path. Refer the below stackoverflow.com link to see the answer.

https://stackoverflow.com/questions/26609922/maven-home-mvn-home-or-m2-home

check maven version

Execute the following command to check the Maven version.

mvn -version
mvn version

Apache Maven 3.6.1 has been installed successfully on Linux Debian 9.

How to install Gradle 5.5 in Linux Debian?

How to install Gradle 5.5 in Linux Debian?

Gradle is a open source build automation tool. It is very flexible and we can develop any kind of software. Gradle is an open-source build automation tool focused on flexibility and performance. Gradle build scripts are written using a Groovy or Kotlin DSL. Read about Gradle features to learn what is possible with Gradle. From mobile apps to microservices, from small startups to big enterprises, Gradle helps teams build, automate and deliver better software, faster. -by docs.gradle.org

PREREQUISITES

  1. JDK

DOWNLOAD

We can download the latest Gradle from the Gradle official site. The site link has been given below.

https://gradle.org/releases/

wget

By using “wget” command, we can download the Gradle latest version.

wget https://services.gradle.org/distributions/gradle-5.5.1-bin.zip -P /tmp

unzip the gradle file

sudo unzip -d /opt/gradle /tmp/gradle-*.zip

set environment variable and gradle home

To set the Gradle environment variable and Gradle Home in Debian Linux, we can use nano editor. Execute the following command to set the ENV variables.

sudo nano /etc/profile.d/gradle.sh

Add the following commands in nano editor and save the editor.

export GRADLE_HOME=/opt/gradle/gradle-5.5.1
export PATH=${GRADLE_HOME}/bin:${PATH}

Provide the permission to that gradle.sh file.

sudo chmod +x /etc/profile.d/gradle.sh

load environment variables

To load the Gradle environment variables, execute the following command.

source /etc/profile.d/gradle.sh

gradle version

To check the Gradle version execute the following command.

gradle -version
Gradle version

The Gradle installation on Debian Linux is done.

How to install Zulu Open JDK 12 on Debian GNU/Linux 9 (Stretch)?

How to install Zulu Open JDK 12 on Debian GNU/Linux 9 (Stretch)?

Zulu Enterprise™ is a commercialized build of OpenJDK™ and is certified compatible and compliant with the Java SE specification. The 100% open source Zulu JDK is simple to install and requires no coding changes to your Java application. Installing Zulu Java Development Kit 12 in Debian Linux 9 is really a simple. Here are the step by step procedure to install the Zulu Open JDK in Debian Linux 9 Operating System. – by www.azul.com

download JDK

You can download the Zulu Open JDK .tar file from Azul official site. https://www.azul.com/downloads/zulu-community/

Open the terminal and create a new “jvm” folder under /usr/lib directory.

sudo mkdir /usr/lib/jvm

Then change the directory /usr/lib/jvm.

cd /usr/lib/jvm/
Create a new JVM directory

wget download

Now, download the .tar file JDK by using wget command.

sudo wget https://cdn.azul.com/zulu/bin/zulu12.3.11-ca-jdk12.0.2-linux_x64.tar.gz

After download the file, then extract it.

sudo tar -xvzf zulu12.3.11-ca-jdk12.0.2-linux_x64.tar.gz

set environment and java_home Path

Open the nano editor to set the JAVA Path and JAVA_HOME path by using below command.

sudo nano /etc/environment

Add below lines into your text editor after executing the nano command.

PATH="/usr/lib/jvm/zulu12.3.11-ca-jdk12.0.2-linux_x64/bin"
JAVA_HOME="/usr/lib/jvm/zulu12.3.11-ca-jdk12.0.2-linux_x64"

Then, save the file. Next step is inform to Linux where Java is located in that system.

update alternatives

Execute the following commands to set the Java alternatives in Linux machine.

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/zulu12.3.11-ca-jdk12.0.2-linux_x64/bin/java" 0
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/zulu12.3.11-ca-jdk12.0.2-linux_x64/bin/javac" 0
sudo update-alternatives --set java /usr/lib/jvm/zulu12.3.11-ca-jdk12.0.2-linux_x64/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/zulu12.3.11-ca-jdk12.0.2-linux_x64/bin/javac

To verify the setup execute the following commands and it will print the location of the java and javac path.

update-alternatives --list java 
update-alternatives --list javac 

check java version

Restart the computer or logout and login once again. After that, execute the following command to check the java version.

java -version

You can see the following output in the console window.

openjdk version "12.0.2" 2019-07-16

OpenJDK Runtime Environment Zulu12.3+11-CA (build 12.0.2+3)

OpenJDK 64-Bit Server VM Zulu12.3+11-CA (build 12.0.2+3, mixed mode, sharing)