Monday, June 28, 2021

Install tomcat 8 on Ubuntu 18.04

 1. install jdk 8 or open jdk 8

2. create tomcat user account

sudo groupadd tomcat


3. run below command

sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat




4. move to tmp folder

5. run the below command to download tomcat tar file

wget ftp://apache.cs.utah.edu/apache.org/tomcat/tomcat-8/v8.5.68/bin/apache-tomcat-8.5.68.tar.gz
 

 

6. create folder on /opt/tomcat

cd /opt/

sudo mkdir /opt/tomcat
 

 

7. run below command - to extract tar file to /opt/tomcat

cd /tmp/

sudo tar xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
 

 8.tomcat extract to below folder
 

 

9.give the tomcat user control of the entire directory and make all the scripts in the bin location executable

 

sudo chown -R tomcat: /opt/tomcat
sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh'
 

 

 10.run below command

sudo vi /opt/tomcat/conf/tomcat-users.xml

add the below lines

11. add below line to 

sudo vi /etc/systemd/system/tomcat.service

==============================

[Unit]
Description=Tomcat servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/default-java"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
 
12. After that, run the commands below to reload systemd profiles and enable tomcat service
sudo systemctl daemon-reload 
--- not working below two line ---------- 
sudo systemctl start tomcat.service
sudo systemctl enable tomcat.service
 
13. run the tomcat using the below commands
sudo -s
cd /opt/tomcat/bin/ 
./startup.sh 
  

14. on the web browser run below command

http://localhost:8080




Thursday, June 24, 2021

create Elastic Search Database backup


1.Make a zip from elasticsearch folder by executing, `tar -czvf backup.tar.gz elasticsearch`

 =========


Existing database table values display as follows.



2. Stop elastic search db

3. rename it's db data folder to different name


4. extract previously taken db backup using below command

tar -xvf backup.tar.gz
 

 5. Now you can see the extract elasticsearch data folder as follows

 6.start elastic search db using below command
sudo service elasticsearch start
7. recheck the data using the postman

 



Wednesday, June 23, 2021

Uninstall MySQL On Ubuntu OS

 1. open Terminal and execute below command

sudo systemctl stop mysql

this command will stop mysql service

2. Next run below command

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

3.Below command will remove MySQL configuration and data.

sudo rm -rf /etc/mysql /var/lib/mysql

 


4.

(Optional) Remove unnecessary packages.

sudo apt autoremove

(Optional) Remove apt cache.

sudo apt autoclean


MySQL Database DB Bakup from Ubuntu OS

MySQL DB back can be taken as below Terminal command

 

sudo mysqldump -p mailhub >/home/pasindu/a.sql




restore mysql DB using the below command


mysql -u username -p database_name < backup_name.sql

 

Below commands are used to stop mysql service

sudo service mysql stop

or 

sudo systemctl stop mysql
 

Below command is used to start mysql service

sudo service mysql start
 

Create mysql user for MySQL database

 Create new mysql user 

CREATE USER 'sunny'@'localhost' IDENTIFIED BY 'sunny';


GRANT ALL PRIVILEGES ON *.* TO 'sunny'@'localhost' WITH GRANT OPTION;


This user has all privileges

username : sunny

password: sunny

Install MySQL on Ubuntu 18.04

 Install mysql database on the Ubuntu OS.

1. open terminal

 execute below command

sudo apt-get update
2. sudo apt-get install mysql-server

3.sudo systemctl status mysql - check status of mysql db

4.sudo mysql_secure_installation
It's asking for Root new password
5.For all the other asking questions  enter 'y'
 

 
6.Next enter mysql -u root -p
Then it's ask for password
After that It's giving below error message.
7.
 Then enter sudo mysql command


8. After that enter below sql query

SELECT user,authentication_string,plugin,host FROM mysql.user;

you can see output as follows


then I change Root password as follows.

 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '257F257f';



9.then press below sql query.

FLUSH PRIVILEGES;

10. next see below sql query.

SELECT user,authentication_string,plugin,host FROM mysql.user;


Now output will be as follows.

You can see in this example output that the root MySQL user now authenticates using a password. Once you confirm this on your own server,
you can exit from mysql shell using exit command.
Next login to my sql you have to do following command
 
mysql -u root -p
 



Sunday, June 20, 2021

Elastic Search Database

 Elastic Search database is no-sql database.

Below are the comparison with Elastic Search Database items with Relation Database Item.


create index using below command line


If below http://localhost:9200/_cat/indices  on brower contains yellow one,you have to run below command

curl -XPUT 'http://localhost:9200/_settings' -H 'Content-Type: application/json' -d '
{
    "index" : {
        "number_of_replicas" : 0
    }
}'



Tuesday, June 15, 2021

setup nginx Server reverse proxy on Windows 10

 Nginx is famous server to do a reverse proxy.

 Here I am setting up how to setup Nginx