CDH5.16安装

文章目录

  • 安装步骤
    • 一、硬件准备
    • 二、软件准备
    • 三、准备环境
      • 查看linux版本
      • 关闭 selinux
      • 安装 ntp
      • 禁用防火墙
      • 安装 JDK
      • 网络设置
    • 四、MySQL 安装(主节点)
    • 五、集群安装
        • 安装 CM
        • 安装 CDH
    • 调优

安装步骤

一、硬件准备


阿里三台 4h32g云主机

外网
39.102.36.162
39.102.37.229
39.102.38.17

内网:
172.17.96.141 master
172.17.96.140 slave01
172.17.96.142 slave01

网关:
172.17.111.253


二、软件准备

系统环境:

CentOS7.6
cloudera-manager-centos7-cm5.16.2_x86_64.tar.gz(Cloudera Manager安装包)
CDH-5.16.2-1.cdh5.16.2.p0.8-el7.parcel.sha1
CDH-5.16.2-1.cdh5.16.2.p0.8-el7.parcel(CDH离线资源包)
manifest.json
mysql5.7.29
mysql-connector-java-5.1.33-bin.jar
Jdk 1.8

下载mysq
mysql-5.7.29

https://dev.mysql.com/downloads/mysql/5.7.html
Linux - Generic
mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
634.0M

下载mysql连接驱动:

https://mvnrepository.com/artifact/mysql/mysql-connector-java
mysql-connector-java-5.1.33

下载JDK:

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
jdk-8u121-linux-x64.tar.gz

下载CDH相关包:

http://archive.cloudera.com/cm5/cm/5/
cloudera-manager-centos7-cm5.16.2_x86_64.tar.gz
http://archive.cloudera.com/cdh5/parcels/latest/
CDH-5.16.2-1.cdh5.16.2.p0.8-el7.parcel
CDH-5.16.2-1.cdh5.16.2.p0.8-el7.parcel.sha1
manifest.json

三、准备环境

查看linux版本

[root@srv /]# more /etc/redhat-release

关闭 selinux

setenforce 0 # 须先禁用后面才能关闭防火墙
vi /etc/selinux/config
SELINUX=disabled

安装 ntp

 yum install -y ntp
 systemctl enable ntpd

先不要启动。后面配置完免密后启动
 systemctl start ntpd

禁用防火墙

systemctl disable firewalld

安装 JDK

查询已安装jdk(各种方法)

rpm -qa | grep jdk
java -v
whereis java
which java (java执行路径)

删除旧版

rpm -e --no-deps package-name

解压至/usr/java/

mkdir /usr/java
tar -zxvf /usr/jdk-8u161-linux-x64.tar.gz -C /usr/java

设置环境变量

vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH 
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 

环境生效
source /etc/profile
重启(可能不需要)
reboot

网络设置

ip(阿里云上都分配好了静态地址,跳过)

vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
BOOTPROTO=static      # 静态ip
ONBOOT=yes            # 开机启动
IPADDR=172.17.96.141  # ip 地址
PREFIX=24             # 子网掩码
GATEWAY=172.17.111.253   # 网关

hostname

vi /etc/sysconfig/network
HOSTNAME=cdh1.zt.com

hosts

vi /etc/hosts
172.17.96.141 cdh1.zt.com cdh1
172.17.96.140 cdh2.zt.com cdh2
172.17.96.142 cdh3.zt.com cdh3

ssh (主节点)

生成 key
ssh-keygen -t rsa

 拷贝到其他节点
ssh-copy-id cdh2
ssh-copy-id cdh3

ntp
主节点

vi /etc/ntp.conf
#先注释掉所有server
#192.168.2.0 和 255.255.255表示客户端网段和子网掩码
restrict 192.168.2.0 mask 255.255.255.0  nomodify notrap
server  127.127.1.0 # 以本机作为服务器
fudge   127.127.1.0     stratum 10

systemctl start ntpd

子节点

vi /etc/ntp.conf
#先注释掉所有server
server cdh1.hnzst.com

systemctl start ntpd

date来看看时间一样不

四、MySQL 安装(主节点)

删除旧版

rpm -qa | grep mysql
rpm -e --no-deps packagename

安装依赖

yum install -y libaio

解压

tar -zxvf /usr/mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz  -C /usr/local/

软链接

ln -s /usr/local/mysql-5.7.29-linux-glibc2.12-x86_64/ /usr/local/mysql

创建用户和组

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

环境变量

vi /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin

生效环境变量

source /etc/profile.d/mysql.sh

修改配置

vi /etc/my.cnf
[mysqld]
# It is important that the datadir directory, which, by default, is /var/lib/mysql,
# is on a partition that has sufficient free space.
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
transaction-isolation = READ-COMMITTED
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
symbolic-links = 0

key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1

max_connections = 550
#expire_logs_days = 10
#max_binlog_size = 100M

