说明:
- 【一、CDH5.16.2集群之VMware-workstation-14安装】
- 【二、CDH5.16.2集群之三台虚拟机安装】
- 【三、CDH5.16.2集群之三台虚拟机配置网络配置】
- 【四、CDH5.16.2集群之XShell连接虚拟机】
一、集群前期配置
1、安装JAVA(三台虚拟机都执行)
- 卸载自带的Java
执行:rpm -qa | grep -i java
- 执行如下命令卸载上图中箭头所指的四个jdk
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
- 安装自己下载的Java
- 上传下载的Java到目录:/usr/lib/java
- 解压Java的tar包
cd /usr/lib/java
tar -xzvf jdk-8u172-linux-x64.tar.gz
- 配置环境变量到文件**/etc/profile**最后
# Java1.8
export JAVA_HOME="/usr/lib/java/jdk1.8.0_172"
JRE_HOME=" J A V A H O M E / j r e " C L A S S P A T H = " . : {JAVA_HOME}/jre" CLASSPATH=".: JAVAHOME/jre"CLASSPATH=".:{JAVA_HOME}/lib: J R E H O M E / l i b " P A T H = " {JRE_HOME}/lib" PATH=" JREHOME/lib"PATH="{PATH}: H O M E / b i n : {HOME}/bin: HOME/bin:{JAVA_HOME}/bin"
export PATH
- 生效配置文件:source /etc/profile,并查看Java版本:java -version
2、安装NTP,同步时间
- NTP_Server端设置**(只需在cdh1上操作)**
- 安装NTP
yum install -y ntp ntpdate
- 配置ntp.conf
备份/etc/ntp.conf:
cp /etc/ntp.conf /etc/ntp.conf_bak
配置/etc/ntp.conf,添加如下配置:
# 27.127.1.0 代表自身
server 127.127.1.0
fudge 127.127.1.0 stratum 10
- 设置中国时间
timedatectl set-timezone Asia/Shanghai
- 修改启动参数,增加-g -x参数,允许ntp服务在系统时间误差较大时也能正常工作:
echo ‘OPTIONS="-x"’ >> /etc/sysconfig/ntpd
- 设置为开机自启动
chkconfig --level 345 ntpd on
- 设置为enable
systemctl enable ntpd
- 启动NTP服务
systemctl start ntpd
- 查看NTP服务状态
systemctl status ntpd
- NTP_Client端设置**(只需在cdh2、cdh3上操作)**
- 安装NTP
yum install -y ntp ntpdate
- 配置ntp.conf
备份/etc/ntp.conf:
cp /etc/ntp.conf /etc/ntp.conf_bak
配置/etc/ntp.conf,添加如下配置:
# NTP_Server的IP地址
server 192.168.100.101
- 设置中国时间
timedatectl set-timezone Asia/Shanghai
- 修改启动参数,增加-g -x参数,允许ntp服务在系统时间误差较大时也能正常工作:
echo ‘OPTIONS="-x"’ >> /etc/sysconfig/ntpd
- 设置为开机自启动
chkconfig --level 345 ntpd on
- 设置为enable
systemctl enable ntpd
- 启动NTP服务
systemctl start ntpd
- 查看NTP服务状态
systemctl status ntpd
- 停止客户端的NTP服务(只需在cdh2、cdh3上操作)
systemctl stop ntpd
- 同步服务端时间(只需在cdh2、cdh3上操作)
ntpdate 192.168.100.101
- 所有节点启动时间同步(三台虚拟机)
timedatectl set-ntp yes
3、安装MySQL(只在cdh1上操作)
- 用root用户,安装mysql-7.5
上传下载的MySQL文件
把mysql-cluster-gpl-7.5.10-linux-glibc2.12-x86_64.tar.gz文件上传到目录:/data/mysql/data/
解压并修改文件夹名称
mkdir -p /data/mysql/data/
cd /data/mysql/data/
tar -xzvf mysql-cluster-gpl-7.5.10-linux-glibc2.12-x86_64.tar.gz
mv mysql-cluster-gpl-7.5.10-linux-glibc2.12-x86_64 mysql-7.5
- 使用root创建组,用户,mysql相关目录
创建用户
useradd mysqluser
passwd mysqluser //密码 ‘1qaz@WSX’
创建目录
mkdir -p /data/mysql/data/mysql-7.5/3306/data/
mkdir -p /data/mysql/data/mysql-7.5/3306/general_query
mkdir -p /data/mysql/data/mysql-7.5/3306/slow_query
mkdir -p /data/mysql/data/mysql-7.5/3306/tmp
mkdir -p /data/mysql/data/mysql-7.5/3306/error
mkdir -p /data/mysql/binlog/relaylog/
更改目录权限
chown -R mysqluser: /data/mysql/
环境变量
su mysqluser
vi ~/.bashrc
#####增加####
export PATH="$PATH:/data/mysql/data/mysql-7.5/bin"
生效配置
source ~/.bashrc
- 初始化数据库(su mysqluser)mysqluser用户执行
mysqld --initialize --user=mysqluser --datadir=/data/mysql/data/mysql-7.5/3306/data --basedir=/data/mysql/data/mysql-7.5
注:标注的红框是自动生成的密码:ekL!ifwMC6si
- 修改my.cnf配置文件(mysqluser用户执行)
cd /data/mysql/data/mysql-7.5
vi my.cnf
[client]
port=3306
socket =/data/mysql/data/mysql-7.5/3306/mysql.sock
[mysql]
default-character-set = utf8
[mysqld]
lower_case_table_names=1
port = 3306
user = mysql
basedir = /data/mysql/data/mysql-7.5
socket = /data/mysql/data/mysql-7.5/3306/mysql.sock
pid-file = /data/mysql/data/mysql-7.5/3306/mysql.pid
datadir = /data/mysql/data/mysql-7.5/3306/data
tmpdir = /data/mysql/data/mysql-7.5/3306/tmp
server-id=79
open_files_limit = 10240
explicit_defaults_for_timestamp
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
auto_increment_increment=2
auto_increment_offset=1
relay-log=/data/mysql/binlog/relaylog/m1-relaylog
log_slave_updates=on
relay_log_recovery=on
slave-skip-errors=1032
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=16
master_info_repository=TABLE
relay_log_info_repository=TABLE
max_allowed_packet = 256M
max_heap_table_size = 256M
net_buffer_length = 8K
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size = 16M
read_rnd_buffer_size = 16M
query_cache_size = 0
character_set_server = utf8
collation_server = utf8_bin
log_bin = /data/mysql/binlog/mysql-bin
binlog_cache_size = 16M
max_binlog_cache_size = 2048M
max_binlog_size = 1024M
binlog_format = mixed
binlog_stmt_cache_size = 16M
expire_logs_days = 14
log_output = FILE
log_error = /data/mysql/data/mysql-7.5/3306/error/mysql-error.log
slow_query_log = 1
slow_query_log_file = /data/mysql/data/mysql-7.5/3306/slow_query/slow_query.log
general_log = 1
general_log_file = /data/mysql/data/mysql-7.5/3306/general_query/general_query.log
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
max_connections = 1000
max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
skip-name-resolve
sync_binlog = 0
table_open_cache = 3000
- 启动mysql
Mysql所有操作都需要在mysqluser用户下,之后不再特别提示
su - mysqluser
mysqld_safe --defaults-file=/data/mysql/data/mysql-7.5/my.cnf --ledir=/data/mysql/data/mysql-7.5/bin &
- 查看数据库状态
查看mysql进程:ps -ef | grep mysql
查看mysql端口:ss -tulnp | grep 3306
- 修改mysql-root的密码
加粗标注为mysql初始密码,根据实际情况替换
mysqladmin -uroot -p’ekL!ifwMC6si’ password --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
- 测试连接mysql
加粗标注为mysql初始密码,根据实际情况替换
mysql -uroot -p’1qaz@WSX’ --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
- 创建CDH数据库
进入命令行:
mysql -u root --password=‘1qaz@WSX’ --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
create database amon default character set utf8;
create database rman default character set utf8;
create database hive default character set utf8;
create database oozie default character set utf8;
create database hue default character set utf8;
create database cm default character set utf8;
create database scm default character set utf8;
create database aman default character set utf8;
- 创建CDH用户
进入命令行:
mysql -u root --password=‘1qaz@WSX’ --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
CREATE USER "amon"@"%" IDENTIFIED BY "amon!QAZ";
create user "rman"@"%" identified by "rman!QAZ";
create user "hive"@"%" identified by "hive!QAZ";
create user "oozie"@"%" identified by "oozie!QAZ";
create user "hue"@"%" identified by "hue!QAZ";
create user "cm"@"%" identified by "cm!QAZ";
create user "scm"@"%" identified by "scm!QAZ";
create user "aman"@"%" identified by "aman!QAZ";
- 用户授权
进入命令行:
mysql -u root --password=‘1qaz@WSX’ --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
grant all privileges on amon.* to 'amon'@'%';
grant all privileges on rman.* to 'rman'@'%';
grant all privileges on hive.* to 'hive'@'%';
grant all privileges on oozie.* to 'oozie'@'%';
grant all privileges on hue.* to 'hue'@'%';
grant all privileges on cm.* to 'cm'@'%';
grant all privileges on scm.* to 'scm'@'%';
grant all privileges on aman.* to 'aman'@'%';
- 数据库授权刷新
进入命令行:
mysql -u root --password=‘1qaz@WSX’ --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
flush privileges;
4、Mysql 双主配置说明
- 停止mysql(cdh1上mysqluser用户操作)
mysqladmin -uroot -p -S /data/mysql/data/mysql-7.5/3306/mysql.sock shutdown
- 打包备份mysql整个目录(cdh1上root用户操作)
cd /tmp
tar -zcvf mysql.tar.gz /data/mysql/
- scp至192.168.100.102:/tmp 目录(cdh1上root用户操作)
cd /tmp
scp mysql.tar.gz 192.168.100.102:/tmp
- 解压mysql.tar.gz包(cdh2上root用户操作)
tar -zxvf /tmp/mysql.tar.gz -C /
- 创建mysqluser用户(cdh2上root用户操作)
useradd mysqluser
passwd mysqluser //密码 ‘1qaz@WSX’
- 更改mysql目录权限(cdh2上root用户操作)
chown -R mysqluser: /data/mysql/
- 修改配置文件(cdh2上mysqluser用户操作)
server-id=80
auto_increment_increment=2
auto_increment_offset=2
relay-log=/data/mysql/binlog/relaylog/m2-relaylog
- 修改server-uuid(cdh2上mysqluser用户操作)
cd /data/mysql/data/mysql-7.5/3306/data
vi auto.cnf
[auto]
server-uuid=f96ba960-9453-11ea-977b-111c291d9ee9
- 配置环境变量(cdh2上mysqluser用户操作)
vi ~/.bashrc
**添加内容:**export PATH="$PATH:/data/mysql/data/mysql-7.5/bin"
生效配置: source ~/.bashrc
- 启动mysql(cdh2上mysqluser用户操作)
mysqld_safe --defaults-file=/data/mysql/data/mysql-7.5/my.cnf --ledir=/data/mysql/data/mysql-7.5/bin &
- 查看数据库状态(cdh2上mysqluser用户操作)
查看mysql进程与端口
ps -ef | grep mysql
ss -tulnp | grep 3306
- 测试连接mysql(cdh2上mysqluser用户操作)
黑色加粗为实际使用的密码,根据实际情况替换
mysql -uroot -p’1qaz@WSX’ --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
- cdh1上启动mysql服务
mysqld_safe --defaults-file=/data/mysql/data/mysql-7.5/my.cnf --ledir=/data/mysql/data/mysql-7.5/bin &
- 创建双主授权用户
- 两台mysql都需要连接至mysql命令行
mysql -uroot -p’1qaz@WSX’ --socket=/data/mysql/data/mysql-7.5/3306/mysql.sock
- 执行授权操作:
在192.168.100.101上执行
GRANT REPLICATION SLAVE ON . TO ‘repl’@‘192.168.100.102’ IDENTIFIED BY ‘1qaz@WSX’;
flush privileges;
在192.168.100.102上执行
GRANT REPLICATION SLAVE ON . TO ‘repl’@‘192.168.100.101’ IDENTIFIED BY ‘1qaz@WSX’;
flush privileges;
- mysql双主配置- CHANGE MASTER TO
- 192.168.100.101配置
在192.168.100.102执行(mysql命令行)
show master status\G;
在192.168.100.101执行----红色框中标的mysql-bin.000002,613必须与上图中的一致
CHANGE MASTER TO
MASTER_HOST=‘192.168.100.102’,
MASTER_USER=‘repl’,
MASTER_PASSWORD=‘1qaz@WSX’,
MASTER_LOG_FILE=‘mysql-bin.000002’,
MASTER_LOG_POS=613;
- 192.168.100.102配置
在192.168.100.101执行(mysql命令行)
show master status\G;
在192.168.100.102执行----红色框中标的mysql-bin.000002,613必须与上图中的一致
CHANGE MASTER TO
MASTER_HOST=‘192.168.100.101’,
MASTER_USER=‘repl’,
MASTER_PASSWORD=‘1qaz@WSX’,
MASTER_LOG_FILE=‘mysql-bin.000002’,
MASTER_LOG_POS=613;
- 启动slave
在192.168.100.101和192.168.100.102都执行
start slave;
- 查看双主启动slave配置后状态
在192.168.100.101和192.168.100.102都执行
show slave status\G;
cdh1的结果
cdh2的结果
二、准备Cloudera Manager安装
1、安装Httpd服务
在作为CDH yum源的机器上进行操作
yum install httpd
systemctl start httpd
systemctl enable httpd
2、禁用Selunix
所有节点关闭Selunix:
vi /etc/selinux/config
设置:SELINUX=disabled
重启或则执行setenforce 0 使配置生效
3、禁止交换
**所有节点执行:**禁止交换(可选), 内存页面交换在某些情况下会导致 CDH 性能下降,建议在 kernel 在2.6.32-303 之前的版本中将其关闭。
vi /etc/sysctl.conf
#ADD by tansun for CDH
vm.swappiness=0
执行,立即生效
sysctl vm.swappiness=0
4、修改 transparent_hugepage 参数
执行范围:所有节点
这一参数默认值可能会导致 CDH 性能下降,并在/etc/rc.local末尾添加如下两行.
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
三、CDH Manager安装
1、添加yum源:(所有节点)
curl https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/cloudera-manager.repo > /etc/yum.repos.d/cloudera-manager.repo
注:此出隐含条件是有系统默认的yum源可在线更新
2、查看cdh配置信息: /etc/yum.repos.d/cloudera-manager.repo
3、开启5.6版的yum源(所有节点)
vim /etc/yum.repos.d/mysql-community.repo (所有节点)
开启5.6的yum源并修改如下:
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
复制到其他节点:
scp /etc/yum.repos.d/mysql-community.repo 192.168.100.102:/etc/yum.repos.d/mysql-community.repo
scp /etc/yum.repos.d/mysql-community.repo 192.168.100.103:/etc/yum.repos.d/mysql-community.repo
4、安装Cloudera Manager包 (cdh1主节点)
yum install -y cloudera-manager-daemons cloudera-manager-server
5、安装mysql-connector-java(所有节点)
yum install mysql-connector-java
6、设置外部数据源(cdh1主节点)
/usr/share/cmf/schema/scm_prepare_database.sh mysql scm scm ‘scm!QAZ’
7、验证
访问http://192.168.100.101:7180/是否安装成功
四、Cloudera Manager通过界面安装
1、根据提示安装
2、搜索使用的主机
3、根据提示继续安装
4、等待安装完成
5、等待集群安装
6、检查主机
7、选择集群安装的组件
接下来根据提示操作即可…