搭建德国CDH(踩坑无数后整理版)
注: 发出来的文档包含IP皆为内网IP,密码也为文档效果更改
#####三台CentOS Linux release 7.5.1804 (Core)服务器:
[cdh]
172.17.4.9
172.17.4.10
172.17.4.11
#####新建一个普通用户,给予超级用户权限(所有节点):
[root@cdh1-172-17-4-9 ~]# groupadd -r aiot
[root@cdh1-172-17-4-9 ~]# useradd -d /home/aiot/ -m -s /bin/bash -c “administrator user” -g aiot -p passwd -r aiot
[root@cdh1-172-17-4-9 ~]# passwd aiot
更改用户 aiot 的密码 。
新的 密码:passwd
无效的密码: 密码包含用户名在某些地方
重新输入新的 密码:passwd
passwd:所有的身份验证令牌已经成功更新。
[root@cdh1-172-17-4-9 ~]# vim /etc/sudoers
1 |
|
#####安装必要包(所有节点):
yum install httpd -y
yum install ntp -y
#####配置域名解析、主机名(所有节点):
[root@cdh1-172-17-4-9 ~]# cat /etc/hosts
1 |
|
[root@cdh1-172-17-4-9 ~]# hostnamectl set-hostname cdh1-172-17-4-9
[root@cdh2-172-17-4-10 ~]# cat /etc/hosts
1 |
|
[root@cdh2-172-17-4-10 ~]# hostnamectl set-hostname cdh2-172-17-4-10
[root@cdh3-172-17-4-11 ~]# cat /etc/hosts
1 |
|
[root@cdh3-172-17-4-11 ~]# hostnamectl set-hostname cdh3-172-17-4-11
#####关闭防火墙和SELINUX(所有节点):
[root@cdh1-172-17-4-9 ~]# getenforce
Disabled
[root@cdh1-172-17-4-9 ~]# systemctl stop firewalld
[root@cdh1-172-17-4-9 ~]# systemctl disable firewalld.service
[root@cdh1-172-17-4-9 ~]# vim /etc/selinux/config
SELINUX=disabled
#####切换普通用户,配置三机互信(所有节点):
[root@cdh1-172-17-4-9 ~]# su - aiot
[aiot@cdh1-172-17-4-9 ~]$ whoami
aiot
[aiot@cdh1-172-17-4-9 ~]$ mkdir .ssh
[aiot@cdh1-172-17-4-9 ~]$ chmod 750 .ssh
[aiot@cdh1-172-17-4-9 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/aiot//.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/aiot//.ssh/id_rsa.
Your public key has been saved in /home/aiot//.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:MEtv2UxJl5VddGmG+RegPLaTi8n2Z0fo6LHHEbJthYw aiot@cdh1-172-17-4-9
The key’s randomart image is:
+—[RSA 2048]—-+
| . .+=+|
| ..ooo.=o|
| + o=o = .|
| . = =.E++ o.|
| . S o++ + .|
| .. o.o= . |
| = o= o |
| . ..o . |
| .++ . |
+—-[SHA256]—–+
[aiot@cdh1-172-17-4-9 ~]$ cat /home/aiot/.ssh/id_rsa.pub >> /home/aiot/.ssh/authorized_keys
[aiot@cdh1-172-17-4-9 ~]$ chmod 600 /home/aiot/.ssh/authorized_keys
[aiot@cdh1-172-17-4-9 ~]$ cat .ssh/authorized_keys
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ vim .ssh/authorized_keys
[aiot@cdh1-172-17-4-9 ~]$ cat .ssh/authorized_keys
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ ssh 172.17.4.10 date
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘172.17.4.10’ (ECDSA) to the list of known hosts.
Mon Dec 23 10:16:27 CST 2019
[aiot@cdh1-172-17-4-9 ~]$ logout
#####配置时钟同步(所有节点):
[root@cdh1-172-17-4-9 ~]# sudo vim /etc/ntp.conf
1 |
|
[root@cdh1-172-17-4-9 ~]# sudo systemctl enable ntpd
[root@cdh1-172-17-4-9 ~]# sudo systemctl start ntpd
[root@cdh1-172-17-4-9 ~]# sudo systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2019-12-23 09:56:25 CST; 22min ago
Main PID: 10113 (ntpd)
CGroup: /system.slice/ntpd.service
└─10113 /usr/sbin/ntpd -u ntp:ntp -g
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: Listen normally on 0 lo 127.0.0.1 UDP 123
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: Listen normally on 1 eth0 172.17.4.9 UDP 123
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: Listen normally on 2 lo ::1 UDP 123
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: Listen normally on 3 eth0 fe80::5054:ff:feeb:37bf UDP 123
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: Listening on routing socket on fd #20 for interface updates
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: 0.0.0.0 c016 06 restart
12月 23 09:56:25 cdh1-172-17-4-9 ntpd[10113]: 0.0.0.0 c012 02 freq_set kernel -2.846 PPM
12月 23 09:56:25 cdh1-172-17-4-9 systemd[1]: Started Network Time Service.
12月 23 09:56:32 cdh1-172-17-4-9 ntpd[10113]: 0.0.0.0 c615 05 clock_sync
#####禁用大透明页,设置vm.swappiness(主节点):
[root@cdh1-172-17-4-9 ~]# sudo vim /etc/sysctl.conf
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ sudo sysctl vm.swappiness=10
vm.swappiness = 10
[aiot@cdh1-172-17-4-9 ~]$ sudo vim /etc/rc.local
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ sudo chmod +x /etc/rc.d/rc.local
并在终端使用root执行
1 |
|
#####安装jdk(所有节点):
[aiot@cdh1-172-17-4-9 ~]$ sudo rpm -qa | grep java
[aiot@cdh1-172-17-4-9 ~]$ sudo mkdir -p /usr/java
下载java、mysql-connecter
[aiot@cdh1-172-17-4-9 ~]$ sudo tar -zxvf /tmp/jdk-8u181-linux-x64.tar.gz -C /usr/java/
[aiot@cdh1-172-17-4-9 ~]$ sudo ln -s /usr/java/jdk1.8.0_181 /usr/java/jdk
[aiot@cdh1-172-17-4-9 ~]$ sudo vim /etc/profile
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ source /etc/profile
[aiot@cdh1-172-17-4-9 ~]$ vim ~/.bashrc
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ vim ~/.bash_profile
export JAVA_HOME=/usr/java/jdk
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATH
[aiot@cdh1-172-17-4-9 ~]$ echo $JAVA_HOME
/usr/java/jdk
#####拷贝数据库连接jar包(所有节点):
[aiot@cdh1-172-17-4-9 ~]$ sudo mkdir -p /usr/share/java
[aiot@cdh1-172-17-4-9 ~]$ sudo cp /tmp/mysql-connector-java-5.1.46.jar /usr/share/java/mysql-connector-java.jar
[aiot@cdh1-172-17-4-9 ~]$ ls /usr/share/java/
mysql-connector-java.jar
#####安装mysql57并建库授权(所有节点):
[aiot@cdh1-172-17-4-9 ~]$ sudo rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[aiot@cdh1-172-17-4-9 ~]$ sudo rpm -e mariadb-libs-5.5.56-2.el7.x86_64 –nodeps
[aiot@cdh1-172-17-4-9 ~]$ sudo rpm -qa | grep mariadb
[aiot@cdh1-172-17-4-9 ~]$ sudo yum -y install libaio
[aiot@cdh2-172-17-4-10 ~]$ cd /tmp
[aiot@cdh2-172-17-4-10 tmp]$ ls
2f0a2e365ded13cde49324756eacd7de nv_driver_install.log
ansible_command_payload_Vt5UHt nv_gpu_conf.log
cvm_init.log setRps.log
hsperfdata_root systemd-private-21cc3095c6d247a897c48ae1c72ff7c6-ntpd.service-e0cbwM
jdk-8u181-linux-x64.tar.gz systemd-private-62cdd337e72f463daa0d3e2e36bc16a9-ntpd.service-hG5zxr
mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar virtio_blk_affinity.log
mysql-connector-java-5.1.46.jar virtio_blk_affinity_udev.log
net_affinity.log
[aiot@cdh2-172-17-4-10 tmp]$ tar -xvf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
mysql-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm
mysql-community-embedded-5.7.20-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
mysql-community-libs-5.7.20-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.20-1.el7.x86_64.rpm
mysql-community-devel-5.7.20-1.el7.x86_64.rpm
mysql-community-server-5.7.20-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm
mysql-community-client-5.7.20-1.el7.x86_64.rpm
mysql-community-test-5.7.20-1.el7.x86_64.rpm
mysql-community-common-5.7.20-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.20-1.el7.x86_64.rpm
参考: http://www.seaxiang.com/blog/mysql_libnuma_error
[aiot@cdh1-172-17-4-9 aiot]$ sudo yum install numactl
sudo rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-5.7.20-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
[aiot@cdh1-172-17-4-9 aiot]$ sudo mkdir -p /data/mysqldata/mysql
[aiot@cdh2-172-17-4-10 aiot]$ sudo su
[root@cdh2-172-17-4-10 aiot]# cp /etc/my.cnf /tmp
[root@cdh2-172-17-4-10 aiot]# echo > /etc/my.cnf
[root@cdh2-172-17-4-10 aiot]# vim /etc/my.cnf
1 |
|
[root@cdh1-172-17-4-9 aiot]# exit
[aiot@cdh1-172-17-4-9 aiot]$ sudo systemctl enable mysqld
[aiot@cdh1-172-17-4-9 aiot]$ sudo systemctl start mysqld
[aiot@cdh1-172-17-4-9 aiot]$ sudo systemctl status mysqld -l
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2019-12-23 12:02:52 CST; 4s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 28580 ExecStart=/usr/sbin/mysqld –daemonize –pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 28486 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 28583 (mysqld)
CGroup: /system.slice/mysqld.service
└─28583 /usr/sbin/mysqld –daemonize –pid-file=/var/run/mysqld/mysqld.pid
Dec 23 12:02:42 cdh1-172-17-4-9 systemd[1]: Starting MySQL Server…
Dec 23 12:02:52 cdh1-172-17-4-9 systemd[1]: Started MySQL Server.
[aiot@cdh1-172-17-4-9 aiot]$ sudo grep ‘temporary password’ /var/log/mysqld.log
2019-12-23T04:02:49.050303Z 1 [Note] A temporary password is generated for root@localhost: JwXY&drNk6l0
[aiot@cdh1-172-17-4-9 aiot]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20-log
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
1 |
|
#####配置httpd(主节点):
[aiot@cdh1-172-17-4-9 aiot]$ sudo vim /etc/httpd/conf/httpd.conf
1 |
|
[aiot@cdh1-172-17-4-9 aiot]$ sudo systemctl start httpd
[aiot@cdh1-172-17-4-9 aiot]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2019-12-23 12:23:22 CST; 2min 18s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 31242 (httpd)
Status: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec”
CGroup: /system.slice/httpd.service
├─31242 /usr/sbin/httpd -DFOREGROUND
├─31243 /usr/sbin/httpd -DFOREGROUND
├─31244 /usr/sbin/httpd -DFOREGROUND
├─31245 /usr/sbin/httpd -DFOREGROUND
├─31246 /usr/sbin/httpd -DFOREGROUND
└─31247 /usr/sbin/httpd -DFOREGROUND
Dec 23 12:23:22 cdh1-172-17-4-9 systemd[1]: Starting The Apache HTTP Server…
Dec 23 12:23:22 cdh1-172-17-4-9 httpd[31242]: AH00558: httpd: Could not reliably determine the server’s fully qua…ssage
Dec 23 12:23:22 cdh1-172-17-4-9 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[aiot@cdh1-172-17-4-9 aiot]$ sudo systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
#####搭建本地仓库(海外服务器很快(主节点):)
1 |
|
[aiot@cdh2-172-17-4-10 ~]$ sudo chmod -R ugo+rX /var/www/html/cloudera-repos/cdh6
[aiot@cdh2-172-17-4-10 ~]$ sudo chmod -R ugo+rX /var/www/html/cloudera-repos/gplextras6
[aiot@cdh2-172-17-4-10 ~]$ sudo chmod -R ugo+rX /var/www/html/cloudera-repos/cm6
[aiot@cdh2-172-17-4-10 ~]$ sudo chmod -R ugo+rX /var/www/html/cloudera-repos/kafka
[aiot@cdh2-172-17-4-10 ~]$ sudo chmod -R ugo+rX /var/www/html/cloudera-repos/sqoop-connectors
#####配置本地yum源(所有节点,源指向主节点):
[aiot@cdh1-172-17-4-9 ~]$ cat /etc/yum.repos.d/cloudera-manager6.2.0.repo
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ cat /etc/yum.repos.d/cloudera-manager-gplextras6.2.0.repo
1 |
|
sudo wget –recursive –no-parent –no-host-directories http://archive.cloudera.com/gplextras6/6.2.0/redhat7/yum/repodata/ -P /var/www/html/cloudera-repos
[aiot@cdh1-172-17-4-9 ~]$ sudo yum clean all
[aiot@cdh1-172-17-4-9 ~]$ sudo yum makecache
#####更新系统
[aiot@cdh1-172-17-4-9 ~]$ sudo yum update
#####安装cloudera
[aiot@cdh1-172-17-4-9 ~]$ sudo yum -y search cloudera-manager
1 |
|
[aiot@cdh1-172-17-4-9 ~]$ sudo yum install cloudera-manager-daemons cloudera-manager-server
[aiot@cdh1-172-17-4-9 ~]$ sudo -E /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm ‘Aiot2019!@$’
···
JAVA_HOME=/usr/java/jdk
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/java/jdk/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.
Mon Dec 23 15:24:48 CST 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.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
···
[aiot@cdh1-172-17-4-9 ~]$ sudo mkdir -p /data/cloudera/parcels
[aiot@cdh1-172-17-4-9 ~]$ sudo chown -R cloudera-scm:cloudera-scm /data/cloudera/parcels
[aiot@cdh1-172-17-4-9 ~]$ sudo chown -R cloudera-scm:cloudera-scm /data/cloudera
[aiot@cdh1-172-17-4-9 ~]$ sudo mkdir -p /data/cloudera/parcel-repo
[aiot@cdh1-172-17-4-9 ~]$ sudo chown -R cloudera-scm:cloudera-scm /data/cloudera/parcel-repo
[aiot@cdh1-172-17-4-9 ~]$ sudo chown -R cloudera-scm:cloudera-scm /data/cloudera
[aiot@cdh1-172-17-4-9 ~]$ sudo mkdir -p /data/cloudera/parcel-cache
[aiot@cdh1-172-17-4-9 ~]$ sudo chown -R cloudera-scm:cloudera-scm /data/cloudera/parcel-cache
[aiot@cdh1-172-17-4-9 ~]$ sudo chown -R cloudera-scm:cloudera-scm /data/cloudera/
[aiot@cdh1-172-17-4-9 ~]$ sudo systemctl start cloudera-scm-server
[aiot@cdh1-172-17-4-9 ~]$ sudo systemctl status cloudera-scm-server
[aiot@cdh1-172-17-4-9 ~]$ sudo tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
1 |
|