Resolution
https://access.redhat.com/discussions/917293
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum -y install redhat-lsb libXScrnSaver
yum -y localinstall google-chrome-stable_current_x86_64.rpm
Master Linux, Cloud, and DevOps in one place. This blog provides expert DevOps best practices, Linux administration tips, and cloud infrastructure insights for IT professionals and engineers. Learn how to automate tasks, streamline deployments, and optimize AWS, Azure, and GCP environments using tools like Docker, Kubernetes, Terraform, and Ansible. Perfect for anyone building, scaling, or securing cloud-native systems.
https://access.redhat.com/discussions/917293
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum -y install redhat-lsb libXScrnSaver
yum -y localinstall google-chrome-stable_current_x86_64.rpm
I want to monitor OS metrics and performance counters of my Amazon Elastic Compute Cloud (EC2) Linux instance. How can I do this using Amazon CloudWatch?
You can create a custom CloudWatch metric for your EC2 Linux instance statistics by creating a script through the AWS Command Line Interface (AWS CLI). Then, you can monitor that metric by pushing it to CloudWatch.
Before proceeding, be sure that you install and configure the AWS CLI for use with the instance that you want to monitor.
Create a custom CloudWatch metric
To create your custom metric:
Log in to the instance through the AWS CLI.
Copy the following bash script, and then save it to your instance (for example, mem.sh).
This example script shows the values that you can publish in CloudWatch. In this example, the put-metric-data API call is used to push the following values to CloudWatch:
========Sample script======
#!/bin/bash
USEDMEMORY=$(free -m | awk 'NR==2{printf "%.2f\t", $3*100/$2 }')
TCP_CONN=$(netstat -an | wc -l)
TCP_CONN_PORT_80=$(netstat -an | grep 80 | wc -l)
USERS=$(uptime |awk '{ print $6 }')
IO_WAIT=$(iostat | awk 'NR==4 {print $5}')
aws cloudwatch put-metric-data --metric-name memory-usage --dimensions Instance=i-0c51f9f1213e63159 --namespace "Custom" --value $USEDMEMORY
aws cloudwatch put-metric-data --metric-name Tcp_connections --dimensions Instance=i-0c51f9f1213e63159 --namespace "Custom" --value $TCP_CONN
aws cloudwatch put-metric-data --metric-name TCP_connection_on_port_80 --dimensions Instance=i-0c51f9f1213e63159 --namespace "Custom" --value $TCP_CONN_PORT_80
aws cloudwatch put-metric-data --metric-name No_of_users --dimensions Instance=i-0c51f9f1213e63159 --namespace "Custom" --value $USERS
aws cloudwatch put-metric-data --metric-name IO_WAIT --dimensions Instance=i-0c51f9f1213e63159 --namespace "Custom" --value $IO_WAIT
===============================================
$ chmod +x mem.sh
Push your metric to CloudWatch
$ crontab -e
*/1 * * * * /home/ec2-user/mem.sh
When the crontab is saved, crontab: installing new crontab appears.
Monitor your EC2 instance
Find your custom metric in the CloudWatch console:
Open the CloudWatch console.
Choose Metrics.
Choose the All Metrics tab.
Choose Custom.
Choose the dimension Instance.
Select your custom metric by its InstanceId and Metric Name.
View the graph of your metric.
Other uses
You can use this example to build your own logic to process multiple dimensions, and then push that metric data to CloudWatch.
For example, suppose that you benchmark your application. Then, you discover that when the I/O wait time and percentage memory usage reach a certain threshold, the system stops functioning properly. To address this problem, you can monitor both values simultaneously in a script. Store the logical AND of the values in a third variable that you push to CloudWatch.
c=0
if [[ $IO_WAIT > 70 && $USEDMEMORY > 80 ]]
then
c=1
fi
aws cloudwatch put-metric-data --metric-name danger --dimensions Instance=i-0c51f9f1213e63159 --namespace "Custom" --value $c
For normal conditions, this variable is 0 (zero). For situations when both conditions are met, the value is set to 1 (one). You can then build custom alarms around these parameters to warn of problematic situations for your system.
sudo yum install -y
[https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm](https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm)
sudo systemctl status amazon-ssm-agent (to chk status)
sudo systemctl enable amazon-ssm-agent (to enable ssm )
#!/bin/bash
PASSWORD="XXXXXXXXX"
RDS_ENDPOINT=XXXXXXXXXXXXXXXXX
PORT=5432
DUMPNAME=dev-api-db-psql-dump.sql
USER=postgres
DBNAME=dev_aes_database
TARFILENAME=dev-api-db-psql-dump-"$(date +"%d-%m-%Y--%H-%M")".sql.tar
S3_PATH=XXXXXXX
LOCALPATH=/opt/aes-np-api-db-psql-dump
LocalFile=dev-api-db-psql-dump*
cd $LOCALPATHPGPASSWORD=$PASSWORD pg_dump -h $RDS_ENDPOINT -p $PORT -f $DUMPNAME -U $USER $DBNAME
# Command to create DB dump from psql database
tar -czf $TARFILENAME $DUMPNAME
# This will create zipped tar file from DB dump
rm -rf $DUMPNAME
# This will remove dump file from server i.e. from /opt/aes-np-api-db-psql-dump
aws s3 mv $LOCALPATH/$LocalFile $S3_PATH
# copying local tar file to s3 bucket
cd /etc/systemd/system
sudo vi fusion.service
[Unit]
Description=AES fusion Application
Requires=network-online.target
After=network-online.target
[Service]
Type=simple
User=opsadminuser
ExecStart=/bin/sh -c '/opt/lucidworks/fusion/4.2.1/bin/fusion start > /opt/lucidworks/fusion/4.2.1/var/log/app-start.log 2>&1'
RemainAfterExit=yes
ExecStop=/bin/sh -c '/opt/lucidworks/fusion/4.2.1/bin/fusion stop > /opt/lucidworks/fusion/4.2.1/var/log/app-stop.log 2>&1'
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo chmod 755 fusion.service
sudo systemctl daemon-reload
sudo systemctl enable fusion.service
Step 1:
Create a START.sh
/usr/bin/java -jar -Dspring.profiles.active=dev
-Dlog.file=/opt/java/aes_logs/aes_logs
/opt/java/iot/dtc-services-boot-smartfactory-0.0.1-SNAPSHOT-exec.jar
--spring.config.name=application -Xms2G -Xmx4G -XX:+UseG1GC
-XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5
-XX:InitiatingHeapOccupancyPercent=70 -XX:-UseGCOverheadLimit
Step 2:
Go to /etc/systemd/system
Step 3:
then after create a example.service file
EXAMPLE 1:
[Unit]
Description=Smart Factory Application
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simple
User=opsadminuser
ExecStart=/bin/sh -c '/opt/java/iot/connector-start.sh > /opt/java/iot/logs/app.log 2>&1'
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
EXAMPLE 2:
[Unit]
Requires=zookeeper.service
After=zookeeper.service
[Service]
Type=simple
User=opsadminuser
ExecStart=/bin/sh -c '/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties > /opt/kafka/logs/kafka.log 2>&1'
ExecStop=/opt/kafka/bin/kafka-server-stop.sh
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/QuickStartEC2Instance.html
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
],
"Resource": [
"arn:aws:logs:*:*:*"
]
}
]
}
https://www.postgresql.org/download/linux/redhat/
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Install the client packages:
yum install postgresql11
Optionally install the server packages:
yum install postgresql11-server
Optionally initialize the database and enable automatic start:
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html#mon-scripts-getstarted
STEP 1:
To install the required packages on Red Hat Enterprise Linux 7
Log on to your instance. For more information, see Connect to Your Linux Instance.
At a command prompt, install packages as follows:
sudo yum install unzip perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA --enablerepo="rhui-REGION-rhel-server-optional" -y
STEP 2:
The following steps show you how to download, uncompress, and configure the CloudWatch Monitoring Scripts on an EC2 Linux instance.
To download, install, and configure the monitoring scripts
At a command prompt, move to a folder where you want to store the monitoring scripts and run the following command to download them:
sudo curl https://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.2.zip -O
Run the following commands to install the monitoring scripts you downloaded:
sudo unzip CloudWatchMonitoringScripts-1.2.2.zip
sudo rm CloudWatchMonitoringScripts-1.2.2.zip
sudo chown -R opsadminuser:opsadminuser aws-scripts-mon/
cd aws-scripts-mon
The package for the monitoring scripts contains the following files:
sudo corntab -e
select user_login_id,user_password from aes_users where user_login_id='XXXXXX';
First download the Oracle Java from Oracle website
https://www.oracle.com/technetwork/java/javase/downloads/index.html
then go to the server and SCP the jdk and installed the JAVA
sudo rpm -ivh jdk-8u211-linux-x64.rpm
sudo find / -name java
cd /usr/java/jdk1.8.0_211-amd64
pwd
vi ~/.bashrc
export JAVA_HOME=/usr/java/jdk1.8.0_211-amd64
source
~/.bashrc
java -version
First go into the server and check for JAVA is installed or not
java -version
rpm -qa | grep java
Then after if JAVA is not installed then install JAVA first
sudo yum search java 1.8
sudo yum install -y java-1.8.0-openjdk-devel
sudo find / -name jvm
cd /usr/lib/jvm
ls
cd java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64
pwd
Please change vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64
export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre
source ~/.bashrc
echo $JAVA_HOME
https://docs.aws.amazon.com/cli/latest/userguide/install-bundle.html
If you don't have sudo permissions or want to install the AWS CLI only for the current user, you can use a modified version of the previous commands.
$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
$ unzip awscli-bundle.zip
$ ./awscli-bundle/install -b ~/bin/aws
This installs the AWS CLI to the default location (~/.local/lib/aws) and creates a symbolic link (symlink) at ~/bin/aws. Make sure that ~/bin is in your PATH environment variable for the symlink to work.
$ echo $PATH | grep ~/bin // See if $PATH contains ~/bin (output will be empty if it doesn't)
$ export PATH=~/bin:$PATH // Add ~/bin to $PATH if necessary
Tip
To ensure that your $PATH settings are retained between sessions, add the export line to your shell profile (~/.profile, ~/.bash_profile, and so on).
The bundled installer doesn't put anything outside of the installation directory except the optional symlink, so uninstalling is as simple as deleting those two items.
$ sudo rm -rf /usr/local/aws'
$ sudo rm /usr/local/bin/aws
Install lvm2 through by YUM
sudo yum install lvm2* -y
//create a PV in machine
sudo pvcreate /dev/xvdb
sudo pvs
//create a VG in machine
sudo vgcreate vg-fusion-01 /dev/xvdb
sudo vgs
sudo vgdisplay
//create a LV in machine
sudo lvcreate -L 199G -n lv-fusion-01 vg-fusion-01
sudo lvs
sudo fdisk -l
sudo lvs
sudo lvdisplay
//create a FILESYSTEM in machine
sudo mkfs.ext4 -j /dev/vg-fusion-01/lv-fusion-01
lsblk
//MOUNT the LV
sudo mkdir -p /opt/lucidworks
//change the PERMISSION of FOLDER
sudo chown -R opsadminuser:opsadminuser lucidworks/
sudo chmod o+x lucidworks/
//Permanent mount
vi /etc/fstab
/dev/vg-solr-01/lv-solr-01 /opt/lucidworks/ ext4 defaults 0 0
Commands
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu
sudo apt-mark hold docker-ce
sudo docker version
DevOps is about people, process and products. To realize the full benefits of DevOps we'll address all three aspects. We'll start with the products aspect of DevOps
DevOps is the union of people, process, and products to enable continuous delivery of value to our end users.
EC2
VPC
ELB/ AutoScaling
EBS, S3,EFS, Glacier
IAM
CloudWatch, CluodTrail, TrustAdvisor
Route53
RDS
— Administrator of other operating system
— Network administrator
— DBAs
— Application Developers
— Site reliability and NOC engineer
— Security Ops
— Storage administrator
— Data Center Technicians
=================== ****** ===================
1) Regularly Monitoring and capturing system log files.
2) Regularly Monitoring and capturing data of server CPU, memory usage
3) Regularly monitoring Filesytems space.
4) Regularly monitoring capturing network usage.
5) Writing automated scripts to handle routine user and sysadmin tasks.
6) Users Management and Support
7) Taking backup of Important file systems.
8) Maintaining documentation for system parameters and disk layout.
9) updating with new technologies
10) Educating and training users and subordinates if applicable.
To configure SSH agent forwarding for Linux
From your local machine, add your private key to the authentication agent.
For Linux, use the following command:
ssh-add -c mykeypair.pem
Connect to your NAT instance using the -A option to enable SSH agent forwarding, for example:
ssh -A ec2-user@54.0.0.123
When Linux OS boot, below are the steps executed:
runlevels
0 - halt (shut down)
1 - single user mode
2 - multiuser mode , without NFS
3 - full multiuser mode
4 - unused
5 - with GUI
6 - reboot
vim /etc/rc.local -- here you can run custom scripts
Detail explanation
Switch ON the system
BIOS: POST and gives control the Boot Device and loads MBR
BIOS -- Basic Input/output system and present at ROM(Read only memory) which is present on chip-set into the motherboard
First role of BIOS is to perform POST -- Power on self test makes sure hardware to system is working fine the hard disk working fine the keyboard the screen could be accessible it can loads
BIOS provides functionality to load screen drivers
BIOS allows interaction with generic hardware.
BIOS allowed you to boot from hard disk, optical drive, USB, network
BIOS hands over to the first sector of the Disk
--> first sector of the hard disk have the information the how to start booting process
--> first sector consists of Master boot record (MBR)
MBR executes the boot Loader
MBR knows how to boot from Hard disk
In case you have multi boot environment to could be having
GRUB and LILO to install on it
LILO -- LINUX Loader
GRUB -- Grand unified boot loader
both of these provides multi boot environment
GRUB Menu LIST
vim /boot/grub/menu.list
ps -ef | grep init
runlevel
ll /etc/rc1.d
vim /etc/inittab -- default runlevel
https://docs.aws.amazon.com/efs/latest/ug/mount-fs-auto-mount-onreboot.html
sudo yum install -y nfs-utils
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-xxxxxxxx.efs.us-east-1.amazonaws.com:/ /home/aesadminuser/doc_repository
Try to give entry in /etc/fstab but when rebooting the server throwing error
mount: unknown filesystem type 'efs'
open /etc/fstab and give the below entry in RHEL 7.x Ver
fs-xxxxxxxx.efs.us-east-1.amazonaws.com:/ /home/aesadminuser/doc_repository nfs4 defaults,_netdev 0 0
It will work