Monday, September 5, 2022

File format use in Big Data

 

 Advantages of using appropriate file formats:

Faster read

Faster write

Splitable files support

Schema evolution can be supported

Advanced compression can be achieved

Some things to consider when choosing the format are:

The structure of your data: Some formats accept nested data such as JSON, Avro or Parquet and others do not. Even, the ones that do, may not be highly optimized for it. Avro is the most efficient format for nested data, I recommend not to use Parquet nested types because they are very inefficient. Process nested JSON is also very CPU intensive. In general, it is recommended to flat the data when ingesting it.

 

Performance: Some formats such as Avro and Parquet perform better than other such JSON. Even between Avro and Parquet for different use cases one will be better than others. For example, since Parquet is a column-based format, it is great to query your data lake using SQL whereas Avro is better for ETL row level transformation.

 

Easy to read: Consider if you need people to read the data or not. JSON or CSV are text formats and are human readable whereas more performant formats such parquet or Avro are binary.

 

Compression: Some formats offer higher compression rates than others.

 

Schema evolution: Adding or removing fields is far more complicated in a data lake than in a database. Some formats like Avro or Parquet provide some degree of schema evolution which allows you to change the data schema and still query the data. Tools such Delta Lake format provide even better tools to deal with changes in Schemas.

 

Compatibility: JSON or CSV are widely adopted and compatible with almost any tool while more performant options have less integration points

Big Data file formats

 

CSV

CSV files (comma-separated values) are usually used to exchange tabular data between systems using plain text. CSV is a row-based file format, which means that each row of the file is a row in the table. Essentially, CSV contains a header row that contains column names for the data, otherwise, files are considered partially structured. CSV files may not initially contain hierarchical or relational data. Data connections are usually established using multiple CSV files. Foreign keys are stored in columns of one or more files, but connections between these files are not expressed by the format itself. In addition, the CSV format is not fully standardized, and files may use separators other than commas, such as tabs or spaces.

One of the other properties of CSV files is that they are only splitable when it is a raw, uncompressed file or when splitable compression format is used such as bzip2 or lzo (note: lzo needs to be indexed to be splitable).

CSV is good option for compatibility, spreadsheet processing and human readable data. The data must be flat. It is not efficient and cannot handle nested data. There may be issues with the separator which can lead to data quality issues. Use this format for exploratory analysis, POCs or small data sets

 

 

 Advantages

 CSV is human-readable and easy to edit manually;

 CSV provides a simple scheme;

 CSV can be processed by almost all existing applications;

 CSV is easy to implement and parse;

 CSV is compact. For XML, you start a tag and end a tag for each column in each row. In CSV, the column headers are written only once.

 

Disadvantages

 CSV allows you to work with flat data. Complex data structures have to be processed separately from the format;

 No support for column types. No difference between text and numeric columns;

 There is no standard way to present binary data;

 Problems with CSV import (for example, no difference between NULL and quotes);

 Poor support for special characters;

 Lack of a universal standard.

JSON

JSON (JavaScript object notation) data are presented as key-value pairs in a partially structured format. JSON is often compared to XML because it can store data in a hierarchical format. Both formats are user-readable, but JSON documents are typically much smaller than XML. They are therefore more commonly used in network communication, especially with the rise of REST-based web services.

Since much data is already transmitted in JSON format, most web languages initially support JSON. With this huge support, JSON is used to represent data structures, exchange formats for hot data, and cold data warehouses.

Many streaming packages and modules support JSON serialization and deserialization. While the data contained in JSON documents can ultimately be stored in more performance-optimized formats such as Parquet or Avro, they serve as raw data, which is very important for data processing (if necessary).

JSON (JavaScript object notation) data are presented as key-value pairs in a partially structured format. JSON is often compared to XML because it can store data in a hierarchical format. Both formats are user-readable, but JSON documents are typically much smaller than XML. They are therefore more commonly used in network communication, especially with the rise of REST-based web services.

Since much data is already transmitted in JSON format, most web languages initially support JSON. With this huge support, JSON is used to represent data structures, exchange formats for hot data, and cold data warehouses.

Many streaming packages and modules support JSON serialization and deserialization. While the data contained in JSON documents can ultimately be stored in more performance-optimized formats such as Parquet or Avro, they serve as raw data, which is very important for data processing (if necessary)

Advantages

