Cloudera Manager 和CDH6.0.1安裝,解除安裝,各步驟截圖(此博文為筆者辛苦勞作最終生成的,使用了3個熬到凌晨2~4點的夜晚,外加一個週末完成,請轉載時記錄轉載之處,謝謝)
1 Cloudera 文件總地址
https://www.cloudera.com/documentation/enterprise/6/6.0.html
2 Cloudera Manager 和CDH下載地址
Cloudera Manager下載地址:
https://archive.cloudera.com/cm6/6.0.1/redhat7/yum/RPMS/x86_64/
下載上線的rpm,然後把這些檔案放到/root目錄下
CDH下載地址:
https://archive.cloudera.com/cdh6/6.0.1/parcels/,需要下載以下檔案: CDH-6.0.1-1.cdh6.0.1.p0.590678-el7.parcel CDH-6.0.1-1.cdh6.0.1.p0.590678-el7.parcel.sha256 manifest.json
以上三個檔案放到/opt/cloudera/parcel-repo/目錄下,如果沒有此目錄,可以自己手動建立。
此外在下面的官網介紹中:
https://www.cloudera.com/documentation/enterprise/6/release-notes/topics/rg_cm_6_version_download.html
裡面有
Cloudera Manager Release Notes
Cloudera Installation Guide
Gloudera Enterprise Upgrade Guide
Repositories Type Location (baseurl) Repo File RHEL 7 Compatible https://archive.cloudera.com/cm6/6.0.1/redhat7/yum/ cloudera-manager.repo
3 閱讀Introduction中的CDH
閱讀以下章節
4 安裝CDH 6.0.1叢集
以下安裝過程分別參考:http://www.cnblogs.com/piperck/p/9944469.html 和 官網
4.1 軟體環境
作業系統
[[email protected] ~]# uname -a Linux hadoop15 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
機器配置
要注意的是,不同角色的機器,記憶體可以配置不一樣,一般做Master節點的機器所需要的記憶體要多一些
IP 記憶體 作業系統 角色
192.168.106.155 12G Centos7.4 Server + agent
192.168.106.156 9G Centos7.4 Agent
192.168.106.157 8G Centos7.4 Agent
192.168.106.151 1.5G Centos7.4 mysql
4.2 安裝CDH 的準備工作
4.2.1 安裝wget
yum -y install wget
4.2.2 更新安裝vim,安裝vim增強包
yum -y install vim-enhanced
4.2.3 配置host和hostname
官網介紹:
配置域名相關,因為只有三臺機器組叢集,所以直接使用了hosts的方法,參考官網地址可以是:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/configure_network_names.html
1.配置在叢集中的每個節點的host
A:105機器
[[email protected] ~]# hostnamectl set-hostname cdh1
B:106機器
[[email protected] ~]# hostnamectl set-hostname cdh2
C:107機器
[[email protected] ~]# hostnamectl set-hostname cdh3
檢查hostname
[[email protected] ~]# hostname
cdh1
[[email protected]localhost ~]# hostname
cdh2
[[email protected] ~]# hostname
cdh2
2、編輯/etc/hosts
參考網址:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/configure_network_names.html,三臺機器配置成下面相同的配置:
[[email protected] etc]# cat /etc/hosts
192.168.106.155 cdh1
192.168.106.156 cdh2
192.168.106.157 cdh3
3、編輯/etc/sysconfig/network
參考地址:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/configure_network_names.html
[[email protected] ~]# vim /etc/sysconfig/network
[[email protected] ~]# cat /etc/sysconfig/network
HOSTNAME=cdh1
[[email protected] ~]# vim /etc/sysconfig/network
[[email protected] ~]# cat /etc/sysconfig/network
HOSTNAME=cdh2
[[email protected] ~]# vim /etc/sysconfig/network
[[email protected] ~]# cat /etc/sysconfig/network
HOSTNAME=cdh3
驗證配置
uname –a 需要和 hostname 得到一致的域名
修改前:
修改後:
4.2.4 設定防火牆
參考文章:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/install_cdh_disable_iptables.html
1.儲存存在的iptables規則設定(略)
2.禁用iptables (centos7發現沒有),替代的是firewalled
停止: systemctl disable firewalld
禁用: systemctl stop firewalld
4.2.5 設定SELinux
vim /etc/sysconfig/selinux
SELINUX=enforcing 改為 SELINUX=disabled
或使用如下配置:
1.檢查SELinux的狀態
[[email protected] etc]# getenforce
Disabled
[[email protected] etc]#
2.如果輸出是Permissive或者Disabled,你可以跳過此任務,然後開始下面的操作
3.開啟/etc/selinux/config檔案,在一些系統中,是/etc/sysconfig/selinux 檔案
4.修改檔案中的SELINUX=enforcing為SELINUX=permissive
筆者配置如下:
5.儲存和關閉這個檔案
6.重啟系統或者使用下面的命令立即停止SELinux
$ setenforce 0
當你已經安裝部署了CDH之後,你可以在/etc/selinux/config(或/etc/sysconfig/selinux 檔案)通過改變SELINUX=permissive為SELINUX=enforcing重新啟用SELINUX,接著執行下面的命令快速切換到enforcing模式
setenforce 1
4.2.6 啟用NTP
文件地址:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/install_cdh_enable_ntp.html
CDH需要你在叢集中的每個機器中配置Network Time Protocal(NTP)服務,在開機的時候自動重啟NTP。在你的叢集中執行下面的每個步驟。
1. 安裝NTP
相容RHEL的命令:
yum install ntp
2. 配置NTP
官網此處的配置,筆者沒有配置
A:配置NTP
vim /etc/ntp.conf
master配置:(選用復旦大學ntp伺服器)
slave配置:(同步master)
B:開啟NTP服務
service ntpd start
chkconfig ntpd on
C:檢視同步效果
命令:ntpstat
4.2.7 安裝Hue所需的Python2.7
1.安裝Software Collections Library (3個節點都執行以下命令)
yum install centos-release-scl
2.安裝Software Collections utilities (3個節點都執行以下命令)
yum install scl-utils
3.安裝Python 2.7 (3個節點都執行以下命令)
yum install python27
4.驗證python2.7已經被安裝了
[[email protected] ~]# source /opt/rh/python27/enable
[[email protected] ~]# python --version
Python 2.7.13
4.2.8 3臺機器間設定SSH免密
在cdh1,cdh2,cdh3下執行
ssh-keygen -t rsa (這個過程一直打enter)
ssh-copy-id cdh1
ssh-copy-id cdh2
ssh-copy-id cdh3
執行完成之後,分別執行
ssh cdh1
ssh cdh2
ssh cdh3
如果不需要再進行密碼設定,說明免密設定已經完成了
4.3 安裝Cloudera Manager和CDH
4.3.1 安裝JDK
關於JDK要求:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/cdh_ig_jdk_installation.html
這裡使用oracle-j2sdk1.8,此步驟略,按照官網進行安裝
Jdk要求:
A:JDK必須是64位的,不要使用32位的
B:每個叢集節點都要安裝
C:JDK必須安裝在/usr/java/jdk-version.
yum install oracle-j2sdk1.8
如果下載了這個jdk,直接使用:
rpm -ivh oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm
4.3.2 為Clouder Manager配置一個Repository (如果已經下載了Cloudera Manager,此步驟可以忽略)
參考文章:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/configure_cm_repo.html
http://www.cnblogs.com/piperck/p/9944469.html
首先Cloudera為使用者準備好了專用的程式倉庫,需要下載下來
wget https://archive.cloudera.com/cm6/6.0.0/redhat7/yum/cloudera-manager.repo -P /etc/yum.repos.d/
# Import the repository signing GPG key
rpm --import https://archive.cloudera.com/cm6/6.0.0/redhat7/yum/RPM-GPG-KEY-cloudera
4.3.3 安裝Cloudera Manager Package
參考地址:https://www.cloudera.com/documentation/enterprise/6/6.0/topics/install_cm_server.html
在下面這些步驟中,在Cloudera Manager機器(cdh1)上安裝Cloudera Manager Packages,選擇啟用 自動-TLS
4.3.3.1 Install Cloudera Manager Packages
A:在Cloudera Manager伺服器上,鍵入下面的命令安裝Cloudera Manager
OS 命令
RHEL, CentOS, Oracle Linux : sudo yum install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
SLES : sudo zypper install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
Ubuntu : sudo apt-get install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
B:如果你為Cloudera Manager使用的是Oracle database,在Cloudera Manager伺服器上編輯/etc/default/cloudera-scm-server檔案。定位到以export CMF_JAVA_OPTS的一行,改變-Xmx2G為-Xmx4G
如果網速不行,可以先下好Cloudera Manager和CDH。下載地址是:
Cloudera Manager: https://archive.cloudera.com/cm6/6.0.1/redhat7/yum/RPMS/x86_64/
CDH下載地址:https://archive.cloudera.com/cdh6/6.0.1/parcels/
即:
https://archive.cloudera.com/cdh6/6.0.1/parcels/
需要下載的內容是:
cloudera-manager-agent-6.0.1-610811.el7.x86_64.rpm
cloudera-manager-daemons-6.0.1-610811.el7.x86_64.rpm
cloudera-manager-server-6.0.1-610811.el7.x86_64.rpm
jdk
oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm
將以上安裝檔案可以放到/root目錄下
關於安裝:
Master節點(cdh1):
yum -y install cloudera-manager-agent cloudera-manager-daemons cloudera-manager-server
Node節點(cdh2,cdh3):
yum -y install cloudera-manager-agent cloudera-manager-daemons
本地安裝:
(網路好的話,可以忽略此步驟。)
cloudera-manager-agent-6.0.1-610811.el7.x8664.rpm
cloudera-manager-daemons-6.0.1-610811.el7.x8664.rpm
cloudera-manager-server-6.0.1-610811.el7.x8664.rpm
先安裝 cloudera-manager-daemons-6.0.1-610811.el7.x8664.rpm 再安裝其他的。
先安裝下面的內容,因為cloudera-manager-agent依賴這些
yum install bind-utils psmisc cyrus-sasl-plain cyrus-sasl-gssapi portmap httpd mod_ssl openssl-devel python-psycopg2 MySQL-python /lib/lsb/init-functions
cdh1上執行以下命令:
rpm -ivh cloudera-manager-daemons-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-agent-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-server-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-server-db-2-6.0.1-610811.el7.x86_64.rpm
cdh2,cdh3上執行以下命令:
rpm -ivh cloudera-manager-daemons-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-agent-6.0.1-610811.el7.x86_64.rpm
4.3.3.2 啟用Auto-TLS以自動建立證書
JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera /opt/cloudera/cm-agent/bin/certmanager --location /opt/cloudera/CMCA setup --configure-services
4.3.3.3 安裝mysql
參考:https://blog.csdn.net/Sky_WANGJ/article/details/84030458
參考:http://www.cnblogs.com/piperck/p/9944469.html
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-release-el7-5.noarch.rpm
yum -y update
yum -y install mysql-server
*.Move old InnoDB log files /var/lib/mysql/iblogfile0 and /var/lib/mysql/iblogfile1 out of /var/lib/mysql/ to a backup location.
rm -rf /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile1
啟動mysql
systemctl enable mysqld
systemctl start mysqld
初始化Mysql
/usr/bin/mysql_secure_installation
[...]
Enter current password for root (enter for none):
OK, successfully used password, moving on...
[...]
Set root password? [Y/n] Y
New password:root
Re-enter new password:root
Remove anonymous users? [Y/n] Y
[...]
Disallow root login remotely? [Y/n] N
[...]
Remove test database and access to it [Y/n] Y
[...]
Reload privilege tables now? [Y/n] Y
All done!
4.3.3.4 安裝MySQL JDBC驅動程式
wget https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
tar zxvf mysql-connector-java-5.1.46.tar.gz
#要注意的是後面的名字必須是mysql-connector-java.jar(可以將下面的jar包放到3臺機器上)
cp mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar
4.3.3.5 必須配置資料庫支援MySQL UTF8字符集編碼
mysql -u root -p root
create database scm default character set utf8 default collate utf8_general_ci;
grant all on scm.* to 'scm'@'%' identified by 'root';
create database amon default character set utf8 default collate utf8_general_ci;
grant all on amon.* to 'amon'@'%' identified by 'root';
create database rman default character set utf8 default collate utf8_general_ci;
grant all on rman.* to 'rman'@'%' identified by 'root';
create database hue default character set utf8 default collate utf8_general_ci;
grant all on hue.* to 'hue'@'%' identified by 'root';
create database metastore default character set utf8 default collate utf8_general_ci;
grant all on metastore.* to 'hive'@'%' identified by 'root';
create database sentry default character set utf8 default collate utf8_general_ci;
grant all on sentry.* to 'sentry'@'%' identified by 'root';
create database nav default character set utf8 default collate utf8_general_ci;
grant all on nav.* to 'nav'@'%' identified by 'root';
create database oozie default character set utf8 default collate utf8_general_ci;
grant all on oozie.* to 'oozie'@'%' identified by 'root';
CREATE DATABASE activity_monitor DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON activity_monitor.* TO 'activity_monitor'@'%' IDENTIFIED BY 'root';
flush privileges;
筆者的如下:
建立完成之後檢視資料庫:
禁用透明大頁面壓縮(cdh1,cdh2,cdh3上都執行)
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
並將上面的兩條命令寫入開機自啟動
vim /etc/rc.local
優化交換分割槽
vim /etc/sysctl.conf
vm.swappiness = 10
sysctl -p /etc/sysctl.conf
其它
echo never>/sys/kernel/mm/transparent_hugepage/defrag
echo never>/sys/kernel/mm/transparent_hugepage/enabled
4.3.3.6 設定Cloudera Manager資料庫
mysql在本地時執行:
rm -rf /etc/cloudera-scm-server/db.mgmt.properties
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm
如果不在一臺機器上,執行類似如下命令(cdh2為mysql所在位置,cdh1為cloudera manager server所在位置):
[[email protected] cloudera-scm-server]# /opt/cloudera/cm/schema/scm_prepare_database.sh mysql -h 192.168.106.151 --scm-host cdh1 scm scm
[[email protected] cloudera-scm-server]# /opt/cloudera/cm/schema/scm_prepare_database.sh mysql -h 192.168.106.151 --scm-host cdh1 scm scm
Enter SCM password:
JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.8.0_141-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/opt/cloudera/cm/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
[[email protected] cloudera-scm-server]#
上面過程中需要輸入scm的密碼,在上面的資料庫建立語句中scm的密碼被設定成了root,所以在此處也同樣設定scm的密碼為root
啟動Cloudera Manager Server
將CHD6相關的Parcel包放到主節點的/opt/cloudera/parcel-repo/目錄中,如果沒有此目錄,可以自己建立。(如果是線上安裝,那麼此步驟可以忽略。)
注意:
最後將CDH-6.0.1-1.cdh6.0.1.p0.590678-el7.parcel.sha256,重新命名為CDH-6.0.1-1.cdh6.0.1.p0.590678-el7.parcel.sha,這點必須注意,否則系統會重新下載CDH-6.0.1-1.cdh6.0.1.p0.590678-el7.parcel。
存放了CDH和修改了HASH之後,設定Cloudera Manager資料庫,啟動Cloudera Manager Server,然後登入Cloudera Manager Admin Console:
啟動Cloudera Manager Server:
systemctl start cloudera-scm-server
可以檢視啟動日誌
tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
看到此條資訊,說明啟動完成
INFO WebServerImpl:com.cloudera.server.cmf.WebServerImpl: Started Jetty server.
要注意的是,在上傳完上面的CDH之後,要在manifest.json 中找到CDH-6.0.1-1.cdh6.0.1.p0.590678-el7.parcel ,然後找到上面的hash值,即:
將2e650f1f1ea020a3efc98a231b85c2df1a50b030 替換掉CDH-6.0.1-1.cdh6.0.1.p0.590678-el7.parcel.sha 中的內容
登入
在Web瀏覽器中,轉到 http://cdh1:7180/cmf/login,其中域名是執行Cloudera Manager Server的主機的FQDN或IP地址。
如果有啟用自動TLS,則會重定向到https: cdh1:7183,並顯示安全警告。你可能需要表明你信任該證書,或單擊以繼續執行Cloudera Manager Server主機。
登入Cloudera Manager Admin Console。預設憑據為:
Username: admin
Password: admin
進入之後
點選第一個免費的即可
如果出現下面的錯誤:
網路上說的解決辦法,參考:https://yq.aliyun.com/articles/578871。然後筆者使用了之後並不成功。最後定位到是上面各章節的配置沒有配置好導致的,需要驗證:網路是否通,各機器之間是否能夠ssh免密,hostname,hosts等是否設定的正確,網路防火牆是否按照博文敘述進行配置。(為此,筆者重新虛擬過3遍3個叢集,熬了3個到凌晨2,3點的夜晚)。所以在配置過程中一定要細心又細心。
最後:
5 解除安裝Cloudera Manager
systemctl stop cloudera-scm-server
systemctl stop cloudera-scm-agent
yum -y remove 'cloudera-manager-*'
yum clean all
umount cm_processes
umount /var/run/cloudera-scm-agent/process
rm -Rf /usr/share/cmf /var/lib/cloudera* /var/cache/yum/cloudera* /var/log/cloudera* /var/run/cloudera*
rm -rf /tmp/.scmpreparenode.lock
rm -Rf /var/lib/flume-ng /var/lib/hadoop* /var/lib/hue /var/lib/navigator /var/lib/oozie /var/lib/solr /var/lib/sqoop* /var/lib/zookeeper
rm -Rf datadrivepath/dfs datadrivepath/mapred datadrivepath/yarn
systemctl stop mysqld
yum -y remove mysql
rm -rf /var/lib/mysql
rm -rf /var/log/mysqld.log
rm -rf /var/lib/mysql/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/share/mysql
rm -rf /opt/cloudera
rpm -qa | grep -i mysql
解除安裝MySQL相關的檔案。
6 Cloudera Manager重啟,停止等涉及到的相關問題
發現如果是通過rpm -ivh *.rpm方式安裝的軟體,在機器重啟之後,CM和CDH自動重啟了。
如果發現沒有自動重啟或為了保險起見,啟動Cloudera Manager和cdh的方式如下:
以下,第一行命令在cdh1上執行。第二行在所有的節點上執行
systemctl stop cloudera-scm-server
systemctl stop cloudera-scm-agent
(cdh1上執行)
systemctl start cloudera-scm-server
(cdh1,cdh2,cdh3上都執行)
systemctl start cloudera-scm-agent
[[email protected] init.d]# ps -ef | grep cloudera-scm-server (在CDH上執行)
檢視CM的日誌:
[[email protected] init.d]# tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
檢視日誌,然後一直等待到其啟動完畢,大約要等待3~5分鐘左右,然後在瀏覽器中輸入:http://cdh1:7180/cmf/login