CDH6 Cloudera Hadoop 설치하기
- IT 정보/Hadoop Eco System
- 2020. 10. 4.
안녕하세요. 린아저씨 입니다.
제가 처음 접한 하둡은 아파치 바닐라 하둡 버전이었지만, 실제 프로덕트 환경에서는 주로 Cloudera 배포판 하둡을 구축하고 운영해 왔습니다.
현 직장으로 이직을 하면서 이미 구축해 놓은 Cloudera 클러스터를 운영하게되면서 설치를 꽤 오래 안하게 되었습니다.
그래서 오늘은 오랜만에 설치 과정을 리마인드 할겸 Cloudera Manger를 이용해서 하둡 설치과정을 상세하게 포스팅하려고 합니다.
기존에 CDH5 버전을 설치해보신 분이라면 더욱 쉽게 하실 수 있으실 것입니다. 단 CDH6로 오면서 CM 스키마 생성 스크립트 위치등 소소한 몇가지가 변경된 부분이 있어 이 부분만 주의해 주시면 됩니다.
1. 설치 전 준비사항
-
모든 작업은 root 계정으로 진행
-
모든 노드의 root 패스워드는 동일하게 설정하는 것이 작업에 편리함
-
클러스터를 구성하는 노드의 호스트 네임은 FQDN 형식으로 반드시 설정
-
/etc/hosts에 모든 노드의 IP, 호스트 네임 등록
172.16.31.130 hadoop00.testcluster.co.kr hadoop00
172.16.31.131 hadoop01.testcluster.co.kr hadoop01
172.16.31.132 hadoop02.testcluster.co.kr hadoop02
172.16.31.133 hadoop03.testcluster.co.kr hadoop03
2. ssh-keygen 구성
-
ssh-key 생성
# ssh-keygen
-
ssh-key 배포
# for((i=0;i<4;i++)); do ssh-copy-id -i ~/.ssh/id_rsa.pub 172.16.31.13$i; done
3. clustershell & pssh 설치
-
sftp를 이용해서 clustershell 및 pssh 설치 파일 복사 및 설치
# yum install -y pssh
# yum install -y clustershell
-
vi /root/allnodes 파일 생성
# vi ~/allnodes
172.16.31.130
172.16.31.131
172.16.31.132
172.16.31.133
4. 디스크 포맷 및 마운트
-
마운트 되어 있는 dev와 디렉터리 확인
# df -Th
-
파티션 확인
# fdisk -l
-
파티션 설정
# fdisk /dev/sdb
확인 p || 추가 n || 저장 후 나가기 w
-
파티션 포맷
# mkfs.xfs /dev/sdb1
-
디렉터리 추가
# mkdir /data
-
마운트
# mount -t xfs /dev/sdb1 /data
-
재부팅시 마운트가 풀리지 않도록 /etc/fstab 파일 수정
# vi /etc/fstab
/dev/sdb1 /data xfs defaults,noatime 0 0
✓Note : Data 디렉터리 생성시 /data1, /data2, /data3, ..., /dataN 과 같이 절대경로 밑에 디렉터리를 나열하지 말고, /data/01, /data/02, /data/03 .... /data/N 과 같이 절대경로 밑에 data디렉터리를 하나 두고 그 밑에 나열하는 디렉터리 구조를 권고.
5. 방화벽 정지 & Networkmanager 정지
-
firewall 데몬 중지
# pssh -h ~/allnodes "systemctl stop firewalld"
# pssh -h ~/allnodes "systemctl disable firewalld"
-
SELinux 사용 중지
# sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
# pssh -h ~/allnodes "setenforce 0"
# pscp -h ~/allnodes /etc/selinux/config /etc/selinux/config
-
NetworkManager 정지
# pssh -h ~/allnodes "systemctl stop NetworkManager"
# pssh -h ~/allnodes "systemctl disable NetworkManager"
6. local repository 구성(Private network 환경의 경우)
-
iso파일의 경우 mount하여 rpm 파일 복사
# mount -t iso9660 -o loop /root/CentOS-7-x86_64-Everything-1804.iso /root/centos7/
-
sftp를 통해서 centos rpm / createrepo rpm / cm rpm / cdh parcle 파일 복사
-
createrepo 디렉터리에 순서대로 rpm 설치
-
repo 생성
# createrepo centos7.5
-
/centos7.4/repodata/repomd.xml 파일 생성여부 확인
-
repo 설정 파일 생성(# vi centos7.repo)
[Centos7]
name=centos7 repository
baseurl=file:///root/centos7.5
gpgcheck=0
enabled=1
-
repo 리스트 확인
# yum clean all
# yum repolist
7. httpd 설치 및 local_lepo 설정 변경
-
httpd 설치
# yum install -y httpd
-
httpd 설정 변경(Local Parcel Repository 이용시)
# vi /etc/httpd/conf/httpd.conf
<IfModule mime_module> </IfModule> 영역에서
AddType application/x-gzip .gz .tgz .parcel 추가
✓Warning : 다음 설정을 해주지 않을시에 해쉬 실패 에러 발생
-
httpd 시작
# systemctl start httpd
# systemctl enable httpd
-
centos7.5 / cm5.15 / cdh5.15 디렉터리 /var/www/html 로 이동
-
각 디렉터리 권한 설정(확인 후 이미 되어있으면 할 필요 없음)
# chmod -R ugo+rX /var/www/html/centos7.5
# chmod -R ugo+rX /var/www/html/cdh5.15
# chmod -R ugo+rX /var/www/html/cm5.15
-
repo 설정 수정
baseurl=file:///root/local_repo/centos7.2 ⇒ baseurl=http://172.16.31.130/centos7.2
-
repo 리스트 확인
# yum clean all
# yum repolist
8. cm6.0 repo 생성
-
cm5.15 repo 생성
# createrepo cm5.15
*Cloudera manager 6.0 부터는 agent / daemons / RPM-GPG-KEY / allkeys.asc 총 4개 파일 필요
-
cm5.15 repo 설정 파일 생성(# vi /etc/yum.repos.d/cloudera-manager.repo )
[cloudera-manager]
name=Cloudera Manager
baseurl=http://172.16.15.130/cm6.0
gpgkey =http://172.16.15.130/cm6.0/RPM-GPG-KEY-cloudera
gpgcheck=1
enabled=1
autorefresh=0
type=rpm-md
-
전체 노드에 배포
# pscp -h /root/allnodes /etc/yum.repos.d/cloudera-manager.repo \
/etc/yum.repos.d/cloudera-manager.repo
-
repo 리스트 확인
# pssh -h /root/allnodes "yum clean all"
# clush -B -a "yum repolist"
9. IPv6 disabled
-
ipv6 설정 확인
# lsmod | grep ipv6
-
ipv6 disabled - 파일 하단에 추가(# vi /etc/sysctl.conf )
# disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
-
ipv6 disabled - 파일 하단에 추가(# vi /etc/sysconfig/network )
NETWORKING_IPV6=no
IPV6INIT=no
-
모든 노드에 배포
# pscp -h /root/allnodes /etc/sysctl.conf /etc/sysctl.conf
# pscp -h /root/allnodes /etc/sysconfig/network /etc/sysconfig/network
10. Optimizing Performance
-
Disable the tuned Service - tuned 서비스 정지
# pssh -h /root/allnodes "tuned-adm off"
-
Disable the tuned Service - tuned 서비스 정지 확인
# clush -B -a "tuned-adm list"
-
Disable the tuned Service - tuned 중지
# pssh -h /root/allnodes "systemctl stop tuned"
# pssh -h /root/allnodes "systemctl disable tuned"
-
Disabling Transparent Hugepages(THP) & vm.swappiness 설정
# echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> \
/etc/rc.d/rc.local
# echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> \
/etc/rc.d/rc.local
# echo 'sysctl -w vm.swappiness=1' >> /etc/rc.d/rc.local
-
모든 노드에 배포
# pscp -h /root/allnodes /etc/rc.d/rc.local /etc/rc.d/rc.local
# pssh -h /root/allnodes "chmod +x /etc/rc.d/rc.local"
-
THP를 사용하지 않기 위해 GRUB 설정 파일 수정(# vi /etc/default/grub )
(GRUB_CMDLINE_LINUX 맨 마지막에 transparent_hugepage=never 추가)
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet transparent_hugepage=never"
-
모든 노드에 배포
# pscp -h /root/allnodes /etc/default/grub /etc/default/grub
-
모든 노드에 변경사항 적용
# pssh -h /root/allnodes "grub2-mkconfig -o /boot/grub2/grub.cfg"
-
모든 노드 재부팅 후 변경사항 확인
# clush -B -a "cat /sys/kernel/mm/transparent_hugepage/enabled"
⇒ always madvise [never]
# clush -B -a "cat /sys/kernel/mm/transparent_hugepage/defrag"
⇒ always madvise [never]
# clush -B -a "cat /proc/cmdline"
⇒ BOOT_IMAGE=/vmlinuz-3.10.0-229.20.1.el7.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiettransparent_hugepage=never
# clush -B -a "cat /proc/sys/vm/swappiness"
⇒ 1
# clush -B -a "cat /proc/meminfo"
11. HBase 환경설정
HBase는 데이터베이스이기 때문에 동시에 많은 파일을 열 수 있어야 한다. 대부분의 유닉스 계열 시스템에서는 열린 파일의 최대 수에 대한 기본값은 1024로 HBase에서 사용하기에 부족하다. 따라서 다음과 같은 에러가 발생시 동시에 열 수 있는 파일 수를 올려주어야 한다.
2010-04-06 03:04:37,542 INFO org.apache.hadoop.hdfs.DFSClient: Exception increateBlockOutputStream java.io.EOFException
2010-04-06 03:04:37,542 INFO org.apache.hadoop.hdfs.DFSClient: Abandoning block blk_-6935524980745310745_1391901
Cloudera에서는 최대 파일 핸들 수를 10,000개 이상으로 늘릴 것을 권장한다. HBase 프로세스를 실행하는 사용자의 파일 핸들을 늘리는 것은 HBase 구성이 아닌 운영체제 구성이다. 일반적인 실수는 HBase가 다른 사용자로 실행될 때 특정 사용자에 대한 파일 핸들 수를 늘리는 것이다.
-
최대 파일 핸들 수 변경(# vi /etc/security/limits.conf )
hdfs - nofile 65536
hdfs - nproc 65536
hbase - nofile 65536
hbase - nproc 65536
mapred - nofile 65536
mapred - nproc 65536
root - nofile 65536
root - nproc 65536
-
모든 노드에 배포
# pscp -h /root/allnodes /etc/security/limits.conf /etc/security/limits.conf
12. NTP 설치 및 시간 동기화
-
모든 노드에 ntp 설치
# pssh -h /root/allnodes "yum install -y ntp --nogpgcheck"
-
자식 ntp가 기준 ntp 서버를 바라보도록 설정(# vi /etc/ntp.conf )
server 172.16.31.130 /* 기준 NTP 서버 IP */
-
모든 노드에 배포
# pscp -h /root/allnodes /etc/ntp.conf /etc/ntp.conf
-
기준 ntp 환경설정(# vi /etc/ntp.conf )
자식 ntp 서버들이 시간 정보를 가져갈 수 있도록 접근제한을 풀어줌.
restrict 172.16.31.0 mask 255.255.255.0 nomodify notrap
기준 ntp 서버가 자기 자신을 바라볼 수 있도록 설정.
server 127.127.1.0 # local clock
-
모든 노드 ntp 데몬 시작
# pssh -h /root/allnodes "systemctl start ntpd"
# pssh -h /root/allnodes "systemctl enable ntpd"
-
ntpd 서비스가 정상적으로 동작하는지 확인
# clush -B -a "ntpq -pn"
-
기준 ntp 서버 시간 설정
# date -s 15:00:00
-
기준 ntp 서버에 시간 동기화
# ntpdate -u hadoop00
-
모든 노드가 동기화 되는데 10여분정도 필요
# clush -B -a "date"
13. nscd 설치 및 시작
-
모든 노드에 nscd 설치
# pssh -h /root/allnodes "yum install -y nscd"
-
모든 노드에서 nscd 시작
# pssh -h /root/allnodes "systemctl start nscd"
# pssh -h /root/allnodes "systemctl enable nscd"
14. mariaDB 설치 및 설정
-
mariaDB 설치
# yum install -y mariadb-server
-
mariaDB 실행 및 상태 확인
# systemctl start mariadb
# systemctl status mariadb
# systemctl stop mariadb
-
mariaDB 실행을 위해 logfile 삭제 또는 백업
# mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0_backup
# mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1_backup
-
mariaDB conf파일 수정(# vi /etc/my.cof )
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
transaction-isolation = READ-COMMITTED
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
symbolic-links = 0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
#expire_logs_days = 10
#max_binlog_size = 100M
#log_bin should be on a disk with enough free space.
#Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your
#system and chown the specified folder to the mysql user.
log_bin=/var/lib/mysql/mysql_binary_log
#In later versions of MariaDB, if you enable the binary log and do not set
#a server_id, MariaDB will not start. The server_id must be unique within
#the replicating group.
server_id=1
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
-
mariaDB 시작
# systemctl enable mariadb
# systemctl start mariadb
-
mariaDB root 패스워드 설정
# /usr/bin/mysql_secure_installation
⇒ Y / Y / N / Y / Y
15. MySQL 설치 및 설정
-
MySQL 다운로드
# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
-
MySQL repo 설치
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
-
yum repo update
# yum update
-
MySQL-Server 설치
# yum install -y mysql-server
-
MySQL conf 파일 수정(# vi /etc/my.cnf )
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
transaction-isolation = READ-COMMITTED
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
symbolic-links = 0
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
#expire_logs_days = 10
#max_binlog_size = 100M
#log_bin should be on a disk with enough free space.
#Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your
#system and chown the specified folder to the mysql user.
log_bin=/var/lib/mysql/mysql_binary_log
#In later versions of MySQL, if you enable the binary log and do not set
#a server_id, MySQL will not start. The server_id must be unique within
#the replicating group.
server_id=1
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=STRICT_ALL_TABLES
-
MySQL 시작
# systemctl start mysqld
# systemctl enable mysqld
-
임시 root 패스워드 확인
# grep "temporary password" /var/log/mysqld.log
15-1. MySQL root 패스워드 변경
-
MySQL 정지
# systemctl stop mysqld
-
MySQL 옵션 설정( privilege 확인하지 않음 )
# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
-
MySQL 암호 복잡성 해지(mysql 정지 후 실행)
# mv /usr/lib64/mysql/plugin/validate_password.so \
/usr/lib64/mysql/plugin/validate_password.so.bakup
*암호 복잡성 해지하지 않을 시 mysql 5.7 이상 버전에서 password 설정시 반드시 대문자 + 소문자 + 숫자 + 특수문자 조합으로 설정해야 한다.
-
MySQL 시작
# systemctl start mysqld
-
MySQL 접속
# mysql -u root
-
root password 설정
UPDATE mysql.user SET authentication_string = PASSWORD('비밀번호') WHERE user = 'root';
-
MySQL 정지 후 설정했던 옵션 복구
# systemctl stop mysqld
# systemctl unset-environment MYSQLD_OPTS
-
MySQL 시작
# systemctl start mysqld
# systemctl enable mysqld
-
MySQL 정상 접근 후 다시 한번 password 설정
SET PASSWORD = PASSWORD('비밀번호');
16. JDBC Connector 배포
-
JDBC Driver 다운로드 및 압축해제
# wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
# tar xvfz mysql-connector-java-5.1.45.tar.gz
-
모든 노드에 java 디렉터리 생성
# pssh -h /root/allnodes "mkdir -p /usr/share/java"
-
JDBC Connector 배포
# cp ./mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar
# pscp -h /root/allnodes /usr/share/java/mysql-connector-java.jar /usr/share/java/mysql-connector-java.jar
17. DB 생성 및 권한 부여
create database scm DEFAULT CHARACTER SET utf8;
CREATE USER 'scm'@'%' IDENTIFIED BY 'scm' PASSWORD EXPIRE NEVER;
grant all on scm.* TO 'scm'@'%' IDENTIFIED BY 'scm';
create database amon DEFAULT CHARACTER SET utf8;
CREATE USER 'amon'@'%' IDENTIFIED BY 'amon' PASSWORD EXPIRE NEVER;
grant all on amon.* TO 'amon'@'%' IDENTIFIED BY 'amon';
create database rman DEFAULT CHARACTER SET utf8;
CREATE USER 'rman'@'%' IDENTIFIED BY 'rman' PASSWORD EXPIRE NEVER;
grant all on rman.* TO 'rman'@'%' IDENTIFIED BY 'rman';
create database metastore DEFAULT CHARACTER SET utf8;
CREATE USER 'hive'@'%' IDENTIFIED BY 'hive' PASSWORD EXPIRE NEVER;
grant all on metastore.* TO 'hive'@'%' IDENTIFIED BY 'hive';
create database nav DEFAULT CHARACTER SET utf8;
CREATE USER 'nav'@'%' IDENTIFIED BY 'nav' PASSWORD EXPIRE NEVER;
grant all on nav.* TO 'nav'@'%' IDENTIFIED BY 'nav';
create database navms DEFAULT CHARACTER SET utf8;
CREATE USER 'navms'@'%' IDENTIFIED BY 'navms' PASSWORD EXPIRE NEVER;
grant all on navms.* TO 'navms'@'%' IDENTIFIED BY 'navms';
create database sentry DEFAULT CHARACTER SET utf8;
CREATE USER 'sentry'@'%' IDENTIFIED BY 'sentry' PASSWORD EXPIRE NEVER;
grant all on sentry.* TO 'sentry'@'%' IDENTIFIED BY 'sentry';
create database oozie DEFAULT CHARACTER SET utf8;
CREATE USER 'oozie'@'%' IDENTIFIED BY 'oozie' PASSWORD EXPIRE NEVER;
grant all on oozie.* TO 'oozie'@'%' IDENTIFIED BY 'oozie';
create database hue DEFAULT CHARACTER SET utf8 ;
CREATE USER 'hue'@'%' IDENTIFIED BY 'hue' PASSWORD EXPIRE NEVER;
grant all on hue.* to 'hue'@'%' identified by 'hue';
flush privileges;
18. JDK 설치
-
OS에 JAVA가 설치되어 있는지 확인
# rpm -qa | grep java
-
설치되어 있지 않을시 모든 노드에 Oracle JDK 설치
# pssh -h /root/allnodes "yum install -y jdk1.8.0_144 --nogpgcheck"
-
환경변수 설정
export JAVA_HOME=/usr/java/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
-
모든 노드에 배포
# pscp -h /root/allnodes /root/.bashrc /root/.bashrc
-
JAVA 및 JAVA 컴파일러 버전 확인
# clush -B -a "java -version"
# clush -B -a "javac -version"
19. Cloudera Manager 및 Cloudera Manager Agent 설치
-
Util노드에 CM Agent 설치
# yum install -y cloudera-manager-agent
-
설치 확인
# rpm -qa | grep cloudera
-
CM Server 설치
# yum install -y cloudera-manager-server
-
CM Server External DB 스키마 생성
# /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm scm
20. (Recommended) Enable Auto-TLS
-
내장 된 Cloudera Manager CA에서 자동 TLS를 활성화
# JAVA_HOME=/usr/java/jdk1.8.0_162 /opt/cloudera/cm-agent/bin/certmanager setup --configure-services
-
로그 확인
# vi /var/lib/cloudera-scm-server/certmanager
-
생성된 파일 확인
# ls -al /var/lib/cloudera-scm-server/certmanager
21. Cloudera Manager Server 시작
-
CM Server 시작
# systemctl start cloudera-scm-server
-
CM Server 로그 출력
# tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
여기까지 따라오셨으면 아마 에러 없이 설치가 잘 되었을거라 생각합니다.
혹시 장애가 나거나 막히는 부분이 있으시면, 댓글 남겨주세요!
확인하는데로 최대한 도움 드리도록 하겠습니다.