二十三 HDP搭建大資料環境
阿新 • • 發佈:2019-01-06
關閉Selinux
vi /etc/selinux/config
SELINUX=disabled
關閉防火牆
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
firewall-cmd --state
現在的epel源
[[email protected] ~]# yum install epel-release -y
[[email protected] ~]# cat /etc/hostname
master
[[email protected] ~]# cat /etc/hostname
master
[[email protected] ~]# yum install ntp -y
[[email protected] ~]# systemctl enable ntpd.service
[[email protected] ~]# systemctl start ntpd.service
[[email protected] ~]# ntpdate 0.centos.pool.ntp.org
[[email protected] ~]# yum install httpd -y
[[email protected] ~]# reboot
安裝httpd
[[email protected] ~]# yum install httpd -y
[[email protected] ~]# service httpd restart
[[email protected] ~]# chkconfig httpd on
安裝JDK
先解除安裝系統中自帶的JDK
[[email protected] ~]# rpm -qa | grep openjdk
java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64
java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.2.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64
[ [email protected] ~]# yum remove java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.2.el7.x86_64
[[email protected] ~]# yum remove java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64 -y
[[email protected] ~]# tar -zxvf jdk-8u171-linux-x64.tar.gz -C /usr/local/
vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_171
export PATH=.:$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[[email protected] ~]# source /etc/profile
[[email protected] ~]# java -version
SSH無金鑰登入
[[email protected] ~]# ssh-keygen
[[email protected] ~]# ssh-copy-id [email protected]
[[email protected] ~]# sudo sh -c "echo umask 0022 >> /etc/profile"
設定系統執行引數
設定swappiness
[[email protected] ~]# echo 10 > /proc/sys/vm/swappiness
禁用 透明大頁面壓縮
[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag
[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[[email protected] ~]#
全部主機
修改配置檔案/etc/sysctl.conf
kernel.shmmax= 1000000000
kernel.shmmni= 4096
kernel.shmall= 4000000000
kernel.sem= 250 512000 100 2048
kernel.sysrq= 1
kernel.core_uses_pid= 1
kernel.msgmnb= 65536
kernel.msgmax= 65536
kernel.msgmni= 2048
net.ipv4.tcp_syncookies= 0
net.ipv4.ip_forward= 0
net.ipv4.conf.default.accept_source_route= 0
net.ipv4.tcp_tw_recycle= 1
net.ipv4.tcp_max_syn_backlog= 200000
net.ipv4.conf.all.arp_filter= 1
net.ipv4.ip_local_port_range= 1281 65535
net.core.netdev_max_backlog= 200000
#java程式多時,設成2會導致很多服務不能去啟動!
#vm.overcommit_memory= 2
vm.overcommit_memory=0
fs.nr_open= 3000000
kernel.threads-max= 798720
kernel.pid_max= 798720
#increase network
net.core.rmem_max=2097152
net.core.wmem_max=2097152
[[email protected] ~]# sysctl -p
修改/etc/security/limits.conf設定開啟檔案數限制
vim /etc/security/limits.conf
* soft nofile 2900000
* hard nofile 2900000
* soft nproc 131072
* hard nproc 131072
重新登入以使配置生效,或者使用命令臨時設定
ulimit -n 10240
解壓HDP3.0軟體包到/var/www/html目錄下
[[email protected] html]# tar -zxvf /root/ambari-2.7.1.0-centos7.tar.gz -C .
[[email protected] html]# tar -zxvf /root/HDP-3.0.1.0-centos7-rpm.tar.gz -C ./hdp/
[[email protected] html]# tar -zxvf /root/HDP-GPL-3.0.1.0-centos7-gpl.tar.gz -C ./hdp/
[[email protected] html]# tar -zxvf /root/HDP-UTILS-1.1.0.22-centos7.tar.gz -C ./hdp/
/etc/yum.repos.d配置檔案
[[email protected] yum.repos.d]# cat ambari.repo
#VERSION_NUMBER=2.7.1.0-169
[ambari-2.7.1.0]
#json.url = http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json
name=ambari Version - ambari-2.7.1.0
baseurl=http://192.168.229.130/ambari/centos7/2.7.1.0-169/
gpgcheck=1
gpgkey=http://192.168.229.130/ambari/centos7/2.7.1.0-169/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[[email protected] yum.repos.d]# cat hdp.repo
#VERSION_NUMBER=3.0.1.0-187
[HDP-3.0.1.0]
name=HDP Version - HDP-3.0.1.0
baseurl=http://192.168.229.130/hdp/HDP/centos7/3.0.1.0-187
gpgcheck=1
gpgkey=http://192.168.229.130/hdp/HDP/centos7/3.0.1.0-187/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[HDP-UTILS-1.1.0.22]
name=HDP-UTILS Version - HDP-UTILS-1.1.0.22
baseurl=http://192.168.229.130/hdp/HDP-UTILS/centos7/1.1.0.22
gpgcheck=1
gpgkey=http://192.168.229.130/hdp/HDP/centos7/3.0.1.0-187/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
#VERSION_NUMBER=3.0.1.0-187
[HDP-GPL-3.0.1.0]
name=HDP-GPL Version - HDP-GPL-3.0.1.0
baseurl=http://192.168.229.130/hdp/HDP-GPL/centos7/3.0.1.0-187
gpgcheck=1
gpgkey=http://192.168.229.130/hdp/HDP-GPL/centos7/3.0.1.0-187/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[[email protected] yum.repos.d]#
使用剛才配置好的本地倉庫,直接yum命令安裝
[[email protected] ~]# yum install ambari-server -y
安裝mysql
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
rpm -ivh ./mysql57-community-release-el7-7.noarch.rpm
安裝聯結器yum install mysql-connector-java -y
rpm -ivh ./mysql-community-common-5.7.24-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-libs-5.7.24-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-libs-compat-5.7.24-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-client-5.7.24-1.el7.x86_64.rpm
rpm -ivh ./mysql-community-server-5.7.24-1.el7.x86_64.rpm
rpm -ivh mysql-connector-java-5.1.25-3.el7.noarch.rpm
啟動mysql,設定開機啟動
[[email protected] ~]# service mysqld start
[[email protected] ~]# vi /etc/rc.local
#新增service mysqld start
檢視mysql密碼
[[email protected] ~]# grep "temporary password" /var/log/mysqld.log
2019-01-05T07:07:14.924796Z 1 [Note] A temporary password is generated for [email protected]: ,hbjy*P7aB<O
[[email protected] ~]# mysql -uroot -p
Enter password:,hbjy*P7aB<O
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=3; #設定密碼長度最小為6個字元
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
設定mysql遠端連結
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
登入mysql ,執行下面的語句,建立ambari資料庫,為了在ambari-server安裝後啟動,否則報錯
mysql> create database ambari;
mysql> use ambari;
mysql> CREATE USER 'ambari'@'%' IDENTIFIED BY '123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
mysql> CREATE USER 'ambari'@'localhost' IDENTIFIED BY '123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'localhost';
mysql> CREATE USER 'ambari'@'master' IDENTIFIED BY '123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'master';
mysql> flush privileges;
mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
配置 ambari server
[[email protected] ~]# ambari-server setup
Customize user account for ambari-server daemon [y/n] (n)? n
Checking JDK...
[2] Custom JDK
==============================================================================
Enter choice (1): 2
Path to JAVA_HOME: /usr/local/jdk1.8.0_171
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? y
Enter advanced database configuration [y/n] (n)? y
==============================================================================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL / MariaDB
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
[7] - BDB
==============================================================================
Enter choice (1): 3
Hostname (localhost): master
Port (3306):
Database name (ambari): ambari
Username (ambari): root #採用root賬號超級許可權
Enter Database Password (bigdata): 123456 #採用root賬號超級許可權
Re-enter password: 123456 #採用root賬號超級許可權
Should ambari use existing default jdbc /usr/share/java/mysql-connector-java.jar [y/n] (y)? y
Proceed with configuring remote database connection properties [y/n] (y)? y
Adjusting ambari - server permissions and ownership...
Ambari Server 'setup' completed successfully.
[[email protected] ~]#
命令列方式設定mysql資料庫連結庫,用於oozie和range連結mysql時使用(如果上述操作不起作用,則需要採用下面操作)
[[email protected] ~]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
Using python /usr/bin/python
Setup ambari-server
Copying /usr/share/java/mysql-connector-java.jar to /var/lib/ambari-server/resources/mysql-connector-java.jar
If you are updating existing jdbc driver jar for mysql with mysql-connector-java.jar. Please remove the old driver jar, from all hosts. Restarting services that need the driver, will automatically copy the new jar to the hosts.
JDBC driver was successfully initialized.
Ambari Server 'setup' completed successfully.
[[email protected] ~]#
配置ambari-server自啟動,啟動ambari-server
[[email protected] ~]# systemctl enable ambari-server
[[email protected] ~]# systemctl start ambari-server
瀏覽器訪問ambari-server服務
http://192.168.229.130:8080 賬號admin密碼admin
登入之後不要動其它的,先安裝ambari-agent,否則後續會出現問題
所有主機節點,安裝ambari-agent,並配置自動啟動
[[email protected] ~]# yum install ambari-agent -y
[[email protected] ~]# systemctl enable ambari-agent
[[email protected] ~]# systemctl restart ambari-agent && systemctl status ambari-agent
如果出現問題,應該是hive和oozie資料庫沒有建立,則繼續安裝
建立oozie庫
mysql> create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
mysql> create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
參考文件