文檔編寫目的
CDP DC是Cloudera與Hortonworks合併後,第一個融合CDH和HDP所有組件的on-premise版本,CDP Data Center主要由Cloudera Runtime構成,Cloudera Runtime由超過35個開源項目組成,當然CDP Data Center還包括其它功能如管理功能Cloudera Manager,Key Management,專業支持等,如下圖所示:
Cloudera Runtime的主要組件版本如下圖所示:
本文檔Fayson主要描述如何在Redhat7.8安裝CDP DC7.1.2。CDP DC7與CDH5/6的安裝步驟一致,主要包括以下四部分:
1.安全前置準備,包括安裝操作系統、關閉防火牆、同步服務器時鐘等;
2.外部數據庫如MySQL安裝
3.安裝Cloudera Manager;
4.安裝CDH集羣;
- 測試環境
1.CM和CDH版本為7.1.2
2.Redhat7.8
3.OpenJDK1.8
4.MariaDB-5.5.64
5.root用户安裝
前置準備
2.1 hostname及hosts配置
集羣中各個節點之間能互相通信使用靜態IP地址。IP地址和主機名通過/etc/hosts配置,主機名通過/etc/hostname進行配置。
以cm節點(172.24.27.124)為例:
1.hostname配置,建議你將hostname配置為有意義的字母或單詞組合,比如cdp01,請不要使用localhost作為主機名,也不要使用下劃線或者其它特殊字符作為主機名。/etc/hostname文件示例如下:
[root@fayson0001 ~]# cat /etc/hostnamefayson00012.hosts配置需要將集羣的所有主機都加入進來,包括客户端節點,管理節點和工作節點。/etc/hosts文件示例如下:
[root@fayson0001 ~]# cat /etc/hosts::1 localhost localhost.localdomain localhost6 localhost6.localdomain6127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4172.24.27.124 fayson0001172.24.27.121 fayson0002172.24.27.123 fayson0003172.24.27.122 fayson0004以上兩步操作,在集羣中其它節點做相同配置。確認CM的hosts文件已經同步到集羣所有節點:
2.2禁用SELinux
在所有節點執行setenforce 0 命令,此處使用批處理shell執行:
[root@fayson0001 shell]# sh ssh_do_all.sh node.list ''setenforce 0''集羣所有節點修改/etc/selinux/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 - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted2.3關閉防火牆
集羣所有節點執行 systemctl stop命令,此處通過shell批量執行命令如下:
[root@fayson0001 shell]# sh ssh_do_all.sh node.list ''systemctl stop firewalld'' [root@fayson0001 shell]# sh ssh_do_all.sh node.list ''systemctl disable firewalld'' [root@fayson0001 shell]# sh ssh_do_all.sh node.list ''systemctl status firewalld''2.4集羣時鐘同步
在Redhat7.x的操作系統上,已經默認的安裝了chrony,我們這裏先卸載chrony,然後安裝ntp。使用ntp來配置各台機器的時鐘同步,將cm(172.24.27.124)服務作為本地ntp服務器,其它3台服務器與其保持同步。
1.所有機器卸載chrony
[root@fayson0001 shell]# sh ssh_do_all.sh node.list ''yum -y remove chrony''2.所有機器安裝ntp
[root@fayson0001 shell]# sh ssh_do_all.sh node.list ''yum -y install ntp''3.cm機器配置時鐘與自己同步
[root@ fayson0001 shell]# vim /etc/ntp.conf #server 0.rhel.pool.ntp.org iburst #server 1.rhel.pool.ntp.org iburst #server 2.rhel.pool.ntp.org iburst #server 3.rhel.pool.ntp.org iburst server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 104.集羣其它節點,配置找cm機器去同步
[root@ip-172-31-11-232 ~]# vim /etc/ntp.conf #server 0.rhel.pool.ntp.org iburst #server 1.rhel.pool.ntp.org iburst #server 2.rhel.pool.ntp.org iburst #server 3.rhel.pool.ntp.org iburst server 172.24.27.1245.重啓所有機器的ntp服務
[root@ fayson0001 shell]# sh ssh_do_all.sh node.list ''systemctl restart ntpd'' [root@ fayson0001 shell]# sh ssh_do_all.sh node.list ''systemctl enable ntpd'' [root@ fayson0001 shell]# sh ssh_do_all.sh node.list ''systemctl status ntpd''6.驗證始終同步,在所有節點執行ntpq -p命令,如下使用腳本批量執行
[root@fayson0001 shell]# sh ssh_do_all.sh node.list ''ntpq -p''左邊出現*號表示同步成功。
2.5設置swap
1.在所有機器執行以下命令以臨時設置swap為1,並即時生效
sh ssh_do_all.sh node.list ''sysctl -a | grep vm.swappiness'' sh ssh_do_all.sh node.list ''echo 1 > /proc/sys/vm/swappiness'' sh ssh_do_all.sh node.list ''sysctl -a | grep vm.swappiness''確保最後swap打印應該都為1
2.為所有機器永久設置swap為1,修改/etc/sysctl.conf中vm.swappiness為1,沒有則新增。
[root@fayson0001 ~]# vim /etc/sysctl.conf vm.swappiness = 1將/etc/sysctl.conf文件同步到集羣所有機器
2.6設置透明大頁面
1.所有節點執行以下命令關閉透明大頁面,並即時生效
sh ssh_do_all.sh node.list ''echo never > /sys/kernel/mm/transparent_hugepage/defrag'' sh ssh_do_all.sh node.list ''echo never > /sys/kernel/mm/transparent_hugepage/enabled'' sh ssh_do_all.sh node.list ''cat /sys/kernel/mm/transparent_hugepage/enabled'' sh ssh_do_all.sh node.list ''cat /sys/kernel/mm/transparent_hugepage/defrag''2.修改所有節點的/etc/rc.d/rc.local文件的權限以實現開機執行
[root@fayson0001 shell]# sh ssh_do_all.sh node.list ''chmod +x /etc/rc.d/rc.local'' [root@fayson0001 shell]# sh ssh_do_all.sh node.list ''ls -l /etc/rc.d/rc.local''3.在所有節點的/etc/rc.d/rc.local文件中新增如下內容,以實現開機自動關閉透明大頁面。
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi將該文件同步到所有節點
2.7配置操作系統repo
Fayson用的是AWS的環境,這步是可以省略的,放在這裏供物理機部署的兄弟們參考。
1.掛載操作系統iso文件
[root@fayson0001 ~]$ sudo mkdir /media/DVD1 [root@fayson0001 ~]$ sudo mount -o loop CentOS-7-x86_64-DVD-1611.iso /media/DVD1/2.配置操作系統repo
[root@fayson0001 ~]$ sudo vim /etc/yum.repos.d/local_os.repo [local_iso] name=CentOS-$releasever - Media baseurl=file:///media/DVD1 gpgcheck=0 enabled=1 [root@fayson0001 ~]$ sudo yum repolist2.8安裝httpd服務
1.安裝httpd服務
[root@fayson0001 shell]# yum -y install httpd2.啓動httpd服務
[root@fayson0001 shell]# systemctl start httpd3.安裝完httpd後,重新制作操作系統repo,換成http的方式方便其它服務器也可以訪問
[root@fayson0001 ~]$ mkdir /var/www/html/iso [root@fayson0001 ~]$ scp -r /media/DVD1/* /var/www/html/iso/ [root@fayson0001 ~]$ vim /etc/yum.repos.d/os.repo [osrepo] name=os_repo baseurl=http:// 172.31.2.24/iso/ enabled=true gpgcheck=false [root@fayson0001 ~]$ yum repolist4.修改/etc/httpd/conf/httpd.conf配置文件,在
5.保存httpd.conf的修改,並重啓httpd服務
[root@fayson0001 java]# systemctl restart httpd2.9安裝MariaDB
1.安裝MariaDB
[root@fayson0001 ~]# yum -y install mariadb [root@fayson0001 ~]# yum -y install mariadb-server2.啓動並配置MariaDB
[root@fayson0001 ~]# systemctl start mariadb [root@fayson0001 ~]# systemctl enable mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. [root@fayson0001 ~]# /usr/bin/mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n ... skipping. By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!3.建立CM,Hive等需要的表
[root@fayson0001 shell]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 9 Server version: 5.5.64-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]> create database metastore default character set utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> CREATE USER 'hive'@'%' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON metastore. * TO 'hive'@'%'; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> create database cm default character set utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> CREATE USER 'cm'@'%' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON cm. * TO 'cm'@'%'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> create database rm default character set utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> CREATE USER 'rm'@'%' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON rm. * TO 'rm'@'%'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> create database hue default character set utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> CREATE USER 'hue'@'%' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON hue. * TO 'hue'@'%'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> create database ranger default character set utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> CREATE USER 'rangeradmin'@'%' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON ranger. * TO 'rangeradmin'@'%'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)4.安裝JDBC驅動
[root@fayson0001 shell]# mkdir -p /usr/share/java/ [root@fayson0001 shell]# cd [root@fayson0001 ~]# mv mysql-connector-java-5.1.34.jar /usr/share/java/ [root@fayson0001 ~]# cd /usr/share/java [root@fayson0001 java]# chmod 777 mysql-connector-java-5.1.34.jar [root@fayson0001 java]# ln -s mysql-connector-java-5.1.34.jar mysql-connector-java.jar [root@fayson0001 java]# ll total 940 -rwxrwxrwx 1 root root 960372 Aug 10 23:09 mysql-connector-java-5.1.34.jar lrwxrwxrwx 1 root root 31 Aug 10 23:10 mysql-connector-java.jar -> mysql-connector-java-5.1.34.jarCloudera Manager安裝
3.1配置本地repo源
1.下載CM7.1.2的安裝包,地址為:
https://archive.cloudera.com/cm7/7.1.1/redhat7/yum/RPMS/x86_64/cloudera-manager-agent-7.1.1-3274282.el7.x86_64.rpm https://archive.cloudera.com/cm7/7.1.1/redhat7/yum/RPMS/x86_64/cloudera-manager-daemons-7.1.1-3274282.el7.x86_64.rpm https://archive.cloudera.com/cm7/7.1.1/redhat7/yum/RPMS/x86_64/cloudera-manager-server-7.1.1-3274282.el7.x86_64.rpm https://archive.cloudera.com/cm7/7.1.1/redhat7/yum/RPMS/x86_64/cloudera-manager-server-db-2-7.1.1-3274282.el7.x86_64.rpm https://archive.cloudera.com/cm7/7.1.1/redhat7/yum/RPMS/x86_64/enterprise-debuginfo-7.1.1-3274282.el7.x86_64.rpm https://archive.cloudera.com/cm7/7.1.1/redhat7/yum/RPMS/x86_64/openjdk8-8.0+232_9-cloudera.x86_64.rpm https://archive.cloudera.com/cm7/7.1.1/allkeys.asc2.下載CDH7.1.2的安裝包,地址為:
https://archive.cloudera.com/cdh7/7.1.1/parcels/CDH-7.1.1-1.cdh7.1.1.p0.3266817-el7.parcel https://archive.cloudera.com/cdh7/7.1.1/parcels/CDH-7.1.1-1.cdh7.1.1.p0.3266817-el7.parcel.sha256 https://archive.cloudera.com/cdh7/7.1.1/parcels/manifest.json3.將Cloudera Manager安裝需要的6個rpm包以及一個asc文件下載到本地,放在同一目錄,執行createrepo命令生成rpm元數據。
[root@fayson0001 cm7.1.2]# createrepo .4.配置Web服務器
將上述cdp7.1.2/cm7.1.2目錄移動到/var/www/html目錄下, 使得用户可以通過HTTP訪問這些rpm包。
[root@fayson0001 ~]# mv cm7.1.2/ cdp7.1.2/ /var/www/html/ [root@fayson0001 ~]# cd /var/www/html/ [root@fayson0001 html]# ll *7.1.2驗證瀏覽器能否正常訪問
5.製作Cloudera Manager的repo源
[root@fayson0001 yum.repos.d]# vim cm.repo [cmrepo] name = cm_repo baseurl = http://172.24.27.124/cm7.1.2 enable = true gpgcheck = false [root@fayson0001 yum.repos.d]# yum repolist6.驗證安裝JDK
[root@fayson0001 yum.repos.d]# yum -y install openjdk8-8.0+232_9-cloudera.x86_643.2安裝Cloudera Manager Server
1.通過yum安裝Cloudera Manager Server
[root@fayson0001 java]# yum -y install cloudera-manager-server2.初始化數據庫
[root@fayson0001 java]# /opt/cloudera/cm/schema/scm_prepare_database.sh mysql cm cm password3.啓動Cloudera Manager Server
[root@fayson0001 ~]# systemctl start cloudera-scm-server [root@fayson0001 ~]# systemctl status cloudera-scm-server4.檢查端口是否監聽
[root@fayson0001 ~]# netstat -lnpt | grep 7180 tcp 0 0 0.0.0.0:7180 0.0.0.0:* LISTEN 22048/java5.通過http://cm_ip:7180/cmf/login訪問CM
注意:完全啓動成功需要幾分鐘時間。
CDH安裝
4.1CDH集羣安裝嚮導
1.admin/admin登錄到CM,選擇60天試用,點擊繼續
2.點擊繼續
3.點擊“繼續”,輸入集羣名稱,可以使用默認的“Cluster 1”。
4.輸入主機IP或者名稱,點擊搜索找到主機後點擊繼續
5.選擇自定義存儲庫,輸入cm的http地址
“CDH and other software”中選擇“Parcel Repositories & Network Settings”,點擊“ 更多選項”,點擊“-”刪除其它所有地址,輸入http://172.31.2.24/cdp7.1.2,點擊“保存更改”
點擊Save & Verify Configuration,驗證通過,點擊關閉
點擊“繼續”
6.選擇Install a Cloudera-provided version of OpenJDK,點擊繼續
7.進入下一步配置ssh賬號密碼,確保所有機器的root密碼都一致,然後輸入root的密碼即可。
8.點擊“繼續”,進入下一步,安裝Cloudera Manager相關到各個節點
等待Agent安裝完畢後,自動跳轉到下一步開始分發Parcel
9.點擊“繼續”,進入下一步安裝cdh到各個節點
10.點擊Inspect Network Performance和Inspect Hosts,檢查主機
如果有錯誤或者黃色警告,查看“顯示檢查器結果”,並逐項解決,然後“重新運行”檢查,直到所有的檢查都通過,否則沒辦法點擊繼續下一步。
4.2集羣設置安裝嚮導
1.選擇需要安裝的服務,根據需要選擇,這裏選擇自定義服務
2.點擊“繼續”,進入集羣角色分配,一台機器作為管理節點,另外三台機器作為DataNode
注意:Activity Monitor和Telemetry Publisher不用選擇任何主機,留空,即不安裝,因為用不到。
3.點擊“繼續”,進入下一步,測試數據庫連接
4.測試成功,點擊繼續。設置Range相關參數。
以下4個密碼,都需要包含至少一個字母與一個數字,為了安裝方便都輸入admin@123
點擊繼續
5.進入目錄設置,此處使用默認目錄,根據實際情況進行目錄修改.
6.點擊“繼續”,進入各個服務啓動
7.安裝成功後進入home管理界面
4.3組件版本檢查
可以看到Hadoop3.1.1,HBase2.2,Hive3.1,Spark2.4,Hue4.5,Impala3.2,Kafka2.4,Kudu1.12,Oozie5.1,Solr8.4,Sqoop1.4.7,Zookeeper3.5.5等。
總結
1.從安裝方式上來看,CDP DC7.1.2與CDH6變化不大,這也方便了CDH的用户可以較為快速的遷移到CDP DC7,以及適應CDP DC7的安裝與使用。
2.安裝條件前置沒有任何變化,包括防火牆,SELinux關閉,ntp同步等等。可以參考Fayson之前的文章《CDH安裝前置準備》
3.Cloudera Manager自帶的JDK直接提供的是OpenJDK1.8,而不是Oracle JDK,同樣CDP DC也不再支持JDK1.7。
4.與安裝CDH6一樣,CM的安裝除了下載rpm包以外,還要下載allkeys.asc文件,否則安裝agent的時候會報錯。
5.對於離線安裝CDH6.x,分發Parcel出現hash校驗失敗的問題,是因為在CM6中修復了一個bug,讓它不再忽略由http服務器發送的“Content-Encoding”的header信息,但是我們在Redhat中安裝的httpd服務,當它傳輸parcel文件時,默認會錯誤的設置“Content-Encoding”。於是CM server會錯誤的認為parcel文件已經被httpd壓縮並嘗試解壓縮。所以會導致失敗。解決辦法是參考2.8章節的,設置httpd的conf文件,AddType application/x-gzip .gz .tgz .parcel,然後重啓httpd服務和CM服務。這個問題在beta的時候就已經存在了,具體請參考《0350-Redhat7.4安裝CDH6.0_beta1時分發Parcel異常分析》
6.在創建元數據庫時,不需要再創建Navigator和Sentry相關的元數據庫,但需要創建Ranger服務相關的元數據庫。安裝Hue時Oozie服務也不是必須的,所以也可以不創建Oozie數據庫。
7.第一次啓動Ranger服務時,創建x_portal_user表時會報以下錯誤:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytesSQLException : SQL state: 42000 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes ErrorCode: 10712019-11-24 01:12:06,672 [E] ranger_core_db_mysql.sql file import failed!這是因為索引建立的時候,字符長度超過255,由於utf-8字符最長只能為255,超長之後會報錯,所以需要對MySQL做如下配置:
SET GLOBAL innodb_file_per_table = ON, innodb_file_format = Barracuda, innodb_large_prefix = ON;參考:
https://stackoverflow.com/questions/29676724/1071-specified-key-was-too-long-max-key-length-is-767-bytes【來源:科技圈裏那些事Y】
聲明:轉載此文是出於傳遞更多信息之目的。若有來源標註錯誤或侵犯了您的合法權益,請作者持權屬證明與本網聯繫,我們將及時更正、刪除,謝謝。 郵箱地址:[email protected]