您好,登錄后才能下訂單哦!
這篇文章主要講解了“hadoop環境如何部署”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“hadoop環境如何部署”吧!
準備工作
以下步驟要在所有節點上執行
1.1修改hostname
vi /etc/sysconfig/network
1.2關閉SELinux
查看SELinux狀態getenforce
若SELinux沒有關閉,按照下述方式關閉
vi /etc/selinux/config
修改SELinux=disabled。重啟生效,可以等后面都設置完了重啟主機
1.3關閉防火墻
service iptables stop
chkconfig iptables off
chkconfig iptables --list
1.4網絡配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
1.5修改host
127.0.0.1 localhost#必須配置
# CDH Cluster
192.168.88.11 hadoop1
192.168.88.12 hadoop2
192.168.88.13 hadoop3
1.6配置hadoop1到hadoop2免密登錄
1.7所有節點配置NTP服務
集群中所有主機必須保持時間同步,如果時間相差較大會引起各種問題。 具體思路如下:
master節點作為ntp服務器與外界對時中心同步時間,隨后對所有datanode節點提供時間同步服務。所有datanode節點以master節點為基礎同步時間。
所有節點安裝相關組件: yum install ntp 。
完成后,配置開機啟動: chkconfig ntpd on ,
檢查是否設置成功: chkconfig --list ntpd 其中2-5為on狀態就代表成功。
主節點配置
在配置之前,先使用ntpdate手動同步一下時間,免得本機與對時中心時間差距太大,使得ntpd不能正常同步。這里選用65.55.56.206作為對時中心, ntpdate -u 202.112.10.36
vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
# 允許內網其他機器同步時間
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 中國這邊最活躍的時間服務器 : http://www.pool.ntp.org/zone/cn
server 210.72.145.44 perfer # 中國國家受時中心
server 202.112.10.36 # 1.cn.pool.ntp.org
server 59.124.196.83 # 0.asia.pool.ntp.org
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# allow update time by the upper server
# 允許上層時間服務器主動修改本機時間
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 nomodify notrap noquery
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
# 外部時間服務器不可用時,以本地時間作為時間服務
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
service ntpd start
ntpstat
這個一般需要5-10分鐘后才能成功連接和同步
[root@hadoop1 ~]# netstat -tlunp | grep ntp
udp 0 0 192.168.88.11:123 0.0.0.0:* 17339/ntpd ############################
udp 0 0 127.0.0.1:123 0.0.0.0:* 17339/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 17339/ntpd
udp 0 0 fe80::20c:29ff:fe7c:123 :::* 17339/ntpd
udp 0 0 ::1:123 :::* 17339/ntpd
udp 0 0 :::123 :::* 17339/ntpd
[root@hadoop1 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
202.118.1.130 .INIT. 16 u - 64 0 0.000 0.000 0.000#################################
# ntpstat
unsynchronised
time server re-starting
polling server every 64 s
連接并同步后:
synchronised to NTP server (202.112.10.36) at stratum 3
time correct to within 275 ms
polling server every 256 s
# yum install ntp
# chkconfig ntp on
# vim /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
# 配置時間服務器為本地的時間服務器
server 192.168.1.135
restrict 192.168.1.135 nomodify notrap noquery
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
[root@hadoop2 soft]# ntpdate -u hadoop1
2.cloudra安裝 所有節點
2.1下載cloudera-manager.repo wget http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/cloudera-manager.repo
1將cloudera-manager.repo文件拷貝到所有節點的/etc/yum.repos.d/文件夾下
mv cloudera-manager.repo /etc/yum.repos.d/
vi /etc/yum.conf
timeout=50000
yum list|grep cloudera
如果列出的不是你安裝的版本,執行下面命令重試
yum clean all
yum list | grep cloudera
2.2下載CDH將之前下載的Parcel那3個文件拷貝到/opt/cloudera/parcel-repo目錄下(如果沒有該目錄,請自行創建)
wget http://archive-primary.cloudera.com/cdh6/parcels/5.2.1/CDH-5.2.1-1.cdh6.2.1.p0.12-el5.parcel
wget http://archive-primary.cloudera.com/cdh6/parcels/5.2.1/CDH-5.2.1-1.cdh6.2.1.p0.12-el5.parcel.sha1###.sha1文件后綴更改為.sha,同時把內容只保留hash碼部分
wget http://archive-primary.cloudera.com/cdh6/parcels/5.2.1/manifest.json
2.4在master[hadoop1] 節點安裝daemons、server、agent(先裝daemons)
wget http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.2.1/RPMS/x86_64/cloudera-manager-daemons-5.2.1-1.cm521.p0.109.el5.x86_64.rpm
wget http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.2.1/RPMS/x86_64/cloudera-manager-server-5.2.1-1.cm521.p0.109.el5.x86_64.rpm
wget http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.2.1/RPMS/x86_64/cloudera-manager-agent-5.2.1-1.cm521.p0.109.el5.x86_64.rpm
yum --nogpgcheck localinstall cloudera-manager-daemons-5.2.1-1.cm521.p0.109.el6.x86_64.rpm
yum --nogpgcheck localinstall cloudera-manager-server-5.2.1-1.cm521.p0.109.el6.x86_64.rpm
yum --nogpgcheck localinstall cloudera-manager-agent-5.2.1-1.cm521.p0.109.el6.x86_64.rpm(注:agent安裝需要聯網)
2.5在slave-1[hadoop2]、slave-2[hadoop3]節點安裝daemons、agent(先裝daemons)
wget http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.2.1/RPMS/x86_64/cloudera-manager-daemons-5.2.1-1.cm521.p0.109.el5.x86_64.rpm
wget http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.2.1/RPMS/x86_64/cloudera-manager-agent-5.2.1-1.cm521.p0.109.el5.x86_64.rpm
yum --nogpgcheck localinstall cloudera-manager-daemons-5.2.1-1.cm521.p0.109.el6.x86_64.rpm
yum --nogpgcheck localinstall cloudera-manager-agent-5.2.1-1.cm521.p0.109.el6.x86_64.rpm(注:agent安裝需要聯網)
2.6在master、slave-1、slave-2 節點安裝JDK、oraclejdk
rpm -ivh jdk-6u31-linux-amd64.rpm
3.在master節點安裝mysql 數據庫,并配置cdh需要的數據庫選項
yum install mysql-server mysql mysql-devel
chkconfig mysqld on
service mysqld start
mysql –u root
use mysql
update user set password=password('1234') where user='root'
update user set password=password('1234') where host='localhost'
update user set password=password('1234') where host='hadoop1'
service mysqld restart
mysql -u root -p1234
create database cloudera
4.在master節點配置cloudera manager 數據庫并啟動cm的server及agent程序
1.拷貝mysql-connector-java-5.1.7-bin.jar 到 /usr/share/java 下并重命名mysql-connector-java.jar
2.運行 /usr/share/cmf/schema/scm_prepare_database.sh -h hadoop1 mysql cloudera root 1234
3.啟動cm server :service cloudera-scm-server start
4.添加cm server服務 :chkconfig cloudera-scm-server on
5.啟動cm agent :chkconfig cloudera-scm-agent on
6.添加cm agent服務 :service cloudera-scm-server start
5、修改所有節點的agent 配置文件
/etc/cloudera-scm-agent/config.ini 將配置文件中的host 改成 cdh-master
6、在slave節點配置cloudera manager agent程序
1.啟動cm agent :chkconfig cloudera-scm-agent on
2.添加cm agent服務 :service cloudera-scm-agent start
7、測試agent和server是否通信成功
service cloudera-scm-server status
service cloudera-scm-agent status
netstat –anp | grep 7182
# server 端開啟的是7182端口,用于和agent進行通訊
啟動失敗時可以查看日志
server 日志 /var/log/cloudera-scm-server
agent 日志 /var/log/cloudera-scm-agent
8設置parcel[master]
mv CDH-5.2.1-1.cdh6.2.1.p0.12-el5.parcel /opt/cloudera/parcel-repo
[root@hadoop1 parcel-repo]# tail -5 manifest.json
"replaces": "IMPALA, SOLR, SPARK",
"hash": "7dcb31e557a7da951bfb6337e02b0b884aa3d2a2\n"
}
]
[root@hadoop1 parcel-repo]# tail -1 CDH-5.2.1-1.cdh6.2.1.p0.12-el5.parcel.sha1
7dcb31e557a7da951bfb6337e02b0b884aa3d2a2\n
[root@hadoop1 parcel-repo]# mv CDH-5.2.1-1.cdh6.2.1.p0.12-el5.parcel.sha1 CDH-5.2.1-1.cdh6.2.1.p0.12-el5.parcel.sha
9.[root@hadoop1 soft]# rpm -ivh oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm 所有節點
CDH集群安裝
CM安裝成功后瀏覽器輸入http://ip:7180,ip是CM安裝的主機ip或者主機名。顯示如下界面,用戶名和密碼都輸入admin,進入web管理界面。
免費版-〉繼續->查找并選擇需要安裝 CDH 的機器,點擊“繼續” 192.168.88.[11-13]->
二、卸載步驟
記錄卸載過程和問題。現有環境Cloudera Manager + (1 + 2 )的CDH環境。
1、先在Manage管理端移除所有服務。
2、刪除Manager Server
在Manager節點運行
/usr/share/cmf/uninstall-cloudera-manager.sh如果沒有該腳本,則可以手動刪除,先停止服務:
service cloudera-scm-server stop
service cloudera-scm-server-db stop然后刪除:
yum remove cloudera-manager-serversudo
yum remove cloudera-manager-server-db3 、刪除所有CDH節點上的CDH服務,先停止服務:
service cloudera-scm-agent hard_stop卸載安裝的軟件:
yum remove 'cloudera-manager-*' hadoop hue-common 'bigtop-*'4、刪除殘余數據:
rm -Rf /usr/share/cmf /var/lib/cloudera* /var/cache/yum/cloudera*
5、kill掉所有Manager和Hadoop進程(選作,如果你正確停止Cloud Manager和所有服務則無須此步)
$ for u in hdfs mapred cloudera-scm hbase hue zookeeper oozie hive impala flume; do sudo kill $(ps -u $u -o pid=); done6、刪除Manager的lock文件
在Manager節點運行:
rm /tmp/.scm_prepare_node.lock至此,刪除完成。
/var/log/cloudera-manager-installer/3.install-cloudera-manager-server.log
http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.2.1/RPMS/x86_64/
獲取鎖 卸載裝
Couldn't resolve host 'archive.cloudera.com'" dns8.8.8.8
注意主機名要與host一致,若不一致就刪掉,重新搜索
正在搜索要重新卸載,再安裝
[root@h02 soft]# service cloudera-scm-agent status
cloudera-scm-agent dead but pid file exists
[root@client ~]# cd /var/run
[root@client ~]# rm –f cloudera-scm-agent.pid
在日志中發現這樣一條錯誤信息:
ERROR ENGINE Error in HTTP server: shutting down Traceback (most recent call last)
IOError: [Errno 2] No such file or directory: '/var/lib/cloudera-scm-agent/uuid'
[root@h02 cloudera-scm-agent]# mkdir /var/lib/cloudera-scm-agent/
[root@h02 cloudera-scm-agent]# chmod 777 /var/lib/cloudera-scm-agent/
感謝各位的閱讀,以上就是“hadoop環境如何部署”的內容了,經過本文的學習后,相信大家對hadoop環境如何部署這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。