Apache hadoop on linux

How to Install Apache Hadoop on Ubuntu Linux

This article describes the steps to install and use Apache Hadoop on Ubuntu Linux.

Apache Hadoop is an open-source, Java-based software platform that can manage and process large datasets for applications requiring fast and scalable data processing.

It can be used across multiple distributed computing, delivering high availability in cluster environments for your applications.

There are many ways to install Apache Hadoop, and some custom installations are also available. However, for most system administrators, the method below should be the standard way to install it in their environment.

How to install and use Apache Hadoop on Ubuntu Linux

As mentioned above, Apache Hadoop is an open-source, Java-based software platform that can manage and process large datasets for applications requiring fast and scalable data processing.

Below is how to install it when using Ubuntu Linux.

Install JAVA OpenJDK

Apache Hadoop is a Java-based application and therefore requires JDK installed. However, the open-source version of Java is excellent to use with Hadoop.

Run the commands below to install the default OpenJDK packages in Ubuntu’s repositories.

sudo apt update sudo apt install openjdk-11-jdk

Once Java is installed, you can verify its version by running the commands below.

Additional resources on installing OpenJDK on Ubuntu Linux can be found in the post below.

Create a user account for Hadoop

As I said above, there are multiple ways to install Apache Hadoop. In this article, we’re going to be created a dedicated user account to run Hadoop services as well as be able to log on to its web interface.

The account will have a password, and you will also be able to log in to Ubuntu.

Run the commands below to create a new user called Hadoop.

Complete the user details when prompted.

Adding user `hadoop' . Adding new group `hadoop' (1001) . Adding new user `hadoop' (1001) with group `hadoop' . Creating home directory `/home/hadoop' . Copying files from `/etc/skel' . New password: Retype new password: passwd: password updated successfully Changing the user information for hadoop Enter the new value, or press ENTER for the default Full Name []: Apache Hadoop Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y

Once the user is created, switch to the newly created account by running the commands below.

Читайте также:  Mysql linux установка manjaro

Type the password created when creating the user account above when prompted for a password.

Next, generate an SSH key for Hadoop and copy the key to the authorized_keys file in the user profile.

When prompted to enter a passphrase, press ENTER and leave empty for no passphrase.

ssh-keygen -t rsa cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys chmod 640 ~/.ssh/authorized_keys

Log in to accept the SSH server’s key.

Accept the key when prompted:

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'localhost' (ED25519) to the list of known hosts. Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-50-generic x86_64)

Install Apache Hadoop

We are now ready to install Apache Hadoop. At this time of writing this post, the latest Hadoop version is 3.3.4.

Run the commands below to download Hadoop’s current version.

cd /tmp wget https://dlcdn.apache.org/hadoop/common/hadoop-3.3.4/hadoop-3.3.4.tar.gz

Extract the downloaded file and move it into a new Hadoop folder inside the user’s home directory.

tar xzf hadoop-3.3.4.tar.gz mv hadoop-3.3.4 ~/hadoop

Next, run the commands below to open the bashrc file to set up Hadoop environment variables.

You will have to add the variable JAVA_HOME location inside the file. However, you can quickly find the default JAVA_HOME location by running the commands below.

dirname $(dirname $(readlink -f $(which java)))

That should output a similar line as below.

/usr/lib/jvm/java-11-openjdk-amd64

Please copy and paste all the lines below and append them to the bashrc file. Make sure the highlighted line matches your JAVA_HOME path.

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 export HADOOP_HOME=/home/hadoop/hadoop export HADOOP_INSTALL=$HADOOP_HOME export HADOOP_MAPRED_HOME=$HADOOP_HOME export HADOOP_COMMON_HOME=$HADOOP_HOME export HADOOP_HDFS_HOME=$HADOOP_HOME export HADOOP_YARN_HOME=$HADOOP_HOME export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"

Save the load in the new config.

You will also want to confirm JAVA_HOME is correct in the Hadoop-env.sh file.

nano $HADOOP_HOME/etc/hadoop/hadoop-env.sh

Under Generic settings for HADOOP, find the export JAVA_HOME line and uncomment. Then add the JAVA_HOME path and save.

### # Generic settings for HADOOP Many sites configure these options outside of Hadoop, # such as in /etc/profile.d # The java implementation to use. By default, this environment # variable is REQUIRED on ALL platforms except OS X! export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

Configure Apache Hadoop

At this point, we’re ready to configure Hadoop to begin accepting connections. First, create two folders (namenode and datanode) inside the hdfs directory.

Next, edit the core-site.xml file below.

nano $HADOOP_HOME/etc/hadoop/core-site.xml

Then between the configuration lines, enter the hostname value to reference your system name.

See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. -->   fs.defaultFS hdfs://localhost:9000  

Next, edit the hdfs-site.xml file.

nano $HADOOP_HOME/etc/hadoop/hdfs-site.xml

Then create configuration properties to reference the namenode and datanode folders created above.

See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. -->   dfs.replication 1  dfs.name.dir file:///home/hadoop/hadoopdata/hdfs/namenode dfs.data.dir file:///home/hadoop/hadoopdata/hdfs/datanode 

Next, edit the mapred-site.xml file.

nano $HADOOP_HOME/etc/hadoop/mapred-site.xml

Then create configuration properties for the MapReduce framework.

See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. -->   mapreduce.framework.name yarn  

Next, edit the yarn-site.xml file.

nano $HADOOP_HOME/etc/hadoop/yarn-site.xml

Then create configuration properties for yarn.

See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. -->   yarn.nodemanager.aux-services mapreduce_shuffle  

