CDH集群搭建

0. 配置hostname

一定要在一开始就配置hostname,本人忽略了这一点,在集群安装好之后才进行配置hostname,多了很多不必要的操作,详见第11点

1. 修改网卡配置 vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.10.11.38 #本机地址
NETMASK=255.255.255.0 #子网掩码

2. DNS设置 vi /etc/resolv.conf

nameserver 114.114.114.114 #主
nameserver 8.8.8.8 #备

3. host映射配置 vim /etc/hosts

168.20.11.11 dev-cdh-db1
168.20.11.12 dev-cdh-db2
168.20.11.13 dev-cdh-db3

4. 配置ssh免密

//1.在主节点生成公钥文件
ssh-keygen -t rsa
//2.把公钥添加到认证文件中
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
//3.设置认证文件权限
chmod 600 ~/.ssh/authorized_keys
//4.拷贝认证文件到所有datanode节点
scp ~/.ssh/authorized_keys root@db1.cdh:~/.ssh/

5. 依赖包安装

  • vi dependency.sh #追加以下内容

yum -y install bind-utils
yum -y install chkconfig
yum -y install cyrus-sasl-gssapi
yum -y install cyrus-sasl-plain
yum -y install fuse
yum -y install fuse-libs
yum -y install gcc
yum -y install httpd
yum -y install init-functions
yum -y install libxslt
yum -y install mod_ssl
yum -y install MySQL-python
yum -y install openssl
yum -y install openssl-devel
yum -y install openssl-devel
yum -y install perl
yum -y install portmap
yum -y install postgresql-server
yum -y install psmisc
yum -y install python-devel
yum -y install python-psycopg2
yum -y install python-setuptools
yum -y install sed
yum -y install service
yum -y install sqlite
yum -y install swig
yum -y install useradd
yum -y install zlib

  • sh dependency.sh #每台机器执行

6. MYSQL安装配置

  • Install the MySQL database
//卸载
//1.快速删除
yum remove  mysql mysql-server mysql-libs mysql-server
//2.查找残留文件
rpm -qa | grep -i mysql
//3.将查询出来的文件逐个删除,如:
yum remove mysql-community-common-5.7.20-1.el6.x86_64
//4.查找残留目录
whereis mysql
//5.逐条删除目录,如:
rm –rf /usr/lib64/mysql
//安装
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm   
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm   
yum update   
sudo yum install mysql-server
//该步骤报错,如下图,解决方法如下:
//1.sudo vim /etc/yum.repos.d/mysql-community.repo
//2.找到mysql-56-community
//3.将enable置为0 enable=0
//4.sudo yum install mysql-server
sudo systemctl start mysqld 
image.png
  • Ensure the MySQL server starts at boot.

sudo /sbin/chkconfig mysqld on
sudo /sbin/chkconfig --list mysqld

  • Start the MySQL serverStart the MySQL server

sudo service mysqld start

  • Set the MySQL root password

sudo /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:
Re-enter new password:
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!
  • Installing the MySQL JDBC Driver
> Download the MySQL JDBC driver from http://www.mysql.com/downloads/connector/j/5.1.html 
sudo mkdir -p /usr/share/java/ 
scp mysql-connector-java-5.1.47.tar.gz root@168.20.11.13:/usr/share/java
 tar zxvf mysql-connector-java-5.1.31.tar.gz 
//版本号要去掉
mv /usr/share/java/mysql-connector-java-8.0.11.jar /usr/share/java/mysql-connector-java.jar
// Creating Databases need
create database amon DEFAULT CHARACTER SET utf8;
create database rman DEFAULT CHARACTER SET utf8;
create database metastore DEFAULT CHARACTER SET utf8;
create database sentry DEFAULT CHARACTER SET utf8;
create database nav DEFAULT CHARACTER SET utf8;
create database navms DEFAULT CHARACTER SET utf8;
create database cms DEFAULT CHARACTER SET utf8;
create database oozie default character set utf8;
create database hue default character set utf8 default collate utf8_general_ci;
grant all on amon.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on rman.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on metastore.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on sentry.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on nav.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on navms.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on hue.* TO 'cdh'@'%' IDENTIFIED BY ‘cdhroot’;
grant all on cms.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all privileges on oozie.* to 'cdh'@'localhost' identified by 'cdhroot';
grant all privileges on oozie.* to 'cdh'@'%' identified by 'cdhroot';

7. 安装JDK

java安装目录最好在/usr/java/下面,下面是具体范围
local JAVA8_HOME_CANDIDATES=(
'/usr/java/jdk1.8'
'/usr/java/jre1.8'
'/usr/lib/jvm/j2sdk1.8-oracle'
'/usr/lib/jvm/j2sdk1.8-oracle/jre'
'/usr/lib/jvm/java-8-oracle'
)

  • Download the JDK
  • mkdir -p /usr/java
  • 直接把解压的安装包放在/usr/java下面
  • scp jdk-8u191-linux-x64.tar.gz root@168.20.11.13:/usr/java
  • tar zxvf jdk-8u191-linux-x64.tar.gz
  • 配置环境变量

vi /etc/profile //末尾追加下面内容:
export JAVA_HOME=/usr/java/jdk1.8.0_191
export PATH=JAVA_HOME/bin:PATH

  • source /etc/profile

