参照官网的步骤:https://www.cloudera.com/documentation/enterprise/latest/topics/installation.html
准备三台服务器:
ip 地址(CDH 只支持 ipv4) | 主机名 |
---|---|
10.0.0.0 | master |
10.0.0.1 | slave01 |
10.0.0.2 | slave02 |
下载安装包,放在 /root 目录下(若在线安装,则可忽略)
https://archive.cloudera.com/cm6/6.1.0/redhat7/yum/RPMS/x86_64/
https://archive.cloudera.com/cdh6/6.1.0/parcels/
主机名 | 所需安装包 |
---|---|
master | cloudera-manager-agent-6.1.0-769885.el7.x86_64.rpm cloudera-manager-daemons-6.1.0-769885.el7.x86_64.rpm cloudera-manager-server-6.1.0-769885.el7.x86_64.rpm cloudera-manager-server-db-2-6.1.0-769885.el7.x86_64.rpm CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel manifest.json |
slave | cloudera-manager-agent-6.1.0-769885.el7.x86_64.rpm cloudera-manager-daemons-6.1.0-769885.el7.x86_64.rpm |
安装总共分为三大部分:
Part1: 安装前准备
Part2: 安装 Cloudera Manager 和 CDH
Part3: 安装之后
PART1 安装前准备
step1: 修改主机名(所有节点,重启有效)
# master
hostnamectl set-hostname master
# slave01
hostnamectl set-hostname slave01
# slave02
hostnamectl set-hostname slave02
设置映射主机名,将以下内容添加到 /etc/hosts 文件:
10.0.0.0 master
10.0.0.1 slave01
10.0.0.2 slave02
各节点编辑 /etc/sysconfig/network, 填入各自的主机名。比如 master:
HOSTNAME=master
step2: 关闭防火墙(所有节点)
#查看防火墙
systemctl status firewalld.service
#执行关闭命令
systemctl stop firewalld.service
#执行开机禁用防火墙命令
systemctl disable firewalld.service
step3: 关闭 SELINUX (所有节点)
vim /etc/sysconfig/selinux
将 SELINUX=enforcing
改为 SELINUX=disabled
step4: 启用ntp (所有节点)
安装 ntp
yum install ntp
启动 ntp
systemctl enable ntpd
systemctl start ntpd
step5: 配置从 master 到所有 slave 的 ssh 免密登录
先在 master 上执行:
ssh-keygen -t rsa #一路回车到完成
ssh-copy-id -i ~/.ssh/id_rsa.pub root@master #将公钥拷贝到本机的authorized_keys上
再在所有 slave 上分别执行:
ssh-keygen -t rsa #一路回车到完成
ssh-copy-id -i ~/.ssh/id_rsa.pub root@master #注意此处不变,将公钥拷贝到master的authorized_keys上
在 master 上,将 authorized_keys 分发到其他节点服务器:
scp ~/.ssh/authorized_keys root@slave01:~/.ssh/
scp ~/.ssh/authorized_keys root@slave02:~/.ssh/
step6: 禁用透明大页面压缩(所有节点)
注:step6 与 step7 虽然不是官网的标准步骤,但如果不执行,创建集群时会报 warning,仍需修改配置。
打开编辑 /etc/rc.local 文件:
vim /etc/rc.local
添加以下内容:
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
step7: 优化交换分区(所有节点)
编辑 /etc/sysctl.conf 并添加一行 vm.swappiness=0
vim /etc/sysctl.conf
PART2 安装 Cloudera Manager 和 CDH
step1: 为 Cloudera Manager 配置存储库(master)
- 下载对应操作系统的 cloudera-manager.repo 文件到 Cloudera Manager Server 主机上的 /etc/yum.repos.d/
sudo wget https://archive.cloudera.com/cm6/6.1.0/redhat7/yum/cloudera-manager.repo -P /etc/yum.repos.d/
- 导入存储库签名 GPG key:
sudo rpm --import https://archive.cloudera.com/cm6/6.1.0/redhat7/yum/RPM-GPG-KEY-cloudera
step2: 安装 JDK 并写入环境变量(所有节点)
(需要先卸载掉已安装的 JDK)
(认真对待 step2, 没装好会导致 Cloudera Manager 启动失败)
- 完成 step 1:为 Cloudera Manager 配置存储库后,可以使用软件包管理器在 Cloudera Manager Server 主机上(master)安装 Oracle JDK,如下所示:
sudo yum install oracle-j2sdk1.8
如果已经下载了 JDK(下载地址:https://archive.cloudera.com/cm6/6.1.0/redhat7/yum/RPMS/x86_64/oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm),直接用 rpm 安装即可:
rpm -ivh oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm
或自行安装:
Oracle 官网下载 Oracle JDK 并安装,需要 jdk1.8 及以上。
- 写入环境变量:
/etc/profile 末尾添加以下内容
#set jdk environment
export JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
step3: 安装 Cloudera Manager 软件包
在 master 上安装 Cloudera Manager 软件包,并可选择启用 auto-TLS(推荐启用)。
- 先安装下面的内容,因为 cloudera-manager-agent 依赖这些(所有节点)
yum install bind-utils psmisc cyrus-sasl-plain cyrus-sasl-gssapi portmap httpd mod_ssl openssl-devel python-psycopg2 MySQL-python /lib/lsb/init-functions
- 接下来需要安装:(注意需要先安装 daemons,再安装其他)
master:
rpm -ivh cloudera-manager-daemons-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-agent-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-server-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-server-db-2-6.0.1-610811.el7.x86_64.rpm
slave:
rpm -ivh cloudera-manager-daemons-6.0.1-610811.el7.x86_64.rpm
rpm -ivh cloudera-manager-agent-6.0.1-610811.el7.x86_64.rpm
或者可使用在线下载安装,下载慢,不推荐
sudo yum install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
- 启用 auto-TLS:
JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera /opt/cloudera/cm-agent/bin/certmanager setup --configure-services
启用 auto-TLS 后,后续访问 impala 需要指明使用 ssl(默认为不使用)
例如启动 impala-shell:impala-shell --ssl
- 修改 agent 的服务器地址(所有节点)
编辑 /etc/cloudera-scm-agent/config.ini:
vim /etc/cloudera-scm-agent/config.ini
将 server_host=localhost
改为 master 节点主机名 master
step4: 安装数据库(MySQL)
此数据库用于存储 Cloudera Manager 配置信息,只安装在 master 即可
- 安装 MySQL Server
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
systemctl start mysqld
- 配置并启动 MySQL Server
- 首先停止 MySQL 服务
systemctl stop mysqld
- 将旧的 InnoDB 日志文件 /var/lib/mysql/ib_logfile0 和 /var/lib/mysql/ib_logfile1 从 /var/lib/mysql/ 中移除
rm -rf /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile1
- 更新 /etc/my.cnf 配置文件,推荐的配置如下:
[mysqld]
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
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=STRICT_ALL_TABLES
- 启动服务并设置开机启动
systemctl enable mysqld
systemctl start mysqld
- 设置 root 密码和其他安全相关设置:
/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!
- 安装 MySQL JDBC Driver
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
tar zxvf mysql-connector-java-5.1.46.tar.gz
mkdir -p /usr/share/java/
cd mysql-connector-java-5.1.46
cp mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar
- 注意,此时 mysql-connector-java.jar 的权限若为
rwx------
,后期 Cloudera Manager Server 启动时,用非 root 用户没有 mysql-connector-java.jar 的权限,将导致服务启动失败。因此开放 mysql-connector-java.jar 的权限:
chmod 755 /usr/share/java/mysql-connector-java.jar
- 为 Cloudera Manager 创建 MySQL 数据库
- root 用户登录
mysql -u root -p
Enter password:
- 为下表中每个服务创建 utf8 字符集的数据库:
CREATE DATABASE <database> DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON <database>.* TO '<user>'@'%' IDENTIFIED BY '<password>';
Service | database | user |
---|---|---|
Cloudera Manager Server | scm | scm |
Activity Monitor | amon | amon |
Reports Manager | rman | rman |
Hue | hue | hue |
Hive Metastore Server | metastore | hive |
Sentry Server | sentry | sentry |
Cloudera Navigator Audit Server | nav | nav |
Cloudera Navigator Metadata Server | navms | navms |
Oozie | oozie | oozie |
命令如下:
CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON scm.* TO 'scm'@'%' IDENTIFIED BY 'scm';
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON amon.* TO 'amon'@'%' IDENTIFIED BY 'amon';
CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON rman.* TO 'rman'@'%' IDENTIFIED BY 'rman';
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON hue.* TO 'hue'@'%' IDENTIFIED BY 'hue';
CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON metastore.* TO 'hive'@'%' IDENTIFIED BY 'hive';
CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON sentry.* TO 'sentry'@'%' IDENTIFIED BY 'sentry';
CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON nav.* TO 'nav'@'%' IDENTIFIED BY 'nav';
CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON navms.* TO 'navms'@'%' IDENTIFIED BY 'navms';
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON oozie.* TO 'oozie'@'%' IDENTIFIED BY 'oozie';
flush privileges;
- 检查 MySQL 确认已创建所有数据库
SHOW DATABASES;
step5: 设置 Cloudera Manager 数据库
master 执行:
rm /etc/cloudera-scm-server/db.mgmt.properties
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm
得到:
Enter SCM password:
JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk1.8.0_141-cloudera/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/opt/cloudera/cm/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
step6: 安装 CDH 和其他软件
- 准备 parcel 包(master)
若在线安装,则跳过此步
- 将已下载的 CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel 和 manifest.json 拷贝至 /opt/cloudera/parcel-repo/ 目录,并且生成 parcel 包的 sha 值:
sha1sum /opt/cloudera/parcel-repo/CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel
- 将 sha 值填入到 CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel.sha 文件中
vim /opt/cloudera/parcel-repo/CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel.sha
- 启动 cloudera-scm-agent (所有节点)
systemctl start cloudera-scm-agent
- 启动 Cloudera Manager Server (master)
systemctl start cloudera-scm-server
查看启动日志:
tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
看到 INFO WebServerImpl:com.cloudera.server.cmf.WebServerImpl: Started Jetty server.
则说明启动完成
********** 接着在 https://10.0.0.0:7183 创建集群 **********