1. 环境说明
软件准备
- JDK Tar包
- Mysql RPM及其依赖
- Mysql JDBC Driver Tar包
- Clouda RPM及其依赖
- Parcels文件(CDH,KAFKA等)
本文以三台机器为例,sys01-sys03,其中sys01是主节点,其他是从节点
2. 开始前
2.1 修改主机名并添加到hosts文件
# 设置主机名
hostnamectl set-hostname sys01
# 将主机名和IP映射关系添加到hosts文件
echo "192.168.6.43 sys01
192.168.6.44 sys02
192.168.6.45 sys03" >> /etc/hosts
# 查看hosts文件
cat /etc/hosts
2.2 关闭Firewalld
# 禁用firewalld
systemctl stop firewalld
# 禁用firewalld
systemctl disable firewalld
#查看firewalld状态
systemctl status firewalld
2.3 关闭Selinux
# 查看selinux状态,若为enabled即为开启状态
getenforce
# 临时关闭(不用重启机器)
# 设置SELinux 成为permissive模式
setenforce 0
# 永久关闭
# 修改/etc/selinux/config 文件
# 将SELINUX=enforcing改为SELINUX=disabled
sed -i '/SELINUX=/c SELINUX=disabled' /etc/selinux/config
2.4 配置ssh免密登陆
# 在A、B机下生成公钥/私钥对,一直回车键到完成
ssh-keygen -t rsa -P ''
# 在主节点执行命令,设置ssh免密到从节点
ssh-copy-id root@sys02
ssh-copy-id root@sys03
# 验证
ssh root@sys02
ssh root@sys03
2.5 配置YUM源
注:若已经配置好或可以在线安装则本步骤可跳过。
- 配置repo文件,进入/etc/yum.repos.d,运行命令:vi myrepo.rep
# repo文件格式如下
[33-base]
name=33-base
baseurl=http://10.0.0.33/base/
enabled=1
priority=99
gpgcheck=0
2.6 同步时区
- 安装ntp
- 系统默认已安装NTP,若未安装则运行命令:yum -y install ntp
- 开启NPT服务: systemctl start ntpd
- 开机自起:systemctl enable ntpd
- 硬件、系统时间同步:hwclock —systoh
离线情况下集群时间同步
下载jdk tar包 ```bash mkdir /usr/java tar -zxvf jdk-8u231-linux-x64.tar.gz -C /usr/java
将下面内容添加到/etc/profile
JAVA_HOME=/usr/java/jdk1.8.0_231 JRE_HOME=${JAVA_HOME}/jre CLASSPATH=.:$JAVA_HOME/lib:/dt.jar:$JAVA_HOME/lib/tools.jar PATH=$PATH:$JAVA_HOME/bin export JAVA_HOME export JRE_HOME export CLASSPATH export PATH
使配置生效
source /etc/profile
检测是否安装成功
java -version
<a name="fuckm"></a>
### 2.8 安装和配置数据库Mysql(主节点)
- <br />
- 安装mysql先下载mysql的repo源
$ wget [http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm](http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm)
安装源包,即安装mysql-community-release-el7-5.noarch.rpm包<br />$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
```bash
yum -y install mysql-server
注:若安装不成功,请检查2.5配置是否正确。
- 停止mysqld服务
# 停止服务
systemctl stop mysqld
# 查看状态
systemctl status mysql
- 修改my.cnf文件
运行命令:vi /etc/my.cnf
将内容替换为:
[mysqld]
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 = 16M
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
# For MySQL version 5.1.8 or later. Comment out binlog_format for older versions.
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
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=STRICT_ALL_TABLES
注:可依据硬件条件进行调整
设置开机自动启
# 设置开机自启 systemctl enable mysqld
启动mysql服务
# 运行命令: systemctl start mysqld # 查看状态: systemctl status mysqld
设置mysql密码
$ 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配置数据库
以root用户进入数据库 $ mysql -u root -p
Enter password:
创建数据库和用户并设置相应密
mysql> create database 数据库名 DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on 数据库名.* TO ‘用户名’@’%’ IDENTIFIED BY ‘密码’;
Query OK, 0 rows affected (0.00 sec)
创建完exit
全部复制以下内容并执行:
create database amon DEFAULT CHARACTER SET utf8; grant all on amon.* TO 'amon'@'%' IDENTIFIED BY 'sys@123';
create database metastore DEFAULT CHARACTER SET utf8; grant all on metastore.* TO 'hive'@'%' IDENTIFIED BY 'sys@123';
create database rman DEFAULT CHARACTER SET utf8; grant all on rman.* TO 'rman'@'%' IDENTIFIED BY 'sys@123';
create database nav DEFAULT CHARACTER SET utf8; grant all on nav.* TO 'nav'@'%' IDENTIFIED BY 'sys@123';
create database navms DEFAULT CHARACTER SET utf8; grant all on navms.* TO 'navms'@'%' IDENTIFIED BY 'sys@123';
create database oozie DEFAULT CHARACTER SET utf8; grant all on oozie.* TO 'oozie'@'%' IDENTIFIED BY 'sys@123';
create database hue DEFAULT CHARACTER SET utf8; grant all on hue.* TO 'hue'@'%' IDENTIFIED BY 'sys@123';
flush privileges;
映射关系如下:
Role | Database | User | Password |
---|---|---|---|
Activity Monitor | amon | amon | amon_password |
Reports Manager | rman | rman | rman_password |
Hive Metastore Server | metastore | hive | hive_password |
Sentry Server | sentry | sentry | sentry_password |
Cloudera Navigator Audit Server | nav | nav | nav_password |
Cloudera Navigator Metadata Server | navms | navms | navms_password |
2.9 安装CM
# 主节点
yum install -y cloudera-manager-daemons cloudera-manager-server
# 全部节点,包括主节点
yum install -y cloudera-manager-daemons cloudera-manager-agent
2.10 安装Mysql JDBC Driver
- 下载mysql-connector-java-5.1.38.tar.gz
- 下载网址为:http://www.mysql.com/downloads/connector/j/5.1.html.
- 解压:tar zxvf mysql-connector-java-5.1.38.tar.gz
- 将解压的jar文件复制到/usr/share/java/mysql-connector-java.jar
cp mysql-connector-java-5.1.38/mysql-connector-java-5.1.38-bin.jar /usr/share/java/mysql-connector-java.jar
2.11(主节点)配置Cloudera Manager Server数据库
进入/usr/share/cmf/schema目录
运行.sh文件并设置相应数据库# 命令格式为:./scm_prepare_database.sh [options] (postgresql|mysql|oracle) database username [password] ./scm_prepare_database.sh -uroot -p123456 mysql cloudera cic 123456
2.12 创建并使用 Parcel 存储库
使用HTTP,Nginx等软件搭建一个Web服务,使得所有节点能够访问并下载parcel包。例如将CDH和KAFKA分文件夹放置在/var/www/html目录下,使用http://localhost/cdh能正常访问。
3. 开始安装
3.1 开启Cloudera Manager service服务
# 开启server服务(主节点)
systemctl start cloudera-scm-server
# 查看状态
systemctl status cloudera-scm-server
# 开启agent服务
systemctl start cloudera-scm-agent(各个节点)
# 查看状态
systemctl status cloudera-scm-agent
3.2 界面安装
- 输入网址:http://localhost:7180,出现如下界面,初始用户名;admin,密码:admin
- 按下图所示操作,按照默认设置,点击”continue”
- 写入主机ip地址,点击”search”
- 点击下图 More Options选项,配置远程Parcel存储库URL,具体如何创建参见2.12。如下图所示:
cdh-parcels: http://10.0.0.33/cdh-parcels/
kafka-parcel: http://10.0.0.33/kafka-parcels/
- 已安装jdk,不选
- 群集设置配置规
- 所有组件选择主机的时候,如果没有给出默认值,即显示 “选择主机” ,则不处理
- 显示“与 DataNode 相同 ” 的,也不处理,直接修改DataNode节点,其他的就都好了
- Hbase: “Master” 选项,一般需要两个,相互热备,RegionServer 选择所有主机
- HDFS : NameNode 和 SecondNameNode各一个节点就好,但是不要放在一起,也是有热备的作用
- 节点分配的时候注意分散,不要集中到一台主机上,避免负载过大宕机
3.4 服务说明
AP,ES,HM,RM,SM cloudera services
RS hbase reginserver
M hbase master
DN hdfs datanode
NN hdfs namenode
SNN hdfs secondary namenode
B hdfs ballaner
G spark gateway
HS spark history server
S zookeeper server
KB kafka broker
RM yarn resourcemanager
NM yarn nodemanager
JHS yarn jobhistory serve
3.5 其他配置
- 检查主机正确性时出现 “已启用“透明大页面”,它可能会导致重大的性能问题。
# 临时修改:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
# 永久修改:
# vi /etc/rc.local 加入以下两行
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
4. 可能遇到的问题
错误1:
主机目录Permission denied
解决办法:
修改对应目录权限:chmode xxx:xxx 目录地址
错误:2:
hdfs目录Permission denied: user=mapred, access=WRITE, inode=”/“:hdfs:supergroup:drwxr-xr-x
解决办法:
sudo -u hdfs hdfs dfs -chmod 777 /
sudo -u hdfs hdfs dfs -chmod 777 /hbase
错误3:
Log directory specified does not exist: hdfs://cic01:8020/user/spark/applicationHistory
解决办法:
sudo -u hdfs hdfs dfs -chown spark:spark /user/spark
错误4:
需要格式化namenode
解决办法:
hdfs—实例—namenode——操作—格式化
错误5:
某些服务没起来
解决办法:
尝试重启对应服务