8. 安装CDH

  • Download and Extract Tarballs
  1. Download tarballs from the locations listed in Cloudera Manager Version and Download Information(https://www.cloudera.com/documentation/enterprise/release-notes/topics/cm_vd.html#cmvd_topic_1)
  2. sudo mkdir /opt/cloudera-manager
  3. scp cloudera-manager-centos7-cm5.15.1_x86_64.tar.gz root@168.20.11.12:/opt/cloudera-manager
  4. sudo tar xzf cloudera-manager*.tar.gz -C /opt/cloudera-manager
  • Create user on all host

sudo useradd --system --home=/opt/cloudera-manager/cm-5.15.1/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm

  • Create the Cloudera Manager Server Local Data Storage Directory
sudo mkdir /var/lib/cloudera-scm-server   
sudo chown cloudera-scm:cloudera-scm /var/lib/cloudera-scm-server
  • Configure Cloudera Manager Agents
vi /opt/cloudera-manager/cm-5.15.1/etc/cloudera-scm-agent/config.ini
server_host  //Name of the host where Cloudera Manager Server is running.
server_port  //Port on the host where Cloudera Manager Server is running.
  • 设置agent数据目录

vim /opt/cloudera-manager/cm-5.15.1/etc/default/cloudera-scm-agent

export CMF_VAR=/cluster/cdh/cdhdata export CMF_AGENT_ROOT=$CMF_ROOT/lib64/cmf
export CMF_SERVER_ROOT=$CMF_ROOT/share/cmf
export CMF_SBINDIR=$CMF_ROOT/sbin
export CMF_ETC=$CMF_ROOT/etc
export CMF_VAR=/cluster/cdh/cdhdata   #只改了这一行
export CMF_SUDO_CMD=" "

mkdir -p /cluster/cdh/cdhdata/log/cloudera-scm-agent/
mkdir -p /cluster/cdh/cdhdata/lib/cloudera-scm-agent/

  • Create Parcel Directories

//On the Cloudera Manager Server host, create a parcel repository directory:
sudo mkdir -p /opt/cloudera/parcel-repo
sudo chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
//On each cluster host, create a parcels directory:
sudo mkdir -p /opt/cloudera/parcels
sudo chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
//同步Agent到其他节点
//同步主节点的agent到从节点时候一定要在主节点启动agent之前同步过去,不然会导致uuid不一致问题
scp -r /opt/cloudera-manager/cm-5.15.1 root@otherip:/opt/cloudera-manager

  • 下载parcels并放在server在的机器

//ps: http://archive.cloudera.com/cdh5/parcels/ #下载以下三个文件
CDH-5.15.2-1.cdh5.14.2.p0.3-el7.parcel
CDH-5.14.2-1.cdh5.14.2.p0.3-el7.parcel.sha
manifest.json manifest.json
//将这三个文件放到/opt/cloudera/parcel-repo/ #只需在server的那台机器操作

9. 初始化数据库

在server那台机器操作
/opt/cloudera-manager/cm-5.15.1/share/cmf/schema/scm_prepare_database.sh mysql cm -h 168.20.11.14 -u root -p --scm-host 168.20.11.14scm scm scm

10. 运行agent 和 server

sh /opt/cloudera-manager/cm-5.15.1/etc/init.d/cloudera-scm-server start
sh /opt/cloudera-manager/cm-5.15.1/etc/init.d/cloudera-scm-agent start

11. 未配置hostname,建好集群之后配置hostname相关操作

切记:在一开始就应该配置好hostname

1.停止集群
2.vi /etc/hosts
3.vi /etc/sysconfig/network

4.vi /etc/hostname
5.在cdh机器上面进入mysql,mysql -uroot -p000000
6.mysql>use cm;
7.mysql>select host_id, host_identifier, name, ip_address from HOSTS;
8.mysql> update HOSTS set name = 'cdh1.dev' where host_id=4;
9.mysql> select config_id,attr,value from CONFIGS where value like '%dev-statis%';
10.mysql>update CONFIGS set value = 'cdh2.dev' where config_id=162;
11.重启网卡:service network restart
12.输入hostname 看出现的主机名是否是期待的主机名
13.如果修改后没有更新,reboot 重启机器即可

12. 单独安装spark2.1

1.创建目录:mkdir -p /opt/cloudera/csd
2.修改该权限及组:chown cloudera-scm:cloudera-scm /opt/cloudera/csd
3.scp /Users/slash/Downloads/SPARK2_ON_YARN-2.1.0.cloudera1.jar root@168.20.11.14:/opt/cloudera/csd
4.修改组用户权限:
chown cloudera-scm:cloudera-scm SPARK2_ON_YARN-2.1.0.cloudera2.jar

  • 上传parcel包,在每台机器执行

SPARK2-2.1.0.cloudera1-1.cdh5.7.0.p0.120904-el6.parcel
SPARK2-2.1.0.cloudera1-1.cdh5.7.0.p0.120904-el6.parcel.sha
manifest.json

  • 启动CDH集群
  • 然后点击主机->Parcel页面,看是否多了个spark2的选项。如下图,你这里此时应该是分配按钮,点击,等待操作完成后,点击激活按钮
  • 激活后,点击你的群集->添加服务,添加spark2服务。注意,如果你这里看不到spark2服务,就请检查你的CSD包和parcel包是否对应,上面的步骤是否有漏掉。正常情况下,应该是能用了。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,076评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,658评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,732评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,493评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,591评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,598评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,601评论 3 415
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,348评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,797评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,114评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,278评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,953评论 5 339
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,585评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,202评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,442评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,180评论 2 367
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,139评论 2 352

推荐阅读更多精彩内容