Start and access the Apache Hadoop portal

Finally, we’re ready to start and access the Hadoop portal. But first, run the commands below to format the Hadoop namenode.

Читайте также:  Где хранится пароль линукс

If successfully formatted, you should see a message in the results with the similar line below:

Storage directory /home/hadoop/hadoopdata/hdfs/namenode has been successfully formatted.

Next, run the commands below to start Hadoop.

A successful start message will look like the one below:

Starting namenodes on [localhost] Starting datanodes Starting secondary namenodes [Ubuntu2204] Ubuntu2204: Warning: Permanently added 'ubuntu2204' (ED25519) to the list of known hosts. Starting resourcemanager Starting nodemanagers

Next, open your web browser and browse to the server’s hostname or IP address, followed by port number 9870, to view the Hadoop summary portal.

The Hadoop application portal can be accessed by going to the server’s hostname or IP address followed by port number 8088.

This post showed you how to install and use Apache Hadoop on Ubuntu Linux. Please use the comment form below if you find any errors above or have something to add.

Richard W

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

Источник

Установка и настройка кластера Hadoop на Ubuntu

Обновлено и опубликовано

Опубликовано: 19.01.2022

Пошагово, мы выполним работы по предварительной настройке серверов, установке и конфигурирования hadoop, а также созданию кластера.

Подготовка операционной системы

Данные действия необходимо выполнить на всех узлах кластера Hadoop.

1. Обновление пакетов

Как показывает практика, не обновленный список пакетов может привести к ошибкам при установке программного обеспечения.

Для обновления списка пакетов вводим команду:

Также, при желании, мы можем обновить установленные пакеты (особенно рекомендуется на чистых системах):

2. Настройка брандмауэра

Для корректной работы кластера нам нужно открыть следующие порты:

iptables -I INPUT -p tcp —dport 9870 -j ACCEPT

Читайте также:  Install kali linux persistence

iptables -I INPUT -p tcp —dport 8020 -j ACCEPT

iptables -I INPUT -p tcp —match multiport —dports 9866,9864,9867 -j ACCEPT

  • 9870 — веб-интерфейс для управления.
  • 8020 — RPC адрес для клиентских подключений.
  • 9866 — DataNode (передача данных).
  • 9864 — DataNode (http-сервис).
  • 9867 — DataNode (IPC-сервис).

Для сохранения правил используем утилиту netfilter-persistent:

apt install iptables-persistent

3. Настройка hosts.

Узлы нашего кластера должны уметь обращаться друг к другу по имени. В продуктивной среде для этого, обычно, используется DNS. Но если такой возможности нет, то необходимо на серверах добавить в файл hosts следующее:

192.168.1.15 haddop1
192.168.1.20 haddop2
192.168.1.25 haddop3

* в данном примере мы указываем соответствия IP-адресов и имен для нашего конкретного примера. Само собой, в вашем случае это будут другие данные.
** обратите внимание на закомментированную строку
127.0.1.1. Если этого не сделать, то сервер будет запускаться на локальном адресе 127.0.1.1 и вторичные серверы не смогут подключиться к мастеру.

Установка Java

Hadoop разработан на языке программирования Java, поэтому на наших серверах должна быть установлена данная платформа.

Готово. Смотрим версию установленной java:

Мы должны увидеть что-то на подобие:

openjdk version «11.0.13» 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

Установка Hadoop

Установка выполняется вручную — необходимо скачать бинарник с сайта разработчика и разместить на сервере, создать файлы с переменными окружения и настроить автозапуск с помощью systemd. Данные действия выполняем на всех серверах. Также необходимо обеспечить возможность подключения по ssh ко всем серверам кластера.

Загрузка исходника

Переходим на страницу загрузки Hadoop и кликаем по ссылке для скачивания нужной версии программного обеспечения (в нашем примере, самой свежей):

Переходим на страницу загрузки бинарного файла

Копируем ссылку на загрузку архива:

Копируем ссылку для загрузки архива Hadoop

Используя ссылку, загружаем на наши серверы архив:

Установка и настройка среды

Создадим каталог, в который поместим файлы приложения:

Распаковываем содержимое загруженного архива в созданный каталог:

tar -zxf hadoop-*.tar.gz -C /usr/local/hadoop —strip-components 1

Создаем пользователя hadoop:

Задаем в качестве владельца каталога hadoop созданного пользователя:

chown -R hadoop:hadoop /usr/local/hadoop

export HADOOP_HOME=/usr/local/hadoop
export HADOOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS=»$HADOOP_OPTS -Djava.library.path=$HADOOP_HOME/lib/native»
export YARN_HOME=$HADOOP_HOME
export PATH=»$PATH:$/bin:$/sbin»

* в данном примере мы задаем системные переменные, требующиеся для работы hadoop:

  • HADOOP_HOME — путь, где находятся файлы hadoop.
  • HADOOP_HDFS_HOME — директория распределенной файловой системы HDFS.
  • HADOOP_MAPRED_HOME — необходима для возможности отправки задания MapReduce с помощью MapReduce v2 в YARN.
  • HADOOP_COMMON_HOME — путь хранения файлов для модуля common.
  • HADOOP_COMMON_LIB_NATIVE_DIR — место размещения библиотеки native-hadoop.
  • HADOOP_OPTS — дополнительные опции запуска.
  • YARN_HOME — путь размещения файлов модуля YARN.
  • PATH — дополняет общую переменную PATH, где хранятся пути хранения бинарников для запуска приложений.

Источник

Оцените статью
Adblock
detector