1.修改主机名称
vi /etc/hostname
cdh-100
cat /proc/sys/kernel/random/uuid
2.固定ip 每台机需调整ipaddr
vi /etc/sysconfig/network-scripts/ifcfg-ens33
/#添加如下配置信息
DNS1=192.168.20.2 #NDS
IPADDR=192.168.20.100 #IP地址
GATEWAY=192.168.20.2 #网关
PREFIX=24 #centos子网掩码长度:24–> 255.255.255.0
DNS1=192.168.20.2
IPADDR=192.168.20.123
GATEWAY=192.168.20.2
PREFIX=24
7af87106-3443-4c69-94ba-48df1822931d
3.配置 Linux 克隆机主机名称映射 hosts 文件,打开/etc/hosts
vi /etc/hosts
192.168.20.100 cdh-100
192.168.20.101 cdh-101
192.168.20.102 cdh-102
192.168.20.103 cdh-103
192.168.20.104 cdh-104
192.168.20.120 nacos01
192.168.20.121 nacos02
192.168.20.122 nacos03
4.免密登录(cdh-100)
为了方便在机器之间拷贝数据文件,将 cdh-100 的公钥拷贝到其他三台cdh-101-103 机器上,实现免密登录。后续需要拷贝的文件都是在cdh-100上先配置好,然后通过 scp 命令拷贝到其他两台机器上。
在 cdh-100节点上生成公钥:
执行
ssh-keygen
三次enter不用输入
执行
ssh-copy-id root@cdh-101
ssh-copy-id root@cdh-102
ssh-copy-id root@cdh-103
ssh-copy-id root@cdh-104
5.调整配置信息selinux
输入
getenforce
如果输出为 Enforcing,则需要处理一下,否则可以跳过这一步。修改 /etc/selinux/config 文件,将 SELINUX=enforcing 修改为SELINUX=disabled,使用以下命令修改并立即生效:
执行
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
setenforce 0
vi /etc/selinux/config
7.修改swappiness
vm.swappiness 参数可以调整机器使用内存、交互分区的比例。vm.swappiness 的取值范围在 0-100 之间,当 vm.swappiness 为 0 时,表示最大限度地使用物理内存,而后使用 swap 空间;当 swappiness 为 100 时,表示最大限度地使用 swap 空间,把内存中的数据及时搬运到 swap 空间中去。
执行
echo vm.swappiness=0 >> /etc/sysctl.conf
echo “vm.swappiness=10” >> /etc/sysctl.conf
sysctl -p
8.关闭透明大页面
大多数 Linux 平台都包含一个称为透明大页面的功能,该功能与 Hadoop 工作节点的交互很差,并且会严重降低性能。
查看透明大页是否启用,[always] never 表示已启用,always [never] 表示已禁用。
执行
cat /sys/kernel/mm/transparent_hugepage/defrag
如果是启用状态,则执行以下操作关闭透明大页面:
执行
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
vim /etc/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
并将以上命令添加到 /etc/rc.d/rc.local 文件中,使系统重启时依然生效。
cat /etc/rc.d/rc.local
echo ‘echo never > /sys/kernel/mm/transparent_hugepage/defrag’ >> /etc/rc.d/rc.local
echo ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled’ >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
并将以上命令添加到 /etc/rc.d/rc.local 文件中,使系统重启时依然生效。
9.配置本地yum源
配置Centos7.9镜像局域网yum源(配置在cdh-100)
(http和ntp的rpm包都在centos7.9的镜像文件中。)
检查httpd是否安装
rpm -qa|grep httpd
如果没装,先配置Centos7.6镜像局域网yum源
创建/var/www/html文件夹
mkdir -p /var/www/html
将/var/www/html/赋权:
chmod -R 777 /var/www/html
chmod -R 777 /kdata/*
在/var/www/html文件夹下创建cdh和centos7.9文件夹
cd /var/www/html
mkdir cdh
mkdir centos7.9
Centos7.9.iso镜像文件解压到/var/www/html/centos7.6下
mount -o loop /kdata/CentOS-7-x86_64-DVD-2009.iso /var/www/html/centos7.9/
配置/etc/yum.repo.d/CentOS-Media.repo
个人理解:yum通过"*.repo" 的文件( yum 源的配置文件)中的baseurl来找到rpm包的位置
vi /etc/yum.repos.d/CentOS-Media.repo
调整
baseurl=file:///var/www/html/centos7.9
gpgcheck=0
enabled=1
#gpgkey=
清除yum下载下来的 包文件rpm和头文件header
yum clean all
生成缓存
(就是把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存
以后用install时就在缓存中搜索,提高了速度)
yum makecache
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
OK啦,测试下!
yum list
安装httpd服务
yum install -y httpd
启动httpd服务
service httpd start
查看httpd服务状态(active (running)即可)
service httpd status
再次修改/etc/yum.repo.d/CentOS-Media.repo文件
vi /etc/yum.repos.d/CentOS-Media.repo
调整
baseurl=http://192.168.20.100/centos7.9
gpgcheck=0
enabled=1
#gpgkey=
yum clean all
yum makecache
浏览器试下http://192.168.20.100/centos7.9/能否打开,如果可以,即已成功
将/etc/yum.repos.d/CentOS-Media.repo远程拷贝到其他节点,其他节点也就可以下载http服务了
scp /etc/yum.repos.d/CentOS-Media.repo cdh-101:/etc/yum.repos.d/
scp /etc/yum.repos.d/CentOS-Media.repo cdh-102:/etc/yum.repos.d/
scp /etc/yum.repos.d/CentOS-Media.repo cdh-103:/etc/yum.repos.d/
scp /etc/yum.repos.d/CentOS-Media.repo cdh-104:/etc/yum.repos.d/
在其他节点上执行
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
yum clean all
yum makecache
yum install -y httpd
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.20.100” port protocol=“tcp” port=“1:65535” accept”
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.20.101” port protocol=“tcp” port=“1:65535” accept”
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.20.102” port protocol=“tcp” port=“1:65535” accept”
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.20.103” port protocol=“tcp” port=“1:65535” accept”
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.20.104” port protocol=“tcp” port=“1:6379” accept”
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.101” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.102” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.103” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.104” accept’
firewall-cmd --reload
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.100” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.102” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.103” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.104” accept’
firewall-cmd --reload
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.101” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.100” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.103” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.104” accept’
firewall-cmd --reload
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.101” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.102” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.100” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.104” accept’
firewall-cmd --reload
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.101” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.102” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.103” accept’
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.20.100” accept’
firewall-cmd --reload
10.配置cm局域网yum源
执行cd /var/www/html/cdh进入目录,执行mkdir cm6新建目录: cm6,用于存放cloudera-manager的安装包:
cd /var/www/html/cdh
mkdir cm6
将2.1下载的cm6.3.1-redhat7.tar.gz拷贝到/var/www/html/cdh/cm6下
执行tar -zxvf cm6.3.1-redhat7.tar.gz解压安装包(解压后可将压缩包删除)
cd /var/www/html/cdh/cm6
tar -zxvf /kdata/cm6.3.1-redhat7.tar.gz -C /var/www/html/cdh/cm6
进入/etc/yum.repo.d/,新建yum源的配置文件
cd /etc/yum.repos.d/
vi cloudera-manager.repo
vi cloudera-manager.repo(新建文件)输入以下内容
[cloudera-manager]
name=Cloudera Manager 6.3.1
baseurl=http://192.168.20.100/cdh/cm6/cm6.3.1/
enabled=1
gpgcheck=0
清理并重构yum缓存
yum clean all
yum makecache
以上两个yum源配置好以后重启httpd服务:
service httpd restart
开机启动
systemctl enable httpd
浏览器试下http://192.168.20.100/cdh/cm6/cm6.3.1/能否打开,如果可以,即已成功
将/etc/yum.repos.d/cloudera-manager.repo远程拷贝到其他节点,其他节点也就可以下载cm中的rpm包了
scp /etc/yum.repos.d/cloudera-manager.repo cdh-101:/etc/yum.repos.d/
scp /etc/yum.repos.d/cloudera-manager.repo cdh-102:/etc/yum.repos.d/
scp /etc/yum.repos.d/cloudera-manager.repo cdh-103:/etc/yum.repos.d/
scp /etc/yum.repos.d/cloudera-manager.repo cdh-104:/etc/yum.repos.d/
在其他节点上执行
yum clean all
yum makecache
11.集群时间同步
时间同步的方式:找一个机器,作为时间服务器,所有的机器与这台集群时间进行定时的同步,比如,每隔十分钟,同步一次时间。(如果集群时间不同步,集群在执行定时任务时,无法同步执行)
网络时间协议,英文名称:Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。NTP的目的是在无序的Internet环境中提供精确和健壮的时间服务。
检查ntp是否安装
rpm -qa|grep ntp
删除已安装ntp
yum –y remove ntpdate-4.2.6p5-22.el7.x86_64
安装(离线安装)
cd /kdata/ntp
rpm -ivh --replacefiles ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm
rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
scp -r /kdata/ntp/ cdh-101:/kdata/
scp -r /kdata/ntp/ cdh-102:/kdata/
scp -r /kdata/ntp/ cdh-103:/kdata/
scp -r /kdata/ntp/ cdh-104:/kdata/
安装(在线安装)
yum –y install ntp
修改所有节点的/etc/ntp.conf
vi /etc/ntp.conf
restrict 192.168.20.100 nomodify notrap nopeer noquery //当前节点IP地址 iP每台机不一样
restrict 192.168.20.2 mask 255.255.255.0 nomodify notrap //集群所在网段的网关(Gateway),子网掩码(Genmask)
选择一个主节点,修改其/etc/ntp.conf
vi /etc/ntp.conf
在server部分添加一下部分,并注释掉server 0 ~ n
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
主节点以外,继续修改/etc/ntp.conf
vi /etc/ntp.conf
在server部分添加如下语句,将server指向主节点
server 192.168.20.100
Fudge 192.168.20.100 stratum 10
修改/etc/sysconfig/ntpd 文件
增加内容如下(让硬件时间与系统时间一起同步)
vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
重新启动ntpd服务
service ntpd status
service ntpd start
chkconfig ntpd on
启动ntp服务
ntpstat
查看ntp服务器与上层ntp的状态
ntpq -p
设置开机启动
chkconfig ntpd on
设置了ntpd开机自启动,重启服务器ntpd没有自启动
1.需要禁掉chronyd.service:
systemctl disable chronyd.service
2.手动启动ntpd:
systemctl start ntpd
3.再次设置开机自启动:
systemctl enable ntpd
4.重启服务器测试ntpd即可正常自启动了
12.安装配置jdk1.8(所有节点)
2、安装新的jdk
安装流程
2.1)在cdh-100、cdh-101、cdh-102和hadoop103下创建文件夹
mkdir -p /usr/java/
2.2)将jdk-8u311-linux-x64.tar.gz解压到cdh-100的/usr/java目录
tar -zxvf /kdata/jdk-8u311-linux-x64.tar.gz -C /usr/java/
2.3)配置JDK环境变量
(1)打开/etc/profile文件
vi /etc/profile
在profile文件末尾添加JDK路径
#JAVA_HOME
export JAVA_HOME=/usr/java/jdk1.8.0_311
export CLASSPATH=./: J A V A H O M E / l i b e x p o r t P A T H = JAVA_HOME/lib export PATH= JAVAHOME/libexportPATH=PATH:$JAVA_HOME/bin
(2)让修改后的文件生效
source /etc/profile
2.4)测试JDK是否安装成功
java -version
java version “1.8.0_311”
2.5)将cdh-100中的JDK分发到cdh-101、cdh-102、cdh-103三台主机
scp -r /usr/java/jdk1.8.0_311/ cdh-101:/usr/java/
scp -r /usr/java/jdk1.8.0_311/ cdh-102:/usr/java/
scp -r /usr/java/jdk1.8.0_311/ cdh-103:/usr/java/
scp -r /usr/java/jdk1.8.0_311/ cdh-104:/usr/java/
2.6)分别在cdh-101、cdh-102、cdh-103上配置环境变量并source一下
在 /etc/profile中添加如下内容
vi /etc/profile
#JAVA_HOME
export JAVA_HOME=/usr/java/jdk1.8.0_311
export PATH= P A T H : PATH: PATH:JAVA_HOME/bin
执行
source /etc/profile
13.安装MySQL(主节点安装即可)
安装步骤:
(1)此处需要注意的是centos 7 默认安装的是mariadb,如果不卸载直接安装的话会报错,报错信息mariadb-libs is obsoleted by mysql-community-libs-5.7.20-1.el7.x86_64
rpm -qa | grep mariadb #查看安装信息
rpm -e mariadb-libs* --nodeps #根据查找到的软件包信息卸载
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
rpm -e mysql-community-common-5.7.36-1.el7.x86_64 --nodeps
rpm -e mysql-community-libs-5.7.36-1.el7.x86_64 --nodeps
rpm -e mysql-community-libs-compat-5.7.36-1.el7.x86_64 --nodeps
rpm -e mysql-community-client-5.7.36-1.el7.x86_64 --nodeps
rpm -e mysql-community-devel-5.7.36-1.el7.x86_64 --nodeps
rpm -e mysql-community-server-5.7.36-1.el7.x86_64 --nodeps
(2)将mysql的rpm包拷贝到/opt/software中,并安装MySQL(建议按顺序安装:common --> libs --> clients --> server,因为有依赖)
cd /kdata/mysql
检查之前安装版本
rpm -qa|grep mysql
卸载(如果上面查出需执行)
rpm -e mysql-community-common-5.7.25-1.el7.x86_64 --nodeps
执行(注意执行循序)
rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.36-1.el7.x86_64.rpm
yum localinstall -y net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
yum -y install net-tools
mysql8版本
rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.27-1.el7.x86_64.rpm --force --nodeps
yum -y install net-tools
rpm -ivh mysql-community-server-8.0.27-1.el7.x86_64.rpm
显示mysql的随机密码
grep ‘temporary password’ /var/log/mysqld.log
(m1Xl28stFP&
_:a/,2Psm:qh
登录并修改mysql密码
mysql -u root -p
1、需要执行如下语句修改密码:
set password=‘qj1314520@’;
2、如果密码符合Mysql要求,会修改成功。如果出现以下错误信息:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
执行如下两条语句:
set global validate_password.policy=0;
set global validate_password.length=1;
然后再次执行步骤1中的语句即可。
修改密码:
ALTER USER ‘root’@‘%’ IDENTIFIED BY ‘Qj1314520@’;
查看密码策略:
SHOW VARIABLES LIKE ‘validate_password%’;
修改密码长度:
set global validate_password.length=1;
修改密码等级:
set global validate_password.policy=0;
修改后再次查看
设置自己想要的密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;
1、修改密码过期
ALTER USER’root’@‘localhost’ IDENTIFIED BY ‘root’ PASSWORD EXPIRE NEVER;
2、重新修改密码
ALTER USER’root’@‘%’ IDENTIFIED WITH mysql_native_password BY ‘root’;
3、刷新权限(不做可能无法生效)
FLUSH PRIVILEGES;
CREATE USER ‘scm’@‘%’ IDENTIFIED BY ‘Hadoop3!’;
CREATE USER ‘scm’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘amon’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘rman’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘hue’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘metastore’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘sentry’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘nav’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘navms’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘oozie’@‘%’ IDENTIFIED BY ‘123456’;
CREATE USER ‘hive’@‘%’ IDENTIFIED BY ‘123456’;
grant all privileges on scm.* TO ‘scm’@‘%’;
grant all privileges on amon.* TO ‘amon’@‘%’;
grant all privileges on rman.* TO ‘rman’@‘%’ ;
grant all privileges on hue.* TO ‘hue’@‘%’ ;
grant all privileges on metastore.* TO ‘metastore’@‘%’;
grant all privileges on sentry.* TO ‘sentry’@‘%’ ;
grant all privileges on nav.* TO ‘nav’@‘%’ ;
grant all privileges on navms.* TO ‘navms’@‘%’ ;
grant all privileges on oozie.* TO ‘oozie’@‘%’;
grant all privileges on hive.* TO ‘hive’@‘%’;
(3)启动mysql
service mysqld start
(4)查看root初始密码
more /var/log/mysqld.log |grep password
root
ab.!vkoyf4Yk
开机启动
systemctl enable mysqld
(5)登录
mysql -u root -p
mysql -u root -p
输入密码
(6)修改密码规则以及修改密码
set global validate_password_length=6;
set global validate_password_policy=0;
set password = password(‘123456@’);
alter mysql.user ‘root’@‘%’ identified by ‘123456@’;
alter mysql.user ‘root’@‘localhost’ identified by ‘123456@’;
update user set authentication_string=password(“123456”) where user=“root”;
update mysql.user set authentication_string=password(‘123456@’) where user=‘root’;
(7)给任意IP授权(只要是用户root使用密码passwd就能从任意主机连接到mysql服务器)
GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ IDENTIFIED BY ‘123456@’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
(8)设置时区
vi /etc/my.cnf
(9)添加如下内容
default-time_zone = ‘+8:00’
(10)建数据库(如果需要安装下边的几个组件的话,需要先把数据库创建好)
(scm用户及数据库都由之后的脚本自动生成)
CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
grant all on scm.* to ‘scm’@‘%’ identified by ‘123456’;
grant all on amon.* to ‘amon’@‘%’ identified by ‘123456’;
grant all on rman.* to ‘rman’@‘%’ identified by ‘123456’;
grant all on hue.* to ‘hue’@‘%’ identified by ‘123456’;
grant all on metastore.* to ‘hive’@‘%’ identified by ‘123456’;
grant all on sentry.* to ‘sentry’@‘%’ identified by ‘123456’;
grant all on nav.* to ‘nav’@‘%’ identified by ‘123456’;
grant all on navms.* to ‘navms’@‘%’ identified by ‘123456’;
grant all on oozie.* to ‘oozie’@‘%’ identified by ‘123456’;
#scm库和权限暂时不创建,后面指定数据库,会自动创建
#CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
#GRANT ALL ON scm.* TO ‘scm’@‘%’ IDENTIFIED BY ‘123456’;
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON amon.* TO ‘amon’@‘%’ IDENTIFIED BY ‘123456’;
GRANT ALL ON rman.* TO ‘rman’@‘%’ IDENTIFIED BY ‘123456’;
GRANT ALL ON metastore.* TO ‘hive’@‘%’ IDENTIFIED BY ‘123456’;
GRANT ALL ON hue.* TO ‘hue’@‘%’ IDENTIFIED BY ‘123456’;
GRANT ALL ON oozie.* TO ‘oozie’@‘%’ IDENTIFIED BY ‘123456’;
#####注意此处再授权一个本主机名地址,不然web页面配置很容易出错,注意修改本地主机名hostname
GRANT ALL ON amon.* TO ‘amon’@‘本主机名’ IDENTIFIED BY ‘amon’;
#刷新源
FLUSH PRIVILEGES;
FLUSH PRIVILEGES;
(11)安装mysql驱动
mkdir -p /usr/share/java/
注意:默认位置 /usr/share/java/ ,默认驱动名 mysql-connector-java.jar
一定要这个名字(mysql-connector-java.jar),否则会报错Unable to find JDBC driver for database type: MySQL
#解压
tar zxvf /kdata/mysql-connector-java-5.1.46.tar.gz -C /kdata/module/
cd /usr/share/java/
cp /kdata/module/mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar
scp /usr/share/java/mysql-connector-java.jar cdh-101:/usr/share/java/
scp /usr/share/java/mysql-connector-java.jar cdh-102:/usr/share/java/
scp /usr/share/java/mysql-connector-java.jar cdh-103:/usr/share/java/
scp /usr/share/java/mysql-connector-java.jar cdh-104:/usr/share/java/
14.安装Cloudera Manger
建议离线安装,把rpm包下载到服务器上面,传到其他节点一份,再本地安装,速度会快很多。
cdh-100
执行
yum install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
或
yum install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server –y
或
rpm –ivh –-nodeps –-force cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
其他
yum install cloudera-manager-daemons cloudera-manager-agent
或
yum install cloudera-manager-daemons cloudera-manager-agent –y
为Cloudera Manager建立数据库
/opt/cloudera/cm/schema/scm_prepare_database.sh
【这里报错了】com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
mysql jar 需要用8版本
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql -hlocalhost -uroot -p scm scm
/opt/cloudera/cm/schema/scm_prepare_database.sh -h 192.168.20.100 mysql scm scm 123456
如果上面的命令不好用,则可以使用下边的命令,但是需要先创建scm用户与scm库,并允许localhost访问。否则会报错
数据库操作
mysql -u root –p
输入密码
create database scm DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
grant all on . to ‘scm’@‘%’ identified by ‘123456’ WITH GRANT OPTION;
flush privileges;
建表
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm 123456
配置Agent
在所有节点上执行修改agent的配置,
vi /etc/cloudera-scm-agent/config.ini
server_host=cdh-100
准备parcels,将CDH相关文件拷贝到主节点/opt/cloudera/parcel-repo
CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel
CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1
CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha256
manifest.json
需要将CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1
改成CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha,否则安装时会重新下载,很重要!!
mv CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1 CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha
启动
#主节点
systemctl restart cloudera-scm-server
systemctl restart cloudera-scm-agent
主节点:
sudo systemctl enable cloudera-scm-agent
sudo systemctl enable cloudera-scm-server
(进入登录页面后启动agent)
#主节点及其他节点
systemctl start cloudera-scm-agent
systemctl enable cloudera-scm-agent
systemctl status cloudera-scm-server
systemctl status cloudera-scm-agent
journalctl -xe
/var/log/cloudera-scm-server
启动需要点时间,可以查看数据库scm中的hosts表,如果里面出现节点信息表示server启动完成
登录 http://192.168.20.100:7180/cmf/login
登录界面,默认登录用户名和密码都是admin
15.安装CDH6.3.2
选择安装版本(免费)
修改集群名称
为CDH群集安装指定主机
选择CDH版本安装
检查环境
分别点击 Inspect Network Performance 与 Inspect Hosts
发现异常,点击 显示检查器结果
chmod -R 755 /var/lib/hadoop-yarn/
解决方案
第一个警告直接在所有节点上执行echo 10 > /proc/sys/vm/swappiness
第二个警告按照上面的说明,在所有节点上执行这两条命令
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
然后将命令写到 /etc/rc.local,保证每次重启时能执行
配置完成后。重新运行监测程序
群集设置–选择安装服务–按需选择
这里全选(All Services),continue
选择主机上的服务安排,这里根据需要自行配置
输入组件上的数据库信息,这里有hive、oozie、hue的数据库名应为hive、oozie、hue,用户名root,密码root,点击test connection,连接测试成功后点击continue
开始执行安装命令
安装完成
hdfs dfs -ls /
hdfs dfs -chmod -R 777 /tmp