JSON supports hierarchical structures, simplifying the storage of related data in a single document and presenting complex relationships;

 Most languages provide simplified JSON serialization libraries or built-in support for JSON serialization/deserialization;

 JSON supports lists of objects, helping to avoid chaotic list conversion to a relational data model;

 JSON is a widely used file format for NoSQL databases such as MongoDB, Couchbase and Azure Cosmos DB

 Built-in support in most modern tools;

 

Disadvantages

JSON consumes more memory due to repeatable column names;

 Poor support for special characters;

 JSON is not very splitable;

 JSON lacks indexing;

 It is less compact as compared to over binary formats.

Parquet

Parquet: Columnar storage. It has schema support. It works very well with Hive and Spark as a way to store columnar data in deep storage that is queried using SQL. Because it stores data in columns, query engines will only read files that have the selected columns and not the entire data set as opposed to Avro. Use it as a reporting layer

Unlike CSV and JSON, parquet files are binary files that contain metadata about their contents. Therefore, without reading/parsing the contents of the file(s), Spark can simply rely on metadata to determine column names, compression/encoding, data types, and even some basic statistical characteristics. Column metadata for a Parquet file is stored at the end of the file, which allows for fast, single-pass writing.

Parquet is optimized for the paradigm Write Once Read Many (WORM). It writes slowly but reads incredibly quickly, especially when you only access a subset of columns. Parquet is good choice for heavy workloads when reading portions of data. For cases where you need to work with whole rows of data, you should use a format like CSV or AVRO.

 

 

Advantages

Parquet is a columnar format. Only the required columns will be retrieved/read, this reduces disk I/O. The concept is called projection pushdown.

 

The scheme travels with the data, so the data is self-describing;

 

Although it is designed for HDFS, data can be stored on other file systems such as GlusterFs or NFS;

 

Parquet just files, which means it's easy to work, move, backup and replicate them;

 

Built-in support in Spark makes it easy to simply take and save a file in storage;

 

Parquet provides very good compression up to 75% when using even compression formats like snappy;

 

As practice shows, this format is the fastest for read-heavy processes compared to other file formats;

 

Parquet is well suited for data storage solutions where aggregation on a particular column over a huge set of data is required;

 

Parquet can be read and written using the Avro API and Avro Schema (which gives the idea of storing all raw data in the Avro format, but all processed data in parquet);

 

 

 

Disadvantages

 

It also provides predicate pushdown, thus reducing the further cost of transferring data from storage to the processing engine for filtering;

 

 

 

The column-based design makes you think about the schema and data types;

 

 Parquet does not always have built-in support in tools other than Spark;

 

 It does not support data modification (Parquet files are immutable) and scheme evolution. Of course, Spark knows how to combine the schema if you change it over time (you must specify a special option while reading), but you can only change something in an existing file by overwriting it

 

 

 

Avro

 

Avro: Great for storing row data, very efficient. It has a schema and supports evolution. Great integration with Kafka. Supports file splitting. Use it for row level operations or in Kafka. Great to write data, slower to read.

 

Apache Avro was released by the Hadoop working group in 2009. It is a row-based format that has a high degree of splitting. It is also described as a data serialization system similar to Java Serialization. The schema is stored in JSON format, while the data is stored in binary format, which minimizes file size and maximizes efficiency. Avro has reliable support for schema evolution by managing added, missing, and changed fields. This allows old software to read new data, and new software to read old data — it is a critical feature if your data can change.

 

Avro's ability to manage scheme evolution allows components to be updated independently, at different times, with a low risk of incompatibility. This eliminates the need for applications to write if-else statements to handle different versions of schema and eliminates the need for the developer to look at old code to understand the old schema. Since all versions of the schema are stored in a human-readable JSON header, it is easy to understand all the fields available to you.

Since the schema is stored in JSON and the data is stored in binary form, Avro is a relatively compact option for both permanent storage and wire transfer. Since Avro is a row-based format, it is the preferred format for handling large amounts of records as it is easy to add new rows.

 

Advantages

 

Avro is a linguistic-neutral serialization of data.

 

Avro stores the schema in a file header, so the data is self-describing;

 

Easy and fast data serialization and deserialization, which can provide

 

very good ingestion performance.

 

As with the Sequence files, the Avro files also contain synchronization markers to separate blocks. This makes it highly splitable.

 

