Wednesday, June 30, 2021

How To get Aws DB Snapshots list from aws cli and scripting

 #!/bin/bash

aws  rds --output text describe-db-snapshots --db-instance-identifier databaseName --query 'DBSnapshots[*].[DBInstanceIdentifier, AllocatedStorage, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' >  databaseName.csv

# single comand for snapshots
aws ec2 describe-snapshots --output text --query 'Snapshots[*]
 [Description,Encrypted,OwnerId,Progress,SnapshotId,StartTime,State,VolumeId,VolumeSize,OwnerAlias]' >  b.txt


# snapshots get by snapshot-type (manual)
 aws  rds --output text describe-db-snapshots --snapshot-type manual  --db-instance-identifier database-1 --query 'DBSnapshots[*].[DBInstanceIdentifier, AllocatedStorage, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' > a2.csv

#aws  rds --output text describe-db-snapshots --query 'DBSnapshots[*].[DBInstanceIdentifier, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' > a.csv

#aws  rds --output text describe-db-snapshots --snapshot-type manual  --db-instance-identifier database-1 --query 'DBSnapshots[*].[DBInstanceIdentifier, AllocatedStorage, AvailabilityZone, SnapshotType, InstanceCreateTime, VpcId]' > a2.csv

# aws  rds describe-db-snapshots --db-instance-identifier database-1--snapshot-type manual | jq '[.DBSnapshots[] | {Snapshot_Identifier:.DBSnapshotIdentifier,Creationtime:.SnapshotCreateTime}]'

Thursday, June 10, 2021

Installation of Tomcat 9 on Ubuntu 18

 Java installation in Ubuntu  18.....

  

  # sudo apt install openjdk-8-jdk

  # java -version

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Create Tomcat User

# sudo groupadd tomcat

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

# sudo apt update

Dawnload Package of Tomcat 9

# cd /tmp

#  sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.21/bin/apache-tomcat-9.0.21.tar.gz

# sudo mkdir /opt/tomcat

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

#  ll /opt/tomcat/

#  sudo chown -R tomcat: tomcat

#  sudo chmod o+x /opt/tomcat/bin/

Update Permissions

   #  cd /opt/tomcat


Give the tomcat group ownership over the entire installation directory:

    #  sudo chgrp -R tomcat /opt/tomcat

Give the tomcat group read access to the conf directory and all of its contents, and execute access to the directory itself:  

    #  sudo chmod -R g+r conf

    #  sudo chmod g+x conf

 

 Make the tomcat user the owner of the webapps, work, temp, and logs directories:

    # sudo chown -R tomcat webapps/ work/ temp/ logs/


Create a systemd Service File

    # sudo update-java-alternatives -l

!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

[Unit]

Description=Apache Tomcat Web Application Container

After=network.target


[Service]

Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid

Environment=CATALINA_HOME=/opt/tomcat

Environment=CATALINA_BASE=/opt/tomcat

Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'

Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'


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

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


User=tomcat

Group=tomcat

UMask=0007

RestartSec=10

Restart=always

[Install]

WantedBy=multi-user.target

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# sudo systemctl daemon-reload

# sudo systemctl start tomcat

# sudo systemctl status tomcat

Add Port on Firewall

# sudo ufw allow 8080

# http://server_domain_or_IP:8080

How to give privilege for access of single aws bucket ..

 {     "Version": "2012-10-17",     "Statement": [         {             "Effect": "Allow"...