Friday, April 16, 2021

Kubernetes

class notes

 

 apiVersion: v1
kind: Pod
metadata:
  labels:
    test: readiness
  name: readiness-exec
spec:
  containers:
  - name: readiness
    image: k9s.gcr.io/busybox
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy, sleep 30; rm -rf /tmp/healthy; sleep 600
    readinessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
periodSeconds: 5

kc apply -f exec_readiness_probe.yaml
kc get pods
kc describe readiness-exec



spec:
  containers:
  - name: goproxy
    image: k8s.gcr.io/goproxy:0.1
    ports:
    - containerPort: 8080
    readinessProbe:
      tcpSocket:
        port: 8080
      initialDelaySeconds: 5
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy, sleep 30; rm -rf /tmp/healthy; sleep 600
    readinessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
periodSeconds: 5

kc apply -f exec_readiness_probe.yaml
kc get pods
kc describe readiness-exec



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

when to use
if your login page coming, jenkins is ready,
if you want to test every features, they put they strategy or file, or check stable, security implementation, scema then u use limeness ...









Thursday, April 15, 2021

Day39 - Kubernetes - jobs, cronjobs, etcd

 Kubernetes 04/14/2021
Todays topic:- jobs, cronjob, etcd

Jobs
----
Launch your minikube
> minukube start

Container is equal to process

image -> launch -> container -> process
life of a container is a life of process
process killed, container is killed.

When you launch a container, the life of conainer is infinite.
unless you delete it. Any pod we launch is a server - webserver.
- These server never stop.
- They keep on running
- If they fail, by default we have policy - always policy
   There are multiple policies and always is one of them.

restart policy on POD.

batch processing


> kc get job

deployment also launch pod and if they stop, they start automatically.
if job completed, they don't relaunch.

we want some job run on some interval.

We can get it schdule it using crontjob
> kc get cronjob

if you have a work, to run particular job say batch job, kubernetes has a resource: job, crontab



# echo $SHELL
bash

lets take a look on a simple eg,
$ for i in 1 2 3 4 5 6 ; do echo $i; done


Lets create a deployment
> kc create deploy myd --image=centos:7 -o yaml >j.yaml


[root@master ~]# kc create deploy myd --image=centos:7 -o yaml >j.yaml
[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: myd
  name: myd
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myd
  template:
    metadata:
      labels:
        app: myd
    spec:
      containers:
      - image: centos:7
        imagePullPolicy: IfNotPresent
        name: centos
         #- "/bin/bash"
         - "/bin/sh"
         - "-c"
         - "for i in 1 2 3 4 5 6; do echo $i; done"
      restartPolicy: Always #(or Never)
 
[root@master ~]#

> kc apply j.yaml
> kc get pods



[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: myd
  name: myd
  namespace: default
spec:
  completitions: 6
  replicas: 3
  selector:
    matchLabels:
      app: myd
  template:
    metadata:
      labels:
        app: myd
    spec:
      containers:
      - image: centos:7
        imagePullPolicy: IfNotPresent
        name: centos
         #- "/bin/bash"
         - "/bin/sh"
         - "-c"
         - "for i in 1 2 3 4 5 6; do echo $i; done"
      restartPolicy: Always #(or Never)
 
[root@master ~]#


[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Job
metadata:
  labels:
    app: myd
  name: myd
  namespace: default
spec:
  completitions: 6
  parallellism: 2
  replicas: 3
  selector:
    matchLabels:
      app: myd
  template:
    metadata:
      labels:
        app: myd
    spec:
      containers:
      - image: centos:7
        name: centos
        command: [ "expr", "2", "+", "4" ]
      restartPolicy: Always #(or Never)
 
[root@master ~]#
> kc apply j.yaml

> kc get po
> kc delete job --all

cronjob

[root@master ~]# cat j.yaml
apiVersion: apps/v1
kind: Cronjob
metadata:
  labels:
    app: myd
  name: myd
  namespace: default
spec:
  schedule: "*/2 * * * *"    # every 2 min
  jobTemplate:
   spec:
    completitions: 6    # 6 total
    parallellism: 2    # 2 in parallel
    replicas: 3
    selector:
      matchLabels:
        app: myd
    template:
      metadata:
        labels:
          app: myd
      spec:
        containers:
        - image: centos:7
          name: centos
          command: [ "expr", "2", "+", "4" ]
        restartPolicy: Always #(or Never)
 
[root@master ~]#


>kc deletete job --all
> kc apply -f j.yaml
> ck get pods








Sunday, April 11, 2021

Day 38 - AWS - CloudWatch log / SNS / Alerm / Metrics

AWS - Cloudwatch Log - 4-11-2021
Class note

Today's topic
Cloudwatch/SNS/Alarm/Metrics

you have multiple servers running.
why problem happened, to analyze certain issue, or to find some metrix, we use logs
user log, system boot log or any other log are used to analyze the logs

Logs are stored on local systems and collected on central logging system (log server) or remove log server.

Web server, database server, app server generate logs, other network or system device also generate log

plain of glass of view is created to view the log

one of the popular tool is splunk.

we will be discussing Cloudwatch


Go to aws console and create an ec2 instance.
- create web server
- Log Location: /var/log/httpd/access.log
- We will push this log to cloud watch.

check amazon linux -> 1 instance tag name: web1
allow all traffic -> create key and launch.

we will send the log to cloud
- log server is configured in such a way to push log to log server.
- We will install agent program which collect the log from local system is send it to log server.
- Cloud watch can collect from different sources such as system, network device or other cloud provider ssytems.


Now, login to your instance
- Configure apache web server

# yum httpd -y install
# systemctl start httpd

# cd /var/www/html
# cat >index.html
welcome
# cat >hello.html
Test page

Log location
# cd /var/log/httpd
There is not log here, when user is connected, log will be recorded.

go to browser and connect
come back and check the files
access_log
error_log

check real time log
# tail -f access_log
# tail -f error_log

try some page that does not exists

htto://myip/testbest.html

go to error log and check, you will see this incident is recorded.

Now, lets go to cloud watch
- Alarm
- Logs
- Metrics

go to logs -> loggroups
create log group
name: weblg
retention setting: 1 months (after 1 month, date will be removed so plan accordingly)
or select never expires

click on create to create log group

Now, you have to reate Log stream
click on log group and create log stream
log stream : web

note: they will chagrge you for this service

You have to install agent on the EC2 install

since we are using amazon linux and yum is configured
for other platform search for cloud agent software
# yum install awslogs

Config location

# cd /etc/awslogs
# vi swscli.conf

[plugins]
cwlogs =cwlogs
[default]
region = us-west-1        # what region you want to send log to

Configure another file

cloud watch you might have multiple group, thats why you have to specify

# vi awslogs.conf

review the example..

logsteam_name
log_group_name

we have out log name as weblog
log_stream_name = webls


log_steam_name = {instance_id}
but we change
log_stream_name = webls


data in the log is time series data.

# cat /var/log/httpd/access_log

review the log file format

review the fileawslogs.conf for log format and other stuffs
$ cat awslogs.conf
[webblockname]
datetime_format = %b %d %H:%M:%S
file = /var/log/httpd/access_log
bufer_duration = 5000
log_steam_name = webls
initial_position = start_of_file
log_group_name =webls

Start your log service
# systemctl restart awslogs
# systemctl enable awslogs

go to cloudwatch -> group -> log steam

log is yet not here.

go back to agent side and check

now, lets troubleshoot by checking the log
# cd /var/log
# more awslogs.log
you see the file content.
you see error, unable to locate credentials

we know ec2 is one service and cloud watch is different service.

Now, we have to create a role which can allow ec2 instance to write to cloudwatch.
We have to attach the poslicy to the role.

Go to AWS dash board
IAM -> click on Role:
click on Ec2 next permission

filter, serch for cloudwatchlogs
There is a policy cloudwatchLogsFullAccess

Rolename ec2-cwlog

[action, modify role ]

now attach to policy to role.

Restart logs
# systemctl restart awslogsd
# cat acess_log
we didn't see any errors related to access.

This message mean, it is working. No, error is see
To confirm go to Logs -> Log Groups -> Log streams
reresh
- webls
click on webls
you can see all the logs here.
whatever you wirte on this page, exactly file will be avilable.

Entire log is here. This is what we want.

now, our log is centralize.
Go to log groups
-> action -> export data to Amazons3 to keep log for longer time.

Athena and Glue can be using to analyze.

lets do it.
click on export
send it to s3.

choose s3 bucket
steam prefix: mylogweb

export


it failed.

int: permission since cloudwatch or permission issue.


cloudwatch -> metrics -> alarm

Now, go to cloudwatch -> cloudwatch logs

optn your instance and go to monitoring,
- you will see CPU, status ccheck fail,
- Disk read/write, network info and more..

cloud watch monitors these all

Monitoring (Metrics)
- CPU
- N/W
- Block


go to cloud watch and click on Metrics on left side

select your region
you will see what they are monitoring.

Click on all metrics
you will see matrics services
EBs
EC2

click on ec2
they mornitor on instance basis

check uner metric name


what is status check - 2/2
- system check
- instance check

before they provide you any service
- they check hardware and instance.
once both are good, they provide you the instance.

when hardware is down/failed,


go to cloud watch -> metrics ->

cloud watch check cpu, mem or other informaiton.

create an alarm if used % is more than 80%

go to alarm -> set the billing alarm

SNS -> simple notification service

you attach to cloudwatch to send notification


cloud watch -> metric - creat graph
go to action
add to dashboard to check everyday.

give name to your dahsborad: mydashboard
customize the widget title

select metrics
select ec2 ->
metric name
select disk and other what you want to monitor.

create widget

Note: Dash board is seen from any region but the logs,metrics are only regin specific



Plan"
service (Cloud Watch)    ---------> SNS -------> send email to -----------> Gamil
You have to subscribe to receive the email. That way, sns can send notification.


1. Create sns service
- goto aws dashboard
- click on topics
  there is another option sunbscription
- create topic
  -  FIFO (first in first out)
  - standard - select standard

email :
click on create

now, click on subscribe
click on subscription
protocol: email
end point: your gmail vimal.linuxworld@gmail.com
Click on create

you see status: pending
now, go to topic -> you see who subscribe

Now, go to your email and approve the subacription

oprn the link and confirm.

go back to your SNS page and refresh, now its been subscribe.

click on topic -> sunbscriptions
this program will send notification to all subscriber.

Makesure you are on right region

- create alarm -> set the matrics
- selecct ec2 -> matrics
networkpackaetout

you can set up kwwp on checking on every 1 minutes interval,
statics - Average

write a condition
trafffic more than 600 threshold value, trigger the alerm.

click next
configure actions
- select in alarm
- select an sns topic
- select exisitng sns topics


click on send notification to : select an email list



in summary
cloudwatch -> alarm-> create alarm
- specify metrics and conditions
- configure actions
- add name and description
- preview and create








goto cloud watch
-> Click on Alarm -> create alarm
name: myalarmforwebform

go and try to access your page couple of time,
an alerm is generated in cloudwatch.

go to cloudwatch -> alarms -> myalarmfowebforNet


custom metrics
--------------------
create your own metrics

something happened, create an alerm
when somevalue = value say 500, create

clickon logs -> log group
-> on log groups
-> metrics filter

on the tio you see create metrics filter

go to metrics
-> click on metric filter
on test pattern
- select every message under (websp)


go to logs -> log groups

weblg-> create metrics
metrics name: myns

select what you want to
name: mycustommetricfor403


1. Metric create
2. Create an alemr
go to log group -> click on log group -> click on create alerm


athena also has capibility to get log from cloud  watch as well.

go to athena - select different ddata source
connect to data source

->


#






Saturday, April 10, 2021

Day37 - AWS - Athena, Glue, Cloudwatch

 AWS - session 37

Class Notes
Today's topic
- Athena
- Glue Data Catalogue
- Cloudwatch logs

these two services are related to S3 (prefix-partition - improves the performance)


Go to aws console and search
- cloudwatch
- glue
- athena

Read about these services

AWS advance program
- Data analitics (athena and glue are discussed)
- These services are part of big-data.

Lets discuss what Athena and Glue do for us.

We have different dept in our organization
- Research
- Technical
- Development
- Support

They have their own data. Every day they generate lots of data. These are recorded on log file
We have web server, customer access it through.webserver.


log file can be as follow format

1    1.1.1.1        index.html    200
2    2.2.2.2        web.php        400


lets look at one of the Dataset
1,John, ok
2,Bill,goog
3,Jack,good

These data does not have metadata are called rawdata.
These data are hugh data, thats why called bigdata which are
use for analysis for future

Datalake - stores big data files. it stores all raw data which we use for analytics.

Lets say, lets find user who has 404 errror, or user who successfully login to the system and much more ..

Hadoop, which has distrubited filesystem (hdfs) through you access data lakes.
- its an open source tool, use our storage to configure it.
- or use aws, look for service that allow you to store and use it on aws.
Sice of the storage is going to be Petabyte

use some program/tool to access datalake to generate report.

AWS provides these kinds of sitauttion to handle.
s3 is an object storage which provides storage service.
- it is scalable. You can add your data
- Read/wrote/throughput and very fast on s3.

you can use hdfs or s3

bigstoreage is called datalake

if you data in a file in storage, you run a program on top of ram and process runs, reads the data, loads into memory and execute.
But our data is terabyte of data and its hard to load into memory.

But our program goes to s3, analyze the data and returns the result.
The tool we will be using is Athena.
- It is meant for analytics or analysis tool.
- And highly tied with s3.
- For anthena, S3 is data source.
- Athena can access data form other sources as well.

s3 is datalake
- data in raw format

1,John,100,ok
2,Bill,200,goog
3,Jack,500,good

Looking at the data above, we don't know what these data mean.

you also need metadata to know what this data about such as
serial no.
name
salary
remarks

s/n,name,salary,remarks
1,John,100,ok
2,Bill,200,goog
3,Jack,500,good

without metadata, its very hard to find out what the raw data really mean.
Once you have metadata, you can figure it out what this data really mean.

to analyze the rawdata, you first create metadata and attach to raw data.

so, first create metadata also called schema and attach metadata to s3 (data source), on rawdata.

The name of the service is glue
- glue is an ETL tool.
- glue has a service catalogue which helps you to create metadata.


Athena is similar to HIVE
S3 is similar to HDFS
schema (metadata) is similar to HIVE metastore

You have to set up HDFS, HIVE, HIVE metastore by yourself but
Athena, S3, Glue is already configured for you on aws.


splunk is alternate to Athena.
but splunk comes with more feature.

now, lets do the practial

we have a raw data. lets same as
> notepad athena3.csv
1,John,100,ok
2,Bill,200,goog
3,Jack,500,good

So, whats the plan
- First go to s3 (Bucket)and upload this file
  you upload this raw data

Go to aws console
bucket name: awsAthena
select the region (Singapore)
create a bucket

upload the file

s3 -> key=filename

if you want to access file from your laptop -> you initaite a get request

to get speed to download this file is very fast.


max speed you get file from bucket is 6000 files/sec
filesize=?

lets say you have 60,000/sec request per second, what happens?
how to improve the performance.

in s3, you have fastest storage service
which provides 6K/sec but how to get more access time.

you can create different bucket say
- region basis
- day basis (1, 15, 25, chrimas)
   /mybucket/day1
        /day2/f1
        /day3/f2
        /day15/d15
        /day25/d24
This way, we distribute the load. Every folders has different speed. say you have 10 folders and each has 6K so you will get 60,000/sec
This way you can access your required speed.
More partition, folder you create, speed increases.
- day1, day2, day3 .. these are called prefix
- There is no limit of prefix
- You can have more prefix to speed up.
- hardware perspective, reached the limit but this way, you can organize the data.
- Storage, speed up the performance with partition.

Lets go to s2 bucker and create a folers
- create folder  name: april
- create another folers: name: May

each folder has their own speed.
so in total we have 12k/sec speed.

Now, lets go ahead and upload to april folder.

use default option and upload the file.

Now, we have to create metadata

we have to go to Athena and glue

go to console and search for Athena

lets select the region: singapore
-click on get started
on the left side, you see: datasource
our datasource is s3
click on connect data source next to data source on the left side

Two options are available
- query data in aws s3
- query a data source -> select this one

and review
but we will select s3

choose a metadata catalog
- aws glue data catalog
- apache Hive metastore

Select glue

-----------------
now, open a new tab and search for glue.
you see data catalog
review different options
------------------------------

connect to data source
connect to AWS glue data catalog
second option


Tools ------SQL-------> data Source

add table
1. name and location
database: lwdb (its like a folder)
table name: emptable
location of input data set:

now go to your Athena and go to april and get the url
s3.awsathena../april
filename: athena3.cvs

- copy the address and next
2. Data format: csv

click next
2. Column:
what is the first field
cloumn: id
column type: int
column: name
salary , type, init

add column to add more data.
remarks - straing ..
id, name, string,.......
......................
id: int
name: string
salary: int
remarks: string

once you created column, click next and you will be at parititon

click next
you get errro to specify the location to store.
to resolve to go thena and click on the link provided.
when you click on the link, you will be on Athena bicket
create a folder for result. Output

Go to Athena and select the folder called output.

now, go back to graphic page and click next.
we created a schema table.


====================
go to to glue and refresh, you will see your database
click on database, you will see table
and when you click on table, you see detail about schema.

look at teh data location: it is pointed to s3.

you can edit schema, add more fields and more.



go to athena and create a new query
read all the column,row and display data.
select * from emptable;

you will see the result
You see nice display for data.

for big size data, do not run this type of query, it simplay may hangs.

Display sum of the salary
select SUM(salary) from emptable


Lets data is terrabype
only result goes to athena.


select * from emptable where name='jack';


selct remanrks from emptable where name='jack';

orderby
join
innerjoin ... much more..


================================
Cloud watch log
--------------------
You have one instance ec2: webserver
another instance on virtual box: DB server

both these system generate logs

client come and try to access the data.

matrics: mem,io,cup,throput

Logs are stored on your local disks.

if you have 100s of servers, and accessing is a chellange.
so, we create a centralize logging server where all the logs will be sync with

we use cloudwatch log which is a centralized log system.

Go to aws console and search for cloudwatch
- it is used for multiple purpose
- go to logs on left
- this service is used for monitoring, alayzing and sotring logs
- highly scallable, durable and much more.
- Log management tool.

logs are actually created on local storage and upload to cloudwatch.

we have tools for centralize loggin: rsyslog, datadog,splunk

cloudwatch has its own agent
- agent will collect logs from local system on behalv of cloudwatch and uploads to cloud watch.
- on centralized location, we use Athena or other tool to analyze.

You can install cloud agents on your own PC, VM as well.



Demo: tomorrow








Wednesday, April 7, 2021

श्रीमद्भगवत गीताका मन छुने भनाईहरु

श्रीमद्भगवत गीताका मन छुने भनाईहरु, जसले हाम्रो सोच्ने शैली बदल्छ

श्रीमद्भगवत गीता पूर्विय दर्शनको सर्वश्रेष्ठ ग्रन्थ मानिन्छ । यसले मान्छेलाई सही दिशा मार्गदर्शन गर्छ र गलत बाटोमा हिँड्नबाट बचाउँछ ।

यसमा जुन उपदेश छ, त्यो भगवान श्रीकृष्णले स्वयम् कुरुक्षेत्रको युद्धका क्रममा अर्जुनलाई बताएका थिए । जब महाभारतको युद्ध सुरु हुँदै थियो, अर्जुन युद्ध गर्न चाहिरहेका थिएनन् । तब भगवान श्री कृष्णले अर्जुनलाई धर्म र कर्मको सच्चा ज्ञान अवगत गराए ।

–जे भयो, राम्रो भयो । जे हुँदैछ त्यो राम्रो हुँदैछ । जे हुनेछ, त्यो पनि राम्रो हुनेछ ।

–तिमीले के गुमायौं, जसको लागि तिमी रोइरहेका छौं ? तिमीले के लिएको थियौं र के गुमायौं ? तिमीले के कुरा पैदा गरेको थियौं जुन नष्ट भयो । तिमीले जे लिएका थियौं यहीबाट लियौं । जे दियौं, यहीका लागि दियौं ।

–जुन कुरा आज तिम्रो त्यो भोलि अरु कसैको हुनेछ । किनभने परिवर्तन नै संसारको नियम हो ।

–जीवन न भविष्यमा छ, न अतितमा । जीवन त वस् यही पलमा छ ।

–जन्म लिएपछि मृत्यु निश्चित छ । जति पनि जन्मन्छन्, ति सबै मर्छन् । यसैले जुन कुरा अपरिहार्य छ, त्यसमा शोक गर्नु जरुरी छैन ।

–कुनैपनि व्यक्ति आफुले चाहे अनुसार बन्न सक्छ, यदि त्यो व्यक्ति एक विश्वासका साथ इच्छित वस्तमाथि लगातार चिन्तन र कर्म गरिरहन्छन् भने ।

–मान्छे विश्वासले निर्माण हुन्छ । उनीहरुले जे विश्वास गर्छन्, त्यही बन्छन् ।

–कर्म गर, फलप्रति आशक्ति नराख ।

–हे अर्जुन, क्रोधले भ्रम पैदा हुन्छ । भ्रमले बुद्धि व्यग्र हुन्छ । जब बुद्धि व्यग्र हुन्छ, तबत र्क नष्ट हुन्छ । जब तर्क नष्ट हुन्छ, तब व्यक्तिको पतन सुरु हुन्छ ।

–तेरो र मेरो छाड । आफ्नो र पराय छाड । तब सबैकुरा तिम्रो हुनेछ र तिमी सबैको हुनेछौं ।

–सधै सन्देह गरिरहने मान्छेको लागि सुख न यो लोकमा छ, न परलोकमा ।

–नर्कको तीन द्वार छन्, वासना, क्रोध र लोभ ।

–मन अशान्त छ यसलाई नियन्त्रण गर्न कठिन छ, तर अभ्यासद्वारा मनलाई आफ्नो वसमा राख्न सकिन्छ ।

–जुन व्यक्तिले सबै इच्छा त्याग गर्छ । म र मेरो भन्ने लोभ एवं भावनाबाट मुक्त हुन्छन् । उसलाई अपार शान्ति प्राप्त हुन्छ ।

–धर्तीमा जसरी मौसम बद्लिन्छ, उसैगरी जीवनमा सुख र दुख पनि आउने जाने भइरहन्छ ।

–इतिहास भन्छ हिजो सुख थियो । विज्ञान भन्छ, भोलि सुख हुनेछ । तर, अध्यात्म भन्छ, यदि मन सफा र स्वच्छ भने हरक्षण सुख छ ।

–जस्तो व्यवहार अरुले गर्दा तपाईंलाई रुचीकर लाग्दैन, त्यस्तो व्यवहार तपाईंले पनि अरुको लागि गर्नु उचित हुँदैन ।

–केवल मान्छेको मन नै कसैको सत्रु वा मित्र हुन्छ ।

-न यो शरीर तिम्रो हो । न तिमी यो शरीरका हौ । यो शरीर त पञ्च तत्वले बनेको छ, आगो, जल, वायु, पृथ्वी र आकास । एक दिन यो शरीर यही पञ्चतत्वमा विलिन हुन्छ ।

– कुनैपनि व्यक्ति जन्मले होइन, कर्मले महान बन्छन् ।

-संसार आवश्यक्ताको नियम अनुसार चल्छ । जाडो याममा जसरी घामको न्यानो महत्वपूर्ण हुन्छ, गर्मी याममा त्यही घामको तिरस्कार हुन्छ । तपाईंको मूल्य त्यसबेलासम्म कायम रहन्छ, जबसम्म तपाईंको आवश्यक्ता हुन्छ ।

Saturday, April 3, 2021

AWS - Storage - Storage types, S3 types

Today's topic: AWS - Storage , storage types, S3 types, IOPS


EBS, S3, Lifecycle


Program  ----> Checks  DB (NoSQL)  --->  Storage

For better performance, you need to have all of these components faster
For faster Data access
- Ram (fast)
- CPU (fast)
- Storage (slow - bottle neck) - impact the performance

How can you make storage perform well, or increase the speed of the storage?

Lets say you have a storage say s1

S1 -> I/O
how are you managing it?
- How are you designing the storae.
How are you arranging/organzing/managind the data is important.

Lets say you have a fileA, with 1GB in size.

Do you read entire 1Gb at a time or just read the part of the content?
say complete data also called DataSet, and program comes and read all or part of it for analysis?
or its a huge file say terrabyte. how fast you can retrieve from the storage does matter.

do you have older types of harddisk - magnoc one, which has platters sector and sector which contains 512 byte.
this is a physical sector.
but now a days, os program say lvm, they read/write 8 sector at a time (8x5=8 byte = 1 block)

if writing is continous block, then reading is faster since the header on harddisk directly can access. if the blocks are sphread across, then its hard to access faster.

But its not possible to get continous block allocation if the file size on say GB or TB big.

What can you do in this kind of situation?

we talk about throughput, speed of read/write is called throughput.

In case of AWS,
AWS -> Storage -> Block device -> EBS
google for aws optimized volume
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html
review the document.

Lets go to AWS console
- create a linux system nad login
# fdisk -l
review teh output from first disk.
lets create a folder
# mkdir mydir; cd mydir
# ls -l     # review the total
# create a file
# vi myfile.txt
welcome to the clus

=> Now, you see the number 4.

this 4 means, its a 4 block of data is allocated and can be saved.

# get conf -a | less

# blockdev
getsize - get the blocksize os is provided.
# blockdev -h

Go to EBS, create a volume

change volume Type and review the IOPS

Review the Volume Type ST, SC (Cold HDD),

Letss pick

type: sc1
size -> review the range
throughtput (MB) ->

magnetic type or platter based harddisk has header which has to read each block for read or write.
so, we need header where it can read randomly from multiple location.
we want optimized disk or optimized type of disk, these are now available as SSD disk.

how do we calculate the speed of these type of disks?

IOP/s -> Input Output operation per second.

for bigger file, we need different type of hard disk
continouse read

lets say for eg,
1Gb ->  3 IOPS

higher size storage, higher the speed.

GP - general purpose (gp2)
3 IOPS per GB.
3000 IOPS- 1000 GB

Volume Type: Proviisoned IOPS SSD

look at the proce how much you will be paying when you selecting the hard disk

review all Volume Types:
 

GP2 normal and nost costly  thats why by default boot disk is gp2.
100/3000 IOPS

Bustable ->

time
iops

baseline  - We get 300 IOPS

 

 
got to volume and click on any volume and go to monitoring, you can see how much bustable, available,
- you can also see in cloudwatch.

 
now, there is something similar, s3
- permanent storage, we used to store object.
- every object is independent.

Lets talk about storage as a whole.

lets say you are a bank and want to store data or information about customer.
- Lets say whole day activities are copied to one file  called apr3.csv and saved on S3 bucket in bank
- next day say apr4.csv also saved on s3.
- We keep storing data this way every day.
- Every week there is an audit/analysis
  so we go to bucket, use the tool to read and generate report
- the major concern is how fast you can retrieve and acess, process and generate report.



There are different types of storage type
- you have to select what type of storage type you want.

we have a storage type
1. Standard (host-storage) - super fast  - expensive    say price is $100
2. Standard IA -> In frequest access type   prive is $70

what is the difference?
its the IPOS. If you storeage on standard, its faster compared to standard IA.


Go to s3 and create a bucket

bucketname: mybucket

upload  a file,
click on upload -> go down the page, you see storage class
- depleding on the type of data access, you can select the different options.

1. standard (fastest - frequent accessed data) - higher in price
2. Standard-IA - Infrequest Access (cold storage) - IF

in S3, we always select the region. this is ehrer your file is going to storage.
But by default it wil stored on all AZs, and if some disaster happens, data will be available from different AZs.

for standard and standard-IA, data will be available on all AZs on that region.


3. One Zone - AZ - availale on only one zone.
lets say we have a database, and we have a copy of database (IA)
and another copy atone-zone-IA.
so in case one zone-IA fails, we will still have data available on another az.

copying backup to different onezone helps you to work on or to access later date.

it will save a lots of money.

google: price for s3


in case of banking data, there might be provision to retrive data 7 years old data.
these data rarely retrieved. it moght be access once in 7 years or not at all.
so, we can use the slowest one.


Note: filename is key

Glacier: one type of s3 service
- cheapest storage
- Retrive data from 1 min to 12 hrs

Glacier Deep Archive
- takes 12 hours to retrive the data.

Intellegetn - tiering

S3 glacier
-> create a vault
Name:

vault is created.

there is not option to upload the file.
You have to use different tool.

its been merge to bucket.

go to bucket and upload on file
- here you can open fast.

on glacier, there is not option to download. the object in glacier, you want to download, you have to first send initiation request and restore it.
You see three type of retirival tier
- bukl etrival (5-10 hrs)
- standar retrival (3-5 hrs)
- expedited retirval (1-5 min)

and there is fee for tetrival fee.

to use, select expedited retrival, and restore ->  you have to specifed how many days you want to restore: specify 1 days


google for storage classes :

give you very interesting table with differences.

check availabity, durability is same but check the retival fee.

You can move data from on s3 type to different s3 types

s3 is used for bigdata.


 

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...