离线安装cdh6.3.1
离线安装cdh6.3.1(如需安装包请留言)
安装过程比较繁琐,请耐心阅读。祝您好运!
1.环境准备
三台linux服务器(安装jdk1.8+,python2.7以上):
192.168.10.53 node-cdh1(主节点,建议cpu32c,内存64G以上)
192.168.10.54 node-cdh2(建议内存32G以上)
192.168.10.55 node-cdh3(建议内存32G以上)各节点/opt/cloudera/parcels目录建议10G以上
下载
官方下载地址如下:
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html(jdk已安装可省略)
https://archive.cloudera.com/cdh6/6.3.1/parcels/CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcel
https://archive.cloudera.com/cdh6/6.3.1/parcels/CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcel.sha1
https://archive.cloudera.com/cdh6/6.3.1/parcels/manifest.json
https://archive.cloudera.com/cm6/6.3.1/repo-as-tarball/cm6.3.1-redhat7.tar.gz
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.47/mysql-connector-java-5.1.47.jar
1.1.设置linux主机名
各自节点执行修改主机名命令:
hostnamectl set-hostname node-cdh1
hostnamectl set-hostname node-cdh2
hostnamectl set-hostname node-cdh3
修改主机名也可编辑/etc/sysconfig/network
vi /etc/sysconfig/network
输入NETWORKING=yes HOSTNAME=node-cdh1
每个节点上都添加以下内容至 /etc/hosts
vi /etc/hosts
192.168.10.53 node-cdh1
192.168.10.54 node-cdh2
192.168.10.55 node-cdh3
- reboot重启各节点
- 重启完成后用hostname命令查询系统主机名
1.2.关闭集群防火墙
systemctl stop firewalld && systemctl disable firewalld && iptables -F
1.3.关闭集群selinux
vi /etc/selinux/config
SELINUX=disabled
修改成disabled之后 重启linux系统生效
1.4.设置集群时钟同步
1.4.1.所有节点设置亚洲上海时区
timedatectl set-timezone Asia/Shanghai
1.4.2.所有节点安装ntp:
1)确认是否已安装ntp
rpm -qa | grep ntp
如:
ntp-4.2.6p5-29.el7.centos.2.x86_64
ntpdate-4.2.6p5-29.el7.centos.2.x86_64
fontpackages-filesystem-1.44-8.el7.noarch
2)安装ntp
yum install -y ntp
1.4.3.配置ntp服务
本例选取node-cdh1为ntp的主节点
1)修改所有节点的/etc/ntp.conf
【命令】vi /etc/ntp.conf
【内容】
restrict 192.168.10.xxx nomodify notrap nopeer noquery //配置当前节点IP地址
restrict 192.168.10.1 mask 255.255.255.0 nomodify notrap //配置集群所在网段的网关(Gateway),子网掩码(Genmask)
2)选择一个主节点(192.168.10.53),修改其/etc/ntp.conf
【命令】vi /etc/ntp.conf
【内容】在server部分添加一下部分,并注释掉server 0 ~ n
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
3)主节点以外的节点,继续修改/etc/ntp.conf
【命令】vi /etc/ntp.conf
【内容】在server部分添加如下语句,将server指向主节点。
server 192.168.10.53 //改为主节点ip
Fudge 192.168.10.53 stratum 10 //改为主节点ip
修改前
修改后
主节点(192.168.10.53):
节点(192.168.10.54):
节点(192.168.10.55):
三个节点启动ntp服务、查看状态
1)启动ntp服务
【命令】service ntpd start
2)查看ntp服务器有无和上层ntp连通
【命令】ntpstat
查看ntp状态时,可能会出现如下所示情况
① unsynchronised time server re-starting polling server every 8 s
② unsynchronised polling server every 8 s这种情况属于正常,ntp服务器配置完毕后,需要等待5-10分钟才能与/etc/ntp.conf中配置的标准时间进行同步。
等一段时间(5-10分钟)之后,再次使用ntpstat命令查看状态,就会变成如下正常结果:
3)查看ntp服务器与上层ntp的状态
【命令】ntpq -p
4)查看ntpd进程的状态
【命令】watch “ntpq -p”
【终止】按 Ctrl+C 停止查看进程。
5)设置开机启动
【命令】chkconfig ntpd on
1.5.主节点安装mysql
https://github.com/Hackeruncle/MySQL/blob/master/MySQL%205.7.11%20Install.txt
本例mysql安装在/app下
卸载mariadb
安装mysql时候和centos7自带的数据库有冲突。
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
1.5.1.解压及创建目录
tar xzvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -C /app
cd /app
mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql
mkdir mysql/arch mysql/data mysql/tmp
1.5.2.创建my.cnf(见文件)
vi /etc/my.cnf
内容:
[client]
port = 3306
socket = /app/mysql/data/mysql.sock
default-character-set=utf8mb4
[mysqld]
port = 3306
socket = /app/mysql/data/mysql.sock
skip-slave-start
skip-external-locking
key_buffer_size = 256M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
query_cache_size= 32M
max_allowed_packet = 16M
myisam_sort_buffer_size=128M
tmp_table_size=32M
table_open_cache = 512
thread_cache_size = 8
wait_timeout = 86400
interactive_timeout = 86400
max_connections = 600
# Try number of CPU's*2 for thread_concurrency
#thread_concurrency = 32
#isolation level and default engine
default-storage-engine = INNODB
transaction-isolation = READ-COMMITTED
server-id = 1739
basedir = /app/mysql
datadir = /app/mysql/data
pid-file = /app/mysql/data/hostname.pid
#open performance schema
log-warnings
sysdate-is-now
binlog_format = ROW
log_bin_trust_function_creators=1
log-error = /app/mysql/data/hostname.err
log-bin = /app/mysql/arch/mysql-bin
expire_logs_days = 7
innodb_write_io_threads=16
relay-log = /app/mysql/relay_log/relay-log
relay-log-index = /app/mysql/relay_log/relay-log.index
relay_log_info_file= /app/mysql/relay_log/relay-log.info
log_slave_updates=1
gtid_mode=OFF
enforce_gtid_consistency=OFF
# slave
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=4
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
#other logs
#general_log =1
#general_log_file = /app/mysql/data/general_log.err
#slow_query_log=1
#slow_query_log_file=/app/mysql/data/slow_log.err
#for replication slave
sync_binlog = 500
#for innodb options
innodb_data_home_dir = /app/mysql/data/
innodb_data_file_path = ibdata1:1G;ibdata2:1G:autoextend
innodb_log_group_home_dir = /app/mysql/arch
innodb_log_files_in_group = 4
innodb_log_file_size = 1G
innodb_log_buffer_size = 200M
#根据生产需要,调整pool size
innodb_buffer_pool_size = 2G
#innodb_additional_mem_pool_size = 50M #deprecated in 5.6
tmpdir = /app/mysql/tmp
innodb_lock_wait_timeout = 1000
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 2
innodb_locks_unsafe_for_binlog=1
#innodb io features: add for mysql5.5.8
performance_schema
innodb_read_io_threads=4
innodb-write-io-threads=4
innodb-io-capacity=200
#purge threads change default(0) to 1 for purge
innodb_purge_threads=1
innodb_use_native_aio=on
#case-sensitive file names and separate tablespace
innodb_file_per_table = 1
lower_case_table_names=1
[mysqldump]
quick
max_allowed_packet = 128M
[mysql]
no-auto-rehash
default-character-set=utf8mb4
[mysqlhotcopy]
interactive-timeout
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
1.5.3.创建用户组及用户
groupadd -g 101 dba
useradd -u 514 -g dba -G root -d /app/mysql mysqladmin
1.5.4.copy 环境变量配置文件至mysqladmin用户的home目录中,为了以下步骤配置个人环境变量
cp /etc/skel/.* /app/mysql
1.5.5.配置mysql环境变量
vi mysql/.bashrc
export MYSQL_BASE=/app/mysql
export PATH=${MYSQL_BASE}/bin:$PATH
1.5.6.赋权限和用户组,切换用户mysqladmin,安装
chown mysqladmin:dba /etc/my.cnf
chmod 640 /etc/my.cnf
chown -R mysqladmin:dba /app/mysql
chmod -R 755 /app/mysql
1.5.7.配置服务及开机自启动
#将服务文件拷贝到init.d下,并重命名为mysql
cp support-files/mysql.server /etc/rc.d/init.d/mysql
#赋予可执行权限
chmod +x /etc/rc.d/init.d/mysql
#添加服务
chkconfig --add mysql
1.5.8.初始化
cd /app/mysql
#执行
bin/mysqld \
--defaults-file=/etc/my.cnf \
--user=mysqladmin \
--basedir=/app/mysql/ \
--datadir=/app/mysql/data/ \
--initialize
1.5.9.启动mysql,修改初始密码,重启mysql
#启动
su - mysqladmin
service mysql start
#查看初始密码
cd /app/mysql/data
cat hostname.err |grep password
#冒号后为密码(例如)
2020-12-09T16:02:19.331684Z 1 [Note] A temporary password is generated for root@localhost: >jOzMCDx6+t.
#登录
mysql -uroot -p
#输入密码 >jOzMCDx6+t.
#修改初始密码
alter user root@localhost identified by 'naricdh';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'naricdh' ;
#刷新后生效!!!
flush privileges;
#重启mysql
service mysql restart
1.6.创建CDH源数据库、用户、amon服务的数据库
create database cmf default character set utf8;
create database amon default character set utf8;
grant all privileges on cmf.* to 'cmf'@'%' identified by 'comnari';
grant all privileges on amon.* to 'amon'@'%' identified by 'comnari';
flush privileges;
1.7.主节点部署JDBC驱动
#将mysql驱动cp到 /usr/share/java目录下面,修改文件名为:mysql-connector-java.jar
cp mysql-connector-java-5.1.47.jar /usr/share/java/mysql-connector-java.jar
2.CDH部署
#上传cm6.3.1-redhat7.tar.gz到所有节点
#解压cm6.3.1-redhat7.tar.gz
tar -zxf cm6.3.1-redhat7.tar.gz
cd cm6.3.1/RPMS/x86_64/
ll
2.1.所有节点安装 cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm依赖
rpm -ivh cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm --nodeps --force
2.2.主节点部署cloudera-scm-server
rpm -ivh cloudera-manager-server-6.3.1-1466458.el7.x86_64.rpm --nodeps --force
修改 vi /etc/cloudera-scm-server/db.properties
com.cloudera.cmf.db.type=mysql
com.cloudera.cmf.db.host=node-cdh1:3306
com.cloudera.cmf.db.name=cmf
com.cloudera.cmf.db.user=cmf
com.cloudera.cmf.db.password=comnari
com.cloudera.cmf.db.setupType=EXTERNAL
如图:
2.3.主节点启动server,配置开机自启动
systemctl start cloudera-scm-server
systemctl enable cloudera-scm-server
server启动后,浏览器访问CM控制台 http://主节点ip:7180(账号:admin,密码:admin)
能看到如下界面即可,先不要操作
2.4.所有节点(包括主节点)安装agent,配置主节点host,启动agent,设置开机自启动
- 安装agent:
rpm -ivh cloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpm --nodeps --force
-
配置主节点host:
修改vim /etc/cloudera-scm-agent/config.ini
-
启动agent,设置开机自启动:
systemctl start cloudera-scm-agent
systemctl enable cloudera-manager-agent
2.5.安装httpd(用于CM创建集群选择存储库时,使用代理,如不使用代理可省略此步)
yum install -y httpd
cd /var/www/html
mkdir download
将三个文件copy到该目录下面
#启动httpd服务
systemctl start httpd
#开机自启
systemctl enable httpd
#浏览器输入ip/download访问apachehttp服务器
登录http://主节点ip:7180,账号密码默认为admin开始设置集群,注意设置集群中途不要关闭浏览器(集群设置和使用较简单,可自行查阅资料,本教程后期更新CDH集群设置和使用)
设置完服务后效果如下:
登录http://主节点ip:7180/cmf/home
完结!