Ambari 설치방법 - bigchameleon/ambari-lustre GitHub Wiki

Ambari 설치

2018년 1월 29일 [email protected]

Apache Ambari (https://ambari.apache.org/) 는 아파치 소프트웨어 재단의 프로젝트이며, 시스템 관리자가 하둡 클러스터를 관리하고 모니터링할 수 있는 툴이다. 원래 Ambari 는 Hadoop의 하위 프로젝트 이었으나, 현재는 톱레벨 프로젝트이다. 암바리는 하둡 클러스터를 다룰때 발생하는 문제점을 해결하기 위해 발전되어 왔다. 암바리는 표준 구성 요소로 클러스터를 설정하기 위한 웹 기반 GUI와 마법사 형식의 스크립트를 제공한다. 아파치 공개 프로젝트 이지만, 호튼웍스(Hortonworks)에서 주로 지원하고 있다. 암바리의 구조는 크게 나누면 Ambari Server와 Ambari Agent 로 나누어진다. 각 노드에 설치된 Agent가 중앙의 Server와 상호작용을 하는 구조이다. 통신은 REST API형식의 프로토콜을 사용하며, 클러스터의 상태정보와 하둡클러스터의 관리에 대한 기능이 구현된다.

1. 가상머신 준비하기

암바리 설치를 위해 가상머신을 준비한다. 본 문서에서는 VirtualBox 에서 CentOS 7 VM을 이용하여 설치를 진행해 본다. 가상 머신을 하나씩 수동으로 설치할 수도 있으나, 여기서는 Vagrant 를 이용하여 일괄 생성하도록 해 본다.

다음과 같이 Vagrantfile을 준비하고 VM을 시작한다.

Vagrant.configure("2") do |config|

  config.vm.box = "centos7"
  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.provider "virtualbox" do |v|
      v.customize ["modifyvm", :id, "--memory", "4096"]
      v.customize ["modifyvm", :id, "--usb", "on"]
      v.customize ["modifyvm", :id, "--usbehci", "off"]
      v.customize ["modifyvm", :id, "--description", "some description"]
  end

  config.vm.define "node1" do |node|
    node.vm.network "private_network", ip: "192.168.56.101"
    node.vm.hostname = 'amnode1'
    node.vm.provider "virtualbox" do |v|
      v.customize ["modifyvm", :id, "--name", "amnode1"]
    end
  end

  config.vm.define "node2" do |node|
    node.vm.network "private_network", ip: "192.168.56.102"
    node.vm.hostname = 'amnode2'
    node.vm.provider "virtualbox" do |v|
      v.customize ["modifyvm", :id, "--name", "amnode2"]
    end
  end

  config.vm.define "node3" do |node|
    node.vm.network "private_network", ip: "192.168.56.103"
    node.vm.hostname = 'amnode3'
    node.vm.provider "virtualbox" do |v|
      v.customize ["modifyvm", :id, "--name", "amnode3"]
    end
  end

  config.vm.define "node4" do |node|
    node.vm.network "private_network", ip: "192.168.56.104"
    node.vm.hostname = 'amnode4'
    node.vm.provider "virtualbox" do |v|
      v.customize ["modifyvm", :id, "--name", "amnode4"]
    end
  end

  config.vm.define "node5" do |node|
    node.vm.network "private_network", ip: "192.168.56.105"
    node.vm.hostname = 'amnode5'
    node.vm.provider "virtualbox" do |v|
      v.customize ["modifyvm", :id, "--name", "amnode5"]
    end
  end

end
# vagrant up
....wait....
# vagrant status
Current machine states:

node1                     running (virtualbox)
node2                     running (virtualbox)
node3                     running (virtualbox)
node4                     running (virtualbox)
node5                     running (virtualbox)

# vboxmanage  list runningvms
"amnode1" {9a3827c0-9cb3-4538-a71c-45dddf47c2bb}
"amnode2" {f7480a0f-96c6-4f61-80ac-ed3ec28113d9}
"amnode3" {11a01ba0-1fd7-4958-9f9c-9ea7e45d66fe}
"amnode4" {4812c781-8382-46ad-bd52-54100d724ff6}
"amnode5" {376e3747-0032-4ef4-990f-e9885c8929c8}

5개의 가상 머신이 준비 되었다. node1번에 ambari 를 설치하고, node2,3,4,5 는 하둡 클러스터로 설정하기로 한다.

먼저 모든 노드의 selinux 는 disable로 설정한다. 노드 1번으로 접속하여 hosts 파일을 만든 다음, ssh 접속 키를 만들고 각 노드로 복사해 준다.

# ssh -l root 192.168.56.101

[root@amnode1 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.101   node1  node1.example.com
192.168.56.102   node2  node2.example.com
192.168.56.103   node3  node3.example.com
192.168.56.104   node4  node4.example.com
192.168.56.105   node5  node5.example.com
:wq

[root@amnode1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
15:b4:b3:f4:ac:69:5f:c2:f4:d1:81:68:6c:32:22:6d root@amnode1
....
[root@amnode1 ~]# cp .ssh/id_rsa.pub  .ssh/authorized_keys

[root@amnode1 ~]#
 scp -r .ssh node2:./
 scp -r .ssh node3:./
 scp -r .ssh node4:./
 scp -r .ssh node5:./

/etc/host 파일을 각 노드로 복사함

for host in node2 node3 node4 node5 ; do  scp /etc/hosts  $host:/etc/hosts  ; done

호스트네임을 FQDN 형식으로 설정

for host in node2 node3 node4 node5 ; do  ssh $host "hostname $host.example.com"  ; done

for host in node1 node2 node3 node4 node5
do
  ssh $host "hostname > /etc/hostname"
done

/etc/selinux/config 파일에서 SELINUX=disabled 로 수정하고 각 노드로 복사

vi   /etc/selinux/config
...
SELINUX=disabled
...
:wq

for host in node2 node3 node4 node5 ; do  scp /etc/selinux/config $host:/etc/selinux/config  ; done
for host in node2 node3 node4 node5 ; do ssh $host setenforce 0 ; done

시간 동기화를 위해 ntp 서비스를 설치한다.

for host in node1 node2 node3 node4 node5 ;
do
 ssh $host  yum install -y ntp
 ssh $host  chkconfig ntpd on
done
for host in node1 node2 node3 node4 node5 ; do ssh $host date ; done

Tue Jan 30 11:28:29 KST 2018
Tue Jan 30 11:28:29 KST 2018
Tue Jan 30 11:28:29 KST 2018
Tue Jan 30 11:28:30 KST 2018
Tue Jan 30 11:28:30 KST 2018

CentOS 7의 기본 방화벽 서비스를 중시시킨다.

for host in node1 node2 node3 node4 node5 ;
do
 ssh $host  /bin/systemctl stop     firewalld.service
 ssh $host  /bin/systemctl disable  firewalld.service
done

UMASK를 동일하게 설정한다.

echo umask 0022 >> /etc/profile

for host in node2 node3 node4 node5 ; do scp /etc/profile $host:/etc/profile  ; done

설정을 마친 후에 모든 노드를 재부팅 한다.

for host in node2 node3 node4 node5 ; do ssh $host reboot  ; done
reboot

2. 암바리 서버 설치하기

자세한 설치 방법은 다음 링크를 참고한다.

먼저 레포지터리 파일을 다운로드하여 /etc/yum.repos.d 폴더에 넣어준다.

wget -O /etc/yum.repos.d/ambari.repo \
  http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.0.0/ambari.repo 

레포지터리가 추가 되었는지 확인한다.

[root@node1 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
ambari-2.6.0.0                                                                                                          | 2.9 kB  00:00:00     
ambari-2.6.0.0/primary_db                                                                                               | 8.6 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: data.nicehosting.co.kr
 * extras: data.nicehosting.co.kr
 * updates: data.nicehosting.co.kr
repo id                                       repo name                                                     status
ambari-2.6.0.0                                ambari Version - ambari-2.6.0.0                                   12
base/7/x86_64                                 CentOS-7 - Base                                                9,591
extras/7/x86_64                               CentOS-7 - Extras                                                329
updates/7/x86_64                              CentOS-7 - Updates                                             1,909
repolist: 11,841

암바리 서버를 시작한다.

yum  install -y   ambari-server

서버 셋업을 진행한다.

# ambari-server setup
Using python  /usr/bin/python
Setup ambari-server
Checking SELinux...
SELinux status is 'disabled'
Customize user account for ambari-server daemon [y/n] (n)? **n**
Adjusting ambari-server permissions and ownership...
Checking firewall status...
Checking JDK...
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
[3] Custom JDK
==============================================================================
Enter choice (1): 1
To download the Oracle JDK and the Java Cryptography Extension (JCE) Policy Files you must accept the license terms found at http://www.oracle.com/technetwork/java/javase/terms/license/index.html and not accepting will cancel the Ambari Server setup and you must install the JDK and JCE files manually.
Do you accept the Oracle Binary Code License Agreement [y/n] (y)? y
Downloading JDK from http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-8u112-linux-x64.tar.gz to /var/lib/ambari-server/resources/jdk-8u112-linux-x64.tar.gz
jdk-8u112-linux-x64.tar.gz... 100% (174.7 MB of 174.7 MB)
Successfully downloaded JDK distribution to /var/lib/ambari-server/resources/jdk-8u112-linux-x64.tar.gz
Installing JDK to /usr/jdk64/
Successfully installed JDK to /usr/jdk64/
Downloading JCE Policy archive from http://public-repo-1.hortonworks.com/ARTIFACTS/jce_policy-8.zip to /var/lib/ambari-server/resources/jce_policy-8.zip

Successfully downloaded JCE Policy archive to /var/lib/ambari-server/resources/jce_policy-8.zip
Installing JCE policy...
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? n
Configuring database...
Default properties detected. Using built-in database.
Configuring ambari database...
Checking PostgreSQL...
Running initdb: This may take up to a minute.
Initializing database ... OK


About to start PostgreSQL
Configuring local database...
Configuring PostgreSQL...
Restarting PostgreSQL
Creating schema and user...
done.
Creating tables...
done.
Extracting system views...
ambari-admin-2.6.0.0.267.jar
...........
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.

서비스를 시작한다.

[root@node1 ~]# ambari-server  start
Using python  /usr/bin/python
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Ambari database consistency check started...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start................................
Server started listening on 8080

DB configs consistency check: no errors and warnings were found.
Ambari Server 'start' completed successfully.

서비스의 상태를 확인한다.

[root@node1 ~]# ambari-server  status
Using python  /usr/bin/python
Ambari-server status
Ambari Server running
Found Ambari Server PID: 4062 at: /var/run/ambari-server/ambari-server.pid

3. 암바리웹을 이용하여 하둡 클러스터 설치하기

Ambari Server 가 정상적으로 실행되었다면 8080 포트로 접속하여 웹 인터페이스에 접속할 수 있다. http://localhost:8080/#/login

암바리 로그인 화면

Launch Install Wizard 버튼을 클릭하고, 설치할 클러스터 이름을 입력한다.

xxx

xxx

설치할 HDP 스텍의 버전을 선택한다.

xxx

암바리 버전에 따라 지원되는 HDP 스택 버전은 https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.6.2/bk_support-matrices/content/ch_matrices-ambari.html 를 참고할 것

아래쪽에서는 사용할 레포지터리의 주소를 입력 또는 확인한다. Local Repository를 사용할 경우 주소를 직접 입력해야 한다. Public Repository를 선택할 경우 사용할 OS에 따라서 레포지터리 경로가 다르다.

xxx

여기서는 CentOS 7 OS만 사용할 것이므로, 다른 OS는 삭제하고, redhat7만 남겨둔다. HDP-2.6 Base URL http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.3.0 HDP-UTILS-1.1.0.21 Base URL http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7

다음은 설치를 진행할 호스트 명과 SSH 키 정보를 입력한다. xxx

node1은 Ambari Server 만을 위해서 사용할 예정이므로, node1을 제외하고, node2, node3, node4, node5 를 타켓 호스트 입력란에 써준다. 그 아래 쪽으로 Host Registration Information 란에는 node1번의 root 계정의 SSH 개인키 정보를 입력한다. ~/.ssh/id_rsa 키파일의 내용을 복사하여 붙여넣기 한다. SSH를 등록하지 않고, 수동으로 등록하는 경우 Ambari Agent를 수동으로 설치해 주어야 한다. 입력이 끝났으면 Register and Confirm 버튼을 누른다.

다음 절차로는 앞서 입력한 호스트에 대하여 Ambari Agent 를 설치하고, 서버에 등록하는 과정을 진행한다. 정상적으로 등록이 되었다면 초록색으로 Success 가 표시된다. xxx

진행되는 작업은 다음과 같다.

  • 작업 디렉터리인 /var/lib/ambari-agent/data 가 존재하는지 확인
  • ambari sudo script 를 /var/lib/ambari-server/ambari-sudo.sh 경로에 복사한다.
  • /usr/lib/python2.6/site-packages/ambari_commons 경로에 필요한 스크립트들을 복사한다.
  • 파이썬 랩핑 스크립트 /var/lib/ambari-server/create-python-wrap.sh 파일을 복사한다.
  • OS 채크를 위한 /usr/lib/python2.6/site-packages/ambari_server/os_check_type.py 파일을 복사한다.
  • Yum 레포지터리 파일 /etc/yum.repos.d/ambari.repo 을 복사한다.
  • 셋업 스크립트 파일 /usr/lib/python2.6/site-packages/ambari_server/setupAgent.py 을 복사한다.
  • setupAgent.py 스크립트를 실행한다.
  • setupAgent.py가 실행되면서 서버에 해당 호스트를 등록한다.

다음 단계로 설치할 서비스를 선택하는 화면이 나온다. 기본적인 서비스만 선택해 보도록 한다. HDFS, Yarn+MapReduce2, Tez, Hive, HBase, Pig, Sqoop, Oozie 를 선택 xxx

다음으로 진행하기 전에 의존성으로 필요한 서비스가 있으면 다음과 같이 추가할 것인지 물어본다. xxx xxx xxx

다음으로 마스터 서비스를 설치할 노드를 선택하는 화면이 나온다. 일단은 변경하지 않고, 그냥 넘어가기로 한다. xxx

다음으로 슬레이브와 클라이언트를 설치할 호스트를 입력하는 화면이 나온다. DataNode는 2,3,4,5에 전부다 설치하고, NodeManager와 RegionServer는 node5에 설치, Phoenix Query Server 는 node2,3,4,5에 모두 설치, Client도 모든 노드에 다 설치한다. xxx

다음 화면에서는 서비스에 대한 상세 설정을 하는 화면이 나온다. xxx

먼저 HDFS 에 보면 NameNode directories 가 있고, Can't start with 'home(s)' 라고 경고가 표시된다. /home 으로 시작하는 설정을 삭제한다. DataNode 도 마찬가지로 /home 으로 시작하는 설정을 삭제한다.

변경전

xxx

변경후

xxx

다음으로 YARN 서비스의 경우도 빨간색으로 표시된 부분을 보면 yarn.nodemanager.local-dirs 설정에서 /home 으로 시작되는 설정이 들어가 있으므로 지워준다.

변경전

xxx

변경후

xxx

Hive 서비스의 경우 Database Password 란이 비어 있으므로 패스워드를 설정해 준다.

xxx

Oozie 도 마찬가지로 Database Password 를 채워준다.

xxx

Ambari Metrics 서비스도 마찬가지임

xxx

SmartSense 도 마찬가지임

xxx

빨간색 아이콘이 없이 모두 해결되었다면 Next 를 진행한다.

xxx

설정에 문제가 있을 경우 그림과 같이 표시된다. dfs.datanode.du.reserved 가 너무 작다는 것과, hive.tez.container.size 가 최소 512MB가 되어야 된다는 내용인데 무시하고 그대로 진행한다.

xxx

xxx

설치를 진행하기 전에 입력한 내용을 확인한다. xxx

설치가 진행된다.

xxx

설치가 완료됨

xxx

암바리 데시보드 화면

xxx

HDFS 서비스 페이지

xxx