一、环境准备
参考链接:https://www.cnblogs.com/zhangzhide/p/11108472.html
二、安装jdk(三台主机都要做)
下载jdk安装包并解压:tar xvf jdk-8u131-linux-x64.tar.gz -C /usr/local/ #三台主机都要执行
配置环境变量:
vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/local/jdk1.8.0_131
export PATH=$PATH:$JAVA_HOME/bin
使java.sh配置生效:source /etc/profile.d/java.sh
测试:
[root@master jdk1.8.0_131]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
三、安装集群所需的依赖包(三台主机都要做)
yum install chkconfig python bind-utils psmisc libxslt zlib sqlite cyrus-sasl-plain cyrus-sasl-gssapi fuse fuse-libs redhat-lsb -y
四、安装数据库
从官网下载mysql5.7的压缩包,我用的是这个版本:mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz;这里要着重强调一下,千万不要用yum去安装mysql;在CentOS7上yum安装的是mariadb5.5版本的,最后在初始化CDH的时候会提示你CDH版本过老;换成mysql-5.7就解决了;
mysql只安装在其中一台机器上就成了;如果设备富裕的话,可以搞个主从同步;
tar xvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
1、配置mysql环境变量:
[root@master local]# cat /etc/profile.d/mysql.sh
export MYSQL_HOME=/usr/local/mysql-5.7.25
export PATH=$PATH:$MYSQL_HOME/bin
2、让环境变量配置文件生效:
[root@master ~]# source /etc/profile.d/mysql.sh
[root@master ~]# which mysql
/usr/local/mysql-5.7.25/bin/mysql
3、创建mysql用户
[root@master ~]# useradd -s /sbin/nologin mysql #创建mysql用户并禁止登陆
[root@master ~]# chown mysql:mysql -R /usr/local/mysql-5.7.25 #给mysql目录加属主属组
4、创建mysqldata目录
[root@master ~]# mkdir /usr/local/mysql-5.7.25/data
并且也要修改属主属组:chown mysql:mysql /usr/local/mysql-5.7.25/data
5、mysql初始化
[root@master ~]# mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7.25
2019-07-03T06:14:08.907861Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-07-03T06:14:17.286448Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-07-03T06:14:18.591100Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-07-03T06:14:18.958493Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: caae596c-9d59- 11e9-8e15-101a4a160209.
2019-07-03T06:14:19.040304Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-07-03T06:14:19.041357Z 1 [Note] A temporary password is generated for root@localhost: .EP.1UJ9t3hs(生成的临时密码,这个密码要记住,等会要用到)
6、修改mysql配置文件
[root@master ~]# vim /etc/my.cnf
[root@master ~]# cat /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql-5.7.25/
datadir=/usr/local/mysql-5.7.25/data/
7、启动mysql服务
[root@master ~]# cp /usr/local/mysql-5.7.25/support-files/mysql.server /etc/init.d/
[root@master ~]# /etc/init.d/mysql.server start #启动mysql服务
Starting MySQL.Logging to '/usr/local/mysql-5.7.25/data/master.err'.
. SUCCESS! #当看到这个字样时表示成功了;
[root@master ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 80 :::3306 #数据库端口也开启了;
8、通过生成的临时密码登陆mysql并修改临时密码
mysql -uroot -p.EP.1UJ9t3hs
mysql> alter user user() identified by '123.com'; #修改mysql密码
Query OK, 0 rows affected (0.00 sec)
五、安装Cloudera Manager
官方下载链接:http://archive.cloudera.com/cm5/cm/5/
我用这个版本:cloudera-manager-centos7-cm5.15.1_x86_64.tar.gz;下载完成之后,需要将该安装包传到每个节点;
1、创建解压目录,官方默认解压目录是“/opt/cloudera-manager”;建议在学习阶段用这个目录,否则在安装Cloudera Manager的时候选择数据目录的时候需要修改成自定义的目录,并重启服务;为了不必要的麻烦还是用这个目录,我在之前做的时候用的是“/data/softwares/cloudera-manager”,然后在安装阶段改成“/data/softwares/cloudera-manager”这个后还重启了服务,貌似没起作用,后来重启设备才好的;
[root@master ~]# ansible cdh -m shell -a ”mkdir /opt/cloudera-manager“
[root@master ~]# ansible cdh -m shell -a "tar -zxf /root/cloudera-manager-centos7-cm5.15.1_x86_64.tar.gz -C /opt/cloudera-manager/"
[root@master ~]# ansible cdh -m shell -a "sed -i 's/server_host=localhost/server_host=master/g' /opt/cloudera-manager/cm-5.15.1/etc/cloudera-scm-agent/config.ini" #CM服务器器默认是localhost所以每个节点的cmserver都需要改成master;
[root@master ~]# ansible cdh -m shell -a "cat /opt/cloudera-manager/cm-5.15.1/etc/cloudera-scm-agent/config.ini|grep server_host"
node2 | CHANGED | rc=0 >>
server_host=master
node1 | CHANGED | rc=0 >>
server_host=master
master | CHANGED | rc=0 >>
server_host=master
2、在所有节点上创建cloudera-scm用户
[root@master ~]# ansible cdh -m shell -a 'useradd --system --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm'
[root@master ~]# ansible cdh -m shell -a "cat /etc/passwd |grep cloudera-scm"
node2 | CHANGED | rc=0 >>
cloudera-scm:x:997:993:Cloudera SCM User:/home/cloudera-scm:/bin/false
node1 | CHANGED | rc=0 >>
cloudera-scm:x:993:989:Cloudera SCM User:/home/cloudera-scm:/bin/false
master | CHANGED | rc=0 >>
cloudera-scm:x:993:989:Cloudera SCM User:/home/cloudera-scm:/bin/false
3、
tar xvf mysql-connector-java-5.1.47.tar.gz
mkdir /usr/share/java && cd /usr/share/java
cp /root/mysql-connector-java-5.1.47/mysql-connector-java-5.1.47-bin.jar /usr/share/java/
ln -s mysql-connector-java-5.1.47-bin.jar mysql-connector-java.jar
六、初始化CMserver数据库
mysql> GRANT ALL PRIVILEGES ON *.* TO 'cdh'@'10.0.8.%' IDENTIFIED BY '123.com' WITH GRANT OPTION;
[root@master schema]# ./scm_prepare_database.sh mysql cdh -h 10.0.8.107 -ucdh -p123.com --scm-host 10.0.8.107 scm scm scm
JAVA_HOME=/usr/local/jdk1.8.0_131
Verifying that we can write to /opt/cloudera-manager/cm-5.15.1/etc/cloudera-scm-server
Wed Jul 03 10:52:39 EDT 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Creating SCM configuration file in /opt/cloudera-manager/cm-5.15.1/etc/cloudera-scm-server
Executing: /usr/local/jdk1.8.0_131/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-manager/cm- 5.15.1/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /opt/cloudera-manager/cm-5.15.1/etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
Wed Jul 03 10:52:40 EDT 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2019-07-03 10:52:41,015 [main] INFO com.cloudera.enterprise.dbutil.DbCommandExecutor - Successfully connected to database. #当看到这个的时候就初始化成功了;
All done, your SCM database is configured correctly!
七、制作CDH本地源
1、在server端创建parcel-repo目录
mkdir -pv /opt/cloudera/parcel-repo
chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
2、在agent端创建parcels目录
[root@master ~]# ansible cdh -m shell -a 'mkdir -pv /opt/cloudera/parcels'
[root@master ~]# ansible cdh -m shell -a "chown cloudera-scm:cloudera-scm /opt/cloudera/parcels"
3、将下载的CDH包放在
[root@master CHD-5.15.1]# mv /root/CHD-5.15.1/CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel /opt/cloudera/parcel-repo/
[root@master CHD-5.15.1]# mv /root/CHD-5.15.1/manifest.json /opt/cloudera/parcel-repo/
[root@master CHD-5.15.1]# mv /root/CHD-5.15.1/CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel.sha1 /opt/cloudera/parcel-repo/CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel.sha #这时候要注意改名
[root@master CHD-5.15.1]# cd /opt/cloudera/parcel-repo/
[root@master parcel-repo]# ls
CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel.sha manifest.json
八、启动Cloudera Manager Server端
[root@master init.d]# pwd
/opt/cloudera-manager/cm-5.15.1/etc/init.d #启动路径,server端和agent端都是这个启动路径
[root@master init.d]# ll
total 32
-rwxr-xr-x 1 1106 4001 8871 Jul 31 2018 cloudera-scm-agent
-rwxr-xr-x 1 1106 4001 8417 Jul 31 2018 cloudera-scm-server
-rwxr-xr-x 1 1106 4001 4444 Jul 31 2018 cloudera-scm-server-db
[root@master init.d]# ./cloudera-scm-server start #启动CM Server端
Starting cloudera-scm-server: [ OK ]
查看启动日志:
[root@master cloudera-scm-server]# tailf /opt/cloudera-manager/cm-5.15.1/log/cloudera-scm-server/cloudera-scm-server.log
当在日志种看到7180端口的时候,就可以访问web界面进行安装了;
也可以ss查看端口:7182是server通信端口;7180是web访问端口;
九、启动Cloudera Manager Agent端
[root@master init.d]# ansible cdh -m shell -a "/opt/cloudera-manager/cm-5.15.1/etc/init.d/cloudera-scm-agent start" #ansible批量启动CM Agent端
[root@master init.d]# ansible cdh -m shell -a "/opt/cloudera-manager/cm-5.15.1/etc/init.d/cloudera-scm-agent status" #查看状态
master | CHANGED | rc=0 >>
cloudera-scm-agent (pid 26708) is running...
node2 | CHANGED | rc=0 >>
cloudera-scm-agent (pid 20702) is running...
node1 | CHANGED | rc=0 >>
cloudera-scm-agent (pid 30247) is running...
十、访问web界面开始安装CDH服务
登陆界面长这样,账户密码都是admin/admin
允许cloudera manager的条款一路下一步到选择版本那,选择免费版;
选择安装CDH集群的主机,如果能显示当前管理主机的数量是对的,则不用管,如果数量跟你想的不一样则点新主机可以指定条件搜索;
在这个地方可以选择更多选项将多余的项目删掉;
这个时候就只剩下这本地源的一个选项了;
正式安装:这个过程会持续很长一段时间,我这个基本上持续了1个小时;
在上一步结束到下一步检查主机的时候我这报了一个错:
解决方法:
根据提示我查看了三台主机的swappliness的值均为30;
[root@master ~]# ansible cdh -m shell -a "cat /proc/sys/vm/swappiness"
master | CHANGED | rc=0 >>
30
node2 | CHANGED | rc=0 >>
30
node1 | CHANGED | rc=0 >>
30
1>临时修改:
[root@master ~]# ansible cdh -m shell -a "sysctl vm.swappiness=10"
2>永久就修改:
[root@master ~]# ansible cdh -m shell -a "echo 'vm.swappiness=10'>> /etc/sysctl.conf"
将vm.swappiness=10写入sysctl.conf配置文件中;
修改完成之后点击检查主机正确性重新运行,直到全部ok;
集群设置选择自定义服务,安装hdfs、yarn、zookeeper这三个服务就好;
角色分配
默认就好
安装hdfs、yarn、zookeeper;当全部是√的时候下一步;如果中间出错点击重试即可;
当出现下图界面的时候,表示安装成功;
最终CDH主界面长这样