# 1 搭建準備 | HostName | IP | 記憶體 | CPU | 磁碟 | | | | | | | | cdp01 | 172.29.0.110 | 16G | 4核 | 100G | | cdp02 | 172.29.0.111 | 16G | 4核 | 100G | | cdp03 | ...
1 搭建準備
HostName | IP | 記憶體 | CPU | 磁碟 |
---|---|---|---|---|
cdp01 | 172.29.0.110 | 16G | 4核 | 100G |
cdp02 | 172.29.0.111 | 16G | 4核 | 100G |
cdp03 | 172.29.0.112 | 16G | 4核 | 100G |
組件 | 版本 |
---|---|
Cloudera Manager | 7.1.4 |
CDH | 7.1.7 |
OpenJDK | 1.8.0_372 |
CentOS | 7.6 |
MySQL | 8.0.34 |
2 基礎配置
2.1 hosts配置(所有主機)
- 編輯hosts文件
vim /etc/hosts
刪除原IP配置,填入以下內容172.29.0.110 cdp01 172.29.0.111 cdp02 172.29.0.112 cdp03
- 設置主機名稱
cdp01節點
hostnamectl set-hostname cdp01 && bash
cdp02節點
hostnamectl set-hostname cdp02 && bash
cdp03節點
hostnamectl set-hostname cdp03 && bash
2.2 關閉 Selinux(所有主機)
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2.3 關閉防火牆(所有主機)
systemctl stop firewalld
systemctl disable firewalld
2.4 設置swap(所有主機)
cat >> /etc/sysctl.conf <<EOF
vm.swappiness=1
EOF
2.5 設置 limits(所有主機)
cat >> /etc/security/limits.conf <<EOF
* soft nofile 65535
* hard nofile 65535
hdfs - nofile 32768
mapred - nofile 32768
hbase - nofile 32768
hdfs - noproc 32768
mapred - noproc 32768
hbase - noproc 32768
EOF
2.6 關閉透明大頁(所有主機)
vim /etc/rc.d/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
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 安裝ntpd服務(所有主機)
yum install -y ntp ntpdate
- cdp01 節點
vim /etc/ntp.conf
// 註:192.168.191.2 和 255.255.255.0是集群所在網段的網關和子網掩碼 restrict 192.168.191.2 mask 255.255.255.0 nomodify notrap server 127.127.1.0 fudge 127.127.1.0 stratum 8
- cdp02 節點
vim /etc/ntp.conf
restrict 192.168.191.2 mask 255.255.255.0 nomodify notrap server cdp02 prefer server 127.127.1.0 fudge 127.127.1.0 stratum 9
- cdp03 節點
vim /etc/ntp.conf
server cdp01 prefer server cdp02
- 在manager( cdp01 )啟動ntp之後,其餘各節點啟動ntp服務之前,master(cdp02 )和worker( cdp03 )節點執行命令,同步manager時間啟動 cdp01 節點ntpd服務
systemctl start ntpd systemctl enable ntpd
- 在cdp02、cdp03 節點進行時間同步
ntpdate cdp01
- 啟動cdp02、cdp03節點ntpd服務
systemctl start ntpd systemctl enable ntpd
- 查看ntp狀態
ntpq -p ’*’ 表示當前使用的時鐘源,’+’ 表示這些源可作為 NTP 源
2.8 安裝http服務(所有主機)
- 安裝httpd服務
yum install httpd -y
- 開啟httpd服務
systemctl start httpd.service
- 開機⾃動啟動httpd服務
chkconfig httpd on
2.9 配置SSH免密(cdp01節點)
- 在要免密登錄的主機上生成密鑰
ssh-keygen -t rsa # 一路回車
在~/.ssh目錄下創建兩個文件id_rsa(私鑰),id_rsa.pub(公鑰) - 將生成的公鑰發到要遠程連接的伺服器上
註:這一次需要輸入密碼,後面就不用了;如果主機未設置賬號密碼登錄需要先設置賬號密碼;配置後可以通過將/etc/ssh/sshd_config文件中的PasswordAuthentication yes修改為PasswordAuthentication no來關閉賬號密碼登錄ssh-copy-id cdp01 ssh-copy-id cdp02 ssh-copy-id cdp03
vim /etc/ssh/sshd_config 修改如下: PasswordAuthentication no 修改後使其生效: systemctl restart sshd
- 驗證免密登錄效果
ssh root@cdp02 退出輸入: exit
3 配置本地yum源
3.1 配置cm
- 安裝createrepo
yum install createrepo
- 下載cm軟體包
下載所需軟體包,如果下載慢可以自己下載然後上傳到伺服器mkdir -p /var/www/html/cm7.1.4 cd /var/www/html/cm7.1.4
wget -nd -r -l1 --no-parent https://archive.cloudera.com/cm7/7.1.4/redhat7/yum/RPMS/x86_64/ wget https://archive.cloudera.com/cm7/7.1.4/redhat7/yum/RPM-GPG-KEY-cloudera wget https://archive.cloudera.com/cm7/7.1.4/allkeys.asc
- 創建repo
createrepo .
- 下載cdh軟體包
下載所需軟體包,如果下載慢可以自己下載然後上傳到伺服器mkdir -p /var/www/html/cdh7.1.7 cd /var/www/html/cdh7.1.7
wget -nd -r -l1 --no-parent https://archive.cloudera.com/cdh7/7.1.7.0/parcels/
- 創建repo
createrepo .
- 配置本地yum源
配置以下內容:cd /etc/yum.repos.d vim cm7.repo
退出保存後,執⾏以下命令:[cm] name=cm,Version 7.1.4 baseurl=http://172.29.0.110/cm7.1.4/ enable=1 gpgcheck=0 [cdh] name=cdh baseurl=http://172.29.0.110/cdh7.1.7/ enable=1 gpgcheck=0
查看配置結果yum clean all yum makecache
可以看到以下內容:yum list |grep cloudera
可以通過外網地址查看配置結果//xxx.xxx.xxx.xxx為cdp01外網IP http://xxx.xxx.xxx.xxx/cm7.1.4/ http://xxx.xxx.xxx.xxx/cdh7.1.7/
- 分發到其他節點
在cdp01上配置好本地yum倉庫之後,將cm7.repo⽂件分發到其他節點/etc/yum.repos.d目錄
4 安裝jdk(所有主機)
yum -y install java-1.8.0-openjdk
5 安裝MySQL(cdp01)
5.1 安裝並啟用MySQL源
使用wget從MySQL網站下載MySQL源rpm文件:
cd /root/downloads/
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
使用rpm命令來安裝下載的rpm包:
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
檢查MySQL 8.0源已經成功添加到yum程式庫中:
yum repolist enabled | grep "mysql.*-community.*"
5.2 使用yum命令安裝MySQL 8.0
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-server
5.3 啟動並檢查MySQL伺服器
systemctl start mysqld
systemctl status mysqld
5.4 修改Root密碼
查找密碼並登陸Mysql
cat /var/log/mysqld.log | grep password
mysql -u root -p #輸入密碼
alter user root@localhost identified by '密碼';
FLUSH PRIVILEGES;
use mysql;
update user set host='%' where user = 'root';
commit;
exit;
5.5 my.cnf配置
vi /etc/my.cnf
#設置編碼為utf-8
character_set_server=utf8
init_connect='SET NAMES utf8'
5.6 重啟服務
systemctl stop mysqld
systemctl enable mysqld
systemctl start mysqld
5.7 創建CM元資料庫
CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'scm'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON scm.* TO 'scm'@'%';
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'amon'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON amon.* TO 'amon'@'%';
CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'rman'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON rman.* TO 'rman'@'%';
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'hue'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON hue.* TO 'hue'@'%';
CREATE DATABASE hive DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'hive'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON hive.* TO 'hive'@'%';
CREATE DATABASE ranger DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'rangeradmin'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON ranger.* TO 'rangeradmin'@'%';
CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'nav'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON nav.* TO 'nav'@'%';
CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'navms'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON navms.* TO 'navms'@'%';
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE USER 'oozie'@'%' IDENTIFIED BY '密碼';
GRANT ALL ON oozie.* TO 'oozie'@'%';
flush privileges;
6 安裝jdbc驅動(所有主機)
cd /root/downloads/
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
mkdir -p /usr/share/java
tar zxvf mysql-connector-java-5.1.46.tar.gz
scp mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar
scp mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar cdp02:/usr/share/java/mysql-connector-java.jar
scp mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar cdp03:/usr/share/java/mysql-connector-java.jar
7 安裝cm server(cdp01)
7.1 在cdp01上通過yum安裝Cloudera Manager Server
yum -y install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
7.2 安裝完後可以查看服務狀態
systemctl status cloudera-scm-server
7.3 初始化mysql
sudo /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm '之前設置的密碼'
7.4 啟動Cloudera Manager Server
systemctl start cloudera-scm-server.service
systemctl status cloudera-scm-server.service
7.5 檢查服務日誌,等待啟動完成
sudo tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
7.6 檢查埠是否監聽
netstat -nltp | grep 7180
7.7 訪問CM 創建集群
通過 http://cdp01:7180/ 訪問CM,輸⼊初始賬號密碼 admin/admin 即可登陸