所有节点安装必要的工具包:
yum -y install net-tools vim ntp libaio
1. 所有节点配置禁用SELinux
vi /etc/selinux/config
SELINUX=disabled
2. 关闭集群所有节点防火墙
systemctl stop firewalld
systemctl disable firewalld
3. 所有节点设置swap
echo vm.swappiness = 10 >> /etc/sysctl.conf
sysctl vm.swappiness=10
4. 所有节点设置文件打开最大数
vi /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
* soft nproc 32000
* hard nproc 32000
5. centos7默认启用透明大页面压缩,可能会导致重大性能问题,所以先关闭透明大页面压缩
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
6. 所有节点都要配置hosts文件追加如下配置
vi /etc/hosts
172.16.102.170 centos170
172.16.102.171 centos171
172.16.102.172 centos172
172.16.102.173 centos173
前面六步在所有节点上执行完成后, reboot 所有机器;再接着配置下面步骤
二. 继续配置相关的准备环境
1. 设置免秘钥登录(在部署CM服务的机器上配置)
ssh-keygen
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
ssh-copy-id -i ~/.ssh/id_rsa.pub root@centos171
ssh-copy-id -i ~/.ssh/id_rsa.pub root@centos172
ssh-copy-id -i ~/.ssh/id_rsa.pub root@centos173
测试是否免秘钥成功, 输入:ssh centos171 如果正常切换到171机器说明成功
chmod 600 /root/.ssh/authorized_keys
2. 时钟同步
CM服务所在节点上如下配置:
vi /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 172.16.102.0 mask 255.255.255.0 notrap nomodify
server 210.72.145.44 perfer # 中国国家受时中心
server 202.112.10.36 # 1.cn.pool.ntp.org
server 59.124.196.83 # 0.asia.pool.ntp.org
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 nomodify notrap noquery
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
其他slaver上如下配置(注意只需要配置server 为对应的CM服务所在的IP即可):
vi /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 172.16.102.0 mask 255.255.255.0 notrap nomodify
server 172.16.102.170
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
以系统时间为基准,修改硬件时间(所有节点):
hwclock --systohc
启动ntpd服务(所有节点)
systemctl restart ntpd.service
随便找个slaver节点执行结果如下,证明时钟同步配好了;
3. JDK安装
将所有安装软件上传到 /home/soft 目录下
tar -xvf jdk-7u79-linux-x64.tar.gz -C /usr/local/
vi /etc/profile
环境变量中追加如下配置:
export JAVA_HOME=/usr/local/jdk1.7.0_79
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
让环境变量生效:
source /etc/profile
执行java -version 显示如下效果,表示jdk配置成功;
同理所有节点都配置好JDK
3. 安装mysql 在CM服务节点上
centos7默认安装了MariaDB; 先卸载MariaDB
查看MariaDB安装包: rpm -qa | grep mariadb
卸载MariaDB: rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
tar -xvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/ /usr/local/mysql
cd /usr/local/mysql/
mkdir data logs pid
创建mysql用户组,创建之后,可以查看是否创建成功
groupadd mysql
cat /etc/group|grep mysql
useradd -r -g mysql mysql
赋权,更改所属的组和用户
chown -R mysql.mysql /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld
编辑mysqld,修改为指定路径
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
vi /etc/my.cnf 修改配置文件如下(basedir为安装目录,datadir为数据文件目录):
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
socket=/tmp/mysql.sock
character-set-server=utf8
collation-server=utf8_general_ci
[mysqld_safe]
log-error=/usr/local/mysql/logs/mariadb.log
pid-file=/usr/local/mysql/pid/mariadb.pid
chown -R mysql.mysql /usr/local/mysql/logs
chown -R mysql.mysql /usr/local/mysql/pid
touch /usr/local/mysql/logs/mariadb.log
chown -R mysql.mysql /usr/local/mysql/logs/mariadb.log
配置mysql环境变量
vi /etc/profile
##mysql
export MYSQL=/usr/local/mysql
export PATH=$PATH:$MYSQL/bin
使环境变量生效:
source /etc/profile
执行数据库初始化操作:
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
特别注意初始化时候控制台最后一行生成一个初始化密码,如下所示:
service mysqld restart
mysql -uroot -p
root用户登录后使用上面的初始化密码登录后修改root密码
mysql> SET PASSWORD = PASSWORD('123456');
mysql> flush privileges;
使用新密码登录:
mysql -uroot -p123456
添加远程访问权限
mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
重启使得配置生效:
/etc/init.d/mysqld restart
配置开机启动mysql服务:
chkconfig mysqld on
以上所有步骤完成后,即可开始安装CDH
1、所有节点安装依赖包:
yum install chkconfig python bind-utils psmisc libxslt zlib sqlite cyrus-sasl-plain cyrus-sasl-gssapi fuse fuse-libs redhat-lsb -y
2、主节点安装CM5.15.0
tar -xvf cloudera-manager-centos7-cm5.15.0_x86_64.tar.gz -C /opt
scp mysql-connector-java-5.1.37-bin.jar /opt/cm-5.15.0/share/cmf/lib/
3.在主节点初始化数据库
/opt/cm-5.15.0/share/cmf/schema/scm_prepare_database.sh mysql cm -hcentos170 -uroot -p123456 --scm-host centos170 scm scm scm
4.agent配置
vi /opt/cm-5.15.0/etc/cloudera-scm-agent/config.ini
修改server_host为主节点的主机名: server_host= centos170
同步Agent到其他所有节点:
scp -r /opt/cm-5.15.0/ centos171:/opt
scp -r /opt/cm-5.15.0/ centos172:/opt
scp -r /opt/cm-5.15.0/ centos173:/opt
在所有节点创建cloudera-scm用户:
useradd --system --home=/opt/cm-5.15.0/run/cloudera-scm-server/ --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
将CHD5相关的Parcel包放到所有节点的/opt/cloudera/parcel-repo/目录中(parcel-repo需要手动创建)。
相关的文件如下:
CDH-5.15.0-1.cdh5.15.0.p0.21-el7.parcel
CDH-5.15.0-1.cdh5.15.0.p0.21-el7.parcel.sha1
manifest.json
最后将CDH-5.15.0-1.cdh5.15.0.p0.21-el7.parcel.sha1,重命名CDH-5.15.0-1.cdh5.15.0.p0.21-el7.parcel.sha,这点必须注意,否则,系统会重新下载CDH-5.15.0-1.cdh5.15.0.p0.21-el7.parcel文件。
cp mysql-connector-java-5.1.37-bin.jar /opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/lib/hadoop/lib/native/
cp mysql-connector-java-5.1.37-bin.jar /opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/lib/hadoop/lib/
相关启动脚本
主节点:通过/opt/cm-5.15.0/etc/init.d/cloudera-scm-server start启动服务端。
所有节点(包括主节点):通过/opt/cm-5.15.0/etc/init.d/cloudera-scm-agent start启动Agent服务。
CM启动结束后即可访问:http://172.16.102.170:7180
用户名、密码都为admin
选择免费版
继续
选择所有主机
继续, 这个过程比较耗时
选择自定义服务里面的zookeeper 继续
如下配置
继续
如下配置成功 继续
如下表示zookeeper服务配置成功;
添加HDFS服务
如下配置
添加yarn 服务
继续
继续添加spark服务
至此所有的服务已经全部搭建起来了
三 . 后期集群优化方面
vi /opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/etc/spark/conf.dist/spark-env.sh
export SPARK_DIST_CLASSPATH=$(hadoop classpath)
export JAVA_HOME=/usr/local/jdk1.7.0_79