1. 安裝前的準備 1.1 硬體要求 無特殊需求(根據Hadoop各個組件需求及實際情況,一般建議單個集群的機器數量在3台及以上:1台Master結點,2台機器作為Slave結點)。 1.2 軟體要求 1.2.1 操作系統 僅支持如下操作系統: Red Hat Enterprise Linux (R ...
1. 安裝前的準備
1.1 硬體要求
無特殊需求(根據Hadoop各個組件需求及實際情況,一般建議單個集群的機器數量在3台及以上:1台Master結點,2台機器作為Slave結點)。
1.2 軟體要求
1.2.1 操作系統
僅支持如下操作系統:
- Red Hat Enterprise Linux (RHEL) v5.x or 6.x (64-bit)
- CentOS v5.x or 6.x (64-bit)
- SUSE Linux Enterprise Server (SLES) 11, SP1 (64-bit)
1.2.2 瀏覽器
Ambari Web介面運行的瀏覽器需求如下:
Windows (Vista, 7)
- Internet Explorer 9.0 and higher
- Firefox latest stable release
- Safari latest stable release
- Google Chrome latest stable release
Mac OS X (10.6 or later)
- Firefox latest stable release
- Safari latest stable release
- Google Chrome latest stable release
Linux (RHEL, CentOS, SLES)
- Firefox latest stable release
- Google Chrome latest stable release
1.2.3 資料庫
Hadoop的一些組件需要用到傳統關係型資料庫。如MySQL,Derby,PostgreSQL。
1.3 安裝環境準備
1.3.1 地址映射
配置詳情 |
# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.31.3 <主機的全名,如john.smith> |
1.3.2 SSH無密碼登錄
確保ssh版本最新,sshd服務開啟。
配置詳情 |
1) 確認是否已經安裝ssh # rpm -qa | grep ssh # yum install ssh //上條命令無輸出時 2) 修改配置文件 # vi /etc/ssh/sshd_config RSAAuthentication yes # 啟用 RSA 認證 PubkeyAuthentication yes # 啟用公鑰私鑰配對認證方式 AuthorizedKeysFile .ssh/authorized_keys # 公鑰文件路徑 # service sshd restart //重啟sshd服務 3) 生成秘鑰 $ ssh-keygen -t rsa Tips:敲完命令,一直回車,直到命令結束生成如下類似的圖案
圖1-1 生成秘鑰
圖1-2 生成的秘鑰 4) 添加公鑰 $ cat .ssh/id_rsa >> .ssh/authorized_keys Tips:.ssh 700, authorized_keys 644
圖1-3 配置成功 |
1.3.3 關閉SELinux
命令:臨時關閉 |
# setenforce 0 |
命令:永久關閉 |
#vi /etc/selinux/config config: # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted |
1.3.4 關閉iptables
命令 |
#chkconfig iptables off #/etc/init.d/iptables stop |
1.3.5 關閉Packagekit
命令 |
#vi /etc/yum/pluginconf.d/refresh-packagekit.conf enabled=0 |
1.3.6 NTP
針對集群,需要一臺時間同步伺服器,確保集群時間同步,若差距太大,很多組件無法正常運行。
命令 |
# rpm -qa | grep ntp //查看是否已經安裝NTP # yum install ntp //安裝NTP # vi /etc/ntp.conf // restrict default kod nomodify notrap nopeer noquery 改為 restrict default nomodify // 添加/修改上一層時間同步伺服器 server 0.cn.pool.ntp.org server 0.asia.pool.ntp.org server 2.asia.pool.ntp.org # chkconfig ntpd on # service ntpd start |
1.3.7 卸載OpenJDK安裝Oracle JDK
命令 |
#rpm -qa | grep java #rpm -e --nodeps xxx #rpm -ivh xxx.rpm #vi /etc/profiles //配置 JAVA_HOME export JAVA_HOME=/xxx export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar #source /etc/profiles |
1.3.8 安裝、配置PostgreSQL或MySQL
PostgreSQL安裝命令 |
# wget https://download.postgresql.org/pub/repos/yum/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-8.noarch.rpm # rpm –ivh xxxx.rpm # vi /etc/yum.repos.d/ CentOS-Base.repo [base] … exclude=postgresql* [updates] … exclude=postgresql* # yum upgrade postgresql-libs # yum install postgresql92-server # service postgresql-9.2 initdb # service postgresql-9.2 start # psql -U postgres //修改配置文件/var/lib/pgsql/9.1/data/pg_hba.conf 將peer改為trust,將METHOD由預設的ident改為md5,再重啟服務 |
MySQL安裝、部署命令 |
# rpm -qa | grep mysql # rpm -e --nodeps mysql //卸載原有的MySQL # yum install -y mysql-server mysql mysql-devel # service mysqld start # chkconfig mysqld on //開機啟動mysqld服務 # mysqladmin -u root password 'root' //初始化資料庫root賬戶 |
1.3.9 安裝MySQL依賴
命令 |
# yum install mysql-connector-java # chmod 644 /usr/share/java/<mysql-connector-java.jar> |
1.3.10 UMASK
命令 |
#echo umask 0022 >> /etc/profile |
1.3.11 搭建本地庫
(1) 基本依賴組件安裝
命令 |
# yum install createrepo # yum install openssl # yum install nc # yum install redhat-lsb # yum install gcc # yum install python-devel # yum install python-libs |
(2) 下載相關文件
ITEMS |
URLS |
Ambari 2.2.2 |
http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.2.2.0/ ambari-2.2.2.0-centos6.tar.gz |
HDP 2.4 |
http://public-repo-1.hortonworks.com/HDP/centos6/2.x/ updates/2.4.2.0/HDP-2.4.2.0-centos6-rpm.tar.gz |
HDP-UTILS |
http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/ repos/centos6/HDP-UTILS-1.1.0.20-centos6.tar.gz |
(3) 安裝Apache httpd
命令 |
# yum install httpd # chkconfig --levels 235 httpd on # /etc/init.d/httpd start # mkdir -p /var/www/html/ambari # mkdir -p /var/www/html/hdp # mkdir -p /var/www/html/hdp-utils //打開瀏覽器,鍵入http://localhost會出現如下類似的頁面,錶面安裝並開啟成功。
|
(4) 解壓、配置repo文件
命令 |
# tar -zxvf ambari-2.2.2.0-centos6.tar.gz -C /var/www/html/ambari # tar -zxvf HDP-2.4.2.0-centos6-rpm.tar.gz -C /var/www/html/hdp # tar -zxvf HDP-UTILS-1.1.0.20-centos6.tar.gz -C /var/www/html/hdp-utils
# vi ambari.repo [Updates-ambari-2.2.2.0] name=ambari-2.2.2.0-Updates baseurl=http://192.168.31.3/ambari/AMBARI-2.2.2.0/centos6/2.2.2.0-460/ gpgcheck=1 gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
# vi hdp.repo [HDP-2.4.2.0] name=HDPVersion-HDP-2.4.2.0 baseurl=http://192.168.31.3/hdp/HDP/centos6/2.x/updates/2.4.2.0/ gpgcheck=1 gpgkey=http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.4.2.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
# vi hdp-utils.repo [HDP-UTILS-1.1.0.20] name=HDPUtilsVersion-HDP-UTILS-1.1.0.20 baseurl=http://192.168.31.3/hdp-utils/HDP-UTILS-1.1.0.20/repos/centos6/ gpgcheck=1 gpgkey=http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.4.2.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
# cp ambari.repo /etc/yum.repos.d/ # cp hdp.repo /etc/yum.repos.d/ # cp hdp-utils.repo /etc/yum.repos.d/
//打開編輯的鏈接,可以看到解壓出的文件已經掛在httpd上了。
|
2. Ambari組件安裝
2.1 Ambari server
命令 |
# yum install ambari-server # ambari-server start //啟動服務 # ambari-server status //狀態查看
//初始化資料庫(以MySQL為例) # mysql -u root -p mysql> CREATE USER '<AMBARIUSER>'@'%' IDENTIFIED BY '<AMBARIPASSWORD>'; mysql> GRANT ALL PRIVILEGES ON *.* TO '<AMBARIUSER>'@'%'; mysql> CREATE USER '<AMBARIUSER>'@'localhost' IDENTIFIED BY '<AMBARIPASSWORD>'; mysql> GRANT ALL PRIVILEGES ON *.* TO '<AMBARIUSER>'@'localhost'; mysql> CREATE USER '<AMBARIUSER>'@'<AMBARISERVERFQDN>' IDENTIFIED BY '<AMBARIPASSWORD>'; mysql> GRANT ALL PRIVILEGES ON *.* TO '<AMBARIUSER>'@'<AMBARISERVERFQDN>'; mysql> FLUSH PRIVILEGES;
# ambari-server setup //根據提示進行 //若以上安裝過程未能成功初始化ambari資料庫,則切換用戶,手動導入 Ambari的元數據 #mysql -u <AMBARIUSER> -p mysql> CREATE DATABASE <AMBARIDATABASE>; mysql> USE <AMBARIDATABASE>; mysql> SOURCE Ambari-DDL-MySQL-CREATE.sql;
註:<AMBARIUSER>,<AMBARIPASSWORD>,<AMBARISERVERFQDN>等在實際安裝的過程中應根據具體的情況替換。 |
2.2 Ambari Agent
Ambari agent 按安裝完Server之後,可以通過其WebUI進行安裝,但在WebUI上安裝成功率不高,可以通過手動安裝。
命令 |
# yum install ambari-agent -y # ambari-agent start # ambari-agent status //狀態查看 |
3. 大數據組件安裝
(1) 確保ambari-server 啟動,預設通過http://localhost:8080 登錄Ambari WebUI,預設的登錄密碼是admin/admin。界面如下圖所示:
(2) 登錄成功,準備安裝集群。
【聲明】轉載請註明出處