#log_bin should be on a disk with enough free space.
#Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your
#system and chown the specified folder to the mysql user.
log_bin=/var/lib/mysql/mysql_binary_log

#In later versions of MySQL, if you enable the binary log and do not set
#a server_id, MySQL will not start. The server_id must be unique within
#the replicating group.
server_id=1

binlog_format = mixed

read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M

# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit  = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M

character-set-server=utf8mb4
collation-server=utf8mb4_general_ci

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

sql_mode=STRICT_ALL_TABLES

[mysql]
default-character-set=utf8mb4

[client]
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8mb4

数据目录初始化

mysqld --initialize-insecure --user=mysql

服务脚本

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

重启

reboot

设置开机自启动

systemctl enable mysql

启动

systemctl start mysql

修改root密码

登录 MySQL

mysql -u root --skip-password

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

设置root访问权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
flush privileges;

jdbc

mkdir /usr/share/java/
cp /data/cdh5.16.2/mysql-connector-java-5.1.33.jar  /usr/share/java/mysql-connector-java.jar

五、集群安装

安装 CM

解压文件

tar -zxvf /data/cdh5.16.2/cloudera-manager-centos7-cm5.16.2_x86_64.tar.gz -C /data/opt/

添加用户(所有节点)

useradd --system \
--home=/data/opt/cm-5.16.2/run/cloudera-scm-server \
--no-create-home \
--shell=/bin/false \
--comment "Cloudera SCM User" \
cloudera-scm

创建 CM 服务本地数据存储目录

mkdir /data/var/lib/cloudera-scm-server -p
chown cloudera-scm:cloudera-scm /data/var/lib/cloudera-scm-server

配置 Agent

vi /data/opt/cm-5.16.2/etc/cloudera-scm-agent/config.ini
server_host=cdh1.hnzst.com

创建 Parcel 目录

mkdir -p /data/opt/cloudera/parcel-repo/
chown cloudera-scm:cloudera-scm /data/opt/cloudera/parcel-repo/
mkdir -p /data/opt/cloudera/parcels
chown cloudera-scm:cloudera-scm /data/opt/cloudera/parcels/

创建 CM 初始数据库

/data/opt/cm-5.16.2/share/cmf/schema/scm_prepare_database.sh -uroot -p mysql scm scm scm

同步 cm 到其他节点

scp -r /data/opt/cm-5.16.2 cdh2:/data/opt/cm-5.16.2
scp -r /data/opt/cm-5.16.2 cdh3:/data/opt/cm-5.16.2

安装 CDH

安装 perl

yum  install -y perl

拷贝 parcels

cp /data/cdh5.16.2/CDH-5.16.2-1.cdh5.16.2.p0.8-el7.* /data/cdh5.16.2/manifest.json /data/opt/cloudera/parcel-repo/
# xxx.sha1 须重命名为 xxx.sha
mv /opt/cloudera/parcel-repo/CDH-5.16.2-1.cdh5.16.2.p0.8-el7.parcel.sha1 /opt/cloudera/parcel-repo/CDH-5.16.2-1.cdh5.16.2.p0.8-el7.parcel.sha

启动 server (主节点)

/data/opt/cm-5.16.2/etc/init.d/cloudera-scm-server start

启动 agents (所有节点)

/data/opt/cm-5.16.2/etc/init.d/cloudera-scm-agent start

swappiness(所有节点)

sysctl vm.swappiness=0
echo "vm.swappiness=0" >> /etc/sysctl.conf

最大透明(所有节点)

vi /etc/rc.d/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

给权限
chmod +x /etc/rc.d/rc.local

服务化配置(可选)(以下,未测试验证)

主节点

cp /opt/cm-5.16.2/etc/init.d/cloudera-scm-server /etc/init.d/
vi /etc/init.d/cloudera-scm-server
CMF_DEFAULTS=${CMF_DEFAULTS:-/opt/cm-5.16.2/etc/default}

所有节点(包括主节点)

cp /opt/cm-5.16.2/etc/init.d/cloudera-scm-agent /etc/init.d/
vi /etc/init.d/cloudera-scm-agent
CMF_DEFAULTS=${CMF_DEFAULTS:-/opt/cm-5.16.2/etc/default}
systemctl daemon-reload

server 启动|停止|重启

systemctl start|stop|restart cloudera-scm-server

agent 启动|停止|重启

systemctl start|stop|restart cloudera-scm-agent

调优

参考:

https://docs.cloudera.com/documentation/enterprise/5-16-x/topics/cdh_admin_performance.html#cdh_performance

禁用文件访问时间

https://docs.cloudera.com/documentation/enterprise/5-6-x/topics/install_cdh_file_system.html#install_cdh_filesystem_noatime

https://www.cnblogs.com/jlmx/p/CDH_5_16_2_on_CentOS7.html
https://www.zybuluo.com/sasaki/note/242142

你可能感兴趣的:(hadoop)