Files formatted in Avro are splitable and compressible and are therefore a good candidate for data storage in the Hadoop ecosystem.

 

The schema used to read Avro files does not necessarily have to be the same as the one used to write the files. This allows new fields to be added independently of each other.

 

 

Disadvantages

 

 Makes you think about the schema and data types;

 

 Its data is not human-readable;

 

 Not integrated into every programming language.

 

ORC

 

ORC, short for Optimized Row Columnar, is a free and open-source columnar storage format designed for Hadoop workloads. As the name suggests, ORC is a self-describing, optimized file format that stores data in columns which enables users to read and decompress just the pieces they need. It is a successor to the traditional Record Columnar File (RCFile) format designed to overcome limitations of other Hive file formats. It takes significantly less time to access data and also reduces the size of the data up to 75 percent. ORC provides a more efficient and better way to store data to be accessed through SQL-on-Hadoop solutions such as Hive using Tez. ORC provides many advantages over other Hive file formats such as high data compression, faster performance, predictive push down feature, and moreover, the stored data is organized into stripes, which enable large, efficient reads from HDFS

 

 

 

Friday, September 2, 2022

Access Control Lists on Linux

Access control lists (ACL) allow us to fine-tune access control in systematic manner.

With the help of  ACLs, permissions can be defined more flexibly than with the traditional permission .

Traditional Linux access permissions for files and directories consist of setting a combination of read, write, and execute permissions for all

owner,group,others. Access control lists (ACLs) provide a finer-grained access control mechanism than these traditional Linux access permissions.


u:name:permissions: Sets the access ACL for a user (username or UID)

g:name:permissions: Sets the access ACL for the group (group name or GID)

m:permissions: Sets the effective rights mask. This is the union of all permissions of the owning group and all of the user and group entries.

o:permissions: Sets the access ACL for everyone else (others)


# install plugins


$ sudo apt-get install acl -y



Use the setfacl utility to add or modify one or more rules in a file’s ACL. The syntax is: 


$ setfacl -m [rules] [files]


$  setfacl -m u:oracle:rwx foldername



List of commands for setting up ACL :


1) To add permission for user

setfacl -m "u:user:permissions" /path/to/file


2) To add permissions for a group

setfacl -m "g:group:permissions" /path/to/file 


3) To allow all files or directories to inherit ACL entries from the directory it is within

setfacl -dm "entry" /path/to/dir


4) To remove a specific entry

setfacl -x "entry" /path/to/file

 setfacl –x u:oracle <filename>

5) To remove all entries

setfacl -b path/to/file

setfacl –b  <filename>


6) To create default ACL entries, specify the -d option when setting ACL using the setfacl command.

setfacl -d -m {u, g}:<name>:[r, w, x] <directory>


7) Deleting default access control lists on directories.

setfacl -k <directory>


8) To remove default ACL entries in a directory and all subdirectories, you would have to use a recursive option (-R)

setfacl -kR <directory>





Thursday, September 1, 2022

security in Hadoop cluster

 


generally , in company securiy reveal aground  following three thing


1) Authentication  : Authentication  can be done by any of the  following 


     a) MIT KDC

     b) Active Directory

     c) Red HatIPA 




2)  Authorization :     Authorization  done by follwing ways

    a)    Linux Posix Permission 

    b)    Extended ACL'S

    c)    Sticky Bit

    d)   Sentry



3) Encryption : Encryption is another common solution used to secure data both at rest and in motion

 

 for at rest     : We Create an Encryption Zone 

 for in motion: We Install an SSL/TLS Certificate.

 following some of the screenshot to give clue of how to secure cluster.


























Wednesday, August 31, 2022

Backing Up Databases In Cloudera

 Cloudera recommends that you schedule regular backups of the databases that Cloudera Manager uses to store configuration, monitoring, and reporting data and for managed services that require a database


Cloudera Manager Server - Contains all the information about services you have configured and their role assignments, all configuration history, commands, users, and running processes. This relatively small database (< 100 MB) is the most important to back up



To back up a PostgreSQL database, use the same procedure whether the database is embedded or external:


Step 1: Start


Step 2: Log in to the host where the Cloudera Manager Server is installed


Step 3:  Get the name, user, and password properties for the Cloudera Manager database from /etc/cloudera-scm-server/db.properties


com.cloudera.cmf.db.name=scm

com.cloudera.cmf.db.user=scm

com.cloudera.cmf.db.password=NnYfWIjlbk


Step 4: Run the following command as root using the parameters from the preceding step

 pg_dump -h hostname -p 7432 -U scm > /tmp/scm_server_db_backup.$(date +%Y%m%d)


Step 5: Enter the password from the com.cloudera.cmf.db.password property in step 2


Step 6: Stop


Tuesday, August 30, 2022

linux-filesystems

 By default, the ext3 and ext4 filesystems reserve 5% space for use by the root user. This reserved space counts as Non DFS Used.


To view the reserved space use the tune2fs command.
$ sudo lsblk  
sudo tune2fs -l /dev/nvme0n1p1 | egrep "Block count|Reserved block count"

OUTPUT :
Reserved block count: 36628312
Block size:      4096

The Reserved block count is the number of ext3/ext4 filesystem blocks that are reserved. The block size is the size in bytes.

Cloudera recommends reducing the root user block reservation from 5% to 1% for the DataNode volumes.

To set reserved space to 1% with the tune2fs command

tune2fs -m 1 /dev/sde1

run the following command to see output

$ sudo tune2fs -l /dev/nvme0n1p1 | egrep "Block count|Reserved block count"

Monday, August 29, 2022

Oozie

 Apache Oozie is a Java Web application used to schedule Apache Hadoop jobs. it is a workflow scheduler system to manage Apache Hadoop jobs. Oozie combines multiple jobs sequentially into one logical unit of work.


It is integrated with the Hadoop stack, with YARN as its architectural center, and supports Hadoop jobs for Apache MapReduce, Apache Pig, Apache Hive, and Apache Sqoop.


Oozie is integrated with the rest of the Hadoop stack supporting several types of Hadoop jobs out of the box (such as Java map-reduce, Streaming map-reduce, Pig, Hive, Sqoop and Distcp) as well as system specific jobs (such as Java programs and shell scripts)


Oozie is a scalable, reliable and extensible system.


There are two basic types of Oozie jobs

1) Oozie Workflow jobs are Directed Acyclical Graphs (DAGs), specifying a sequence of actions to execute.

2) Oozie Coordinator jobs are recurrent Oozie Workflow jobs that are triggered by time and data availability.

Saturday, July 16, 2022

hbase-commands

 Creating a Table using HBase Shell


1)  create command  : create command use to create table .  in this create command two things you must specify the table name and the Column Family name. The syntax to create a table in HBase shell is shown below.

create ‘<table name>’,’<column family>’


Example 1:


create 'employee', 'personal data', 'professional data'


2) list command    :  this command is use to list all  tables. The synax to list all tables in HBase  shell is shown below.

list

Example 2: 

list  



3)    put command :  put command use to  insert rows into a table. Its syntax is as follows:

put ’<table name>’,’row1’,’<colfamily:colname>’,’<value>’


Example 3:  

 put 'employee','1','personal data:name','sameer'

 put 'employee','1','personal data:city','pune'

 put 'employee','1','professional data:designation','hadoop administrator'

 put 'employee','1','professional data:salary','280000'


4) get command : get command  use to read data from a table in HBase.The following example shows how to use the get command

get ’<table name>’,’row1’

Example 4:

get 'employee', '1' 


5) describe command : describe command  returns the description of the table. Its syntax is as follows

describe 'table name'

Example 5:

describe 'employee'


6)  scan command :  scan command is used to view the data in HTable.  Using the scan command, you can get the table data. Its syntax is as follows.

scan ‘<table name>’

Example 6: 

scan 'employee'



7) disabling command  :  disabling command is use to  disable table in  HBase Shell.

The syntax to disable a table in HBase shell is shown below.


Example 7:

disable 'employee'


8)  is_disabled  command:  is_disabled command is used to find whether a table is disabled. Its syntax is as follows.

Example 8:

is_disabled 'table name'

is_disabled 'employee'


9) disable_all command: disable_all command is use to  disable   all the tables matching the given regex. all the tables matching the given regex

 disable_all 'e.*'

Example 9:

 disable_all 'e.*'


10) drop command: drop command is use to  dropping a table using HBase Shell. 

Note : Before dropping a table, you have to disable it first. 

Example 10: 


disable 'employee'

drop   'employee'