首先大家得弄个自己的内网Nexus3仓库。
配置yum代理仓库地址:https://archive.cloudera.com/
yum仓库文件下载地址:https://archive.cloudera.com/cm6/6.3.1/redhat7/yum/cloudera-manager.repo
下载好后如果配置了Nexus3仓库yum代理的话可以修改https://archive.cloudera.com为你的私服地址https://repo.xxx.com
然后把这个repo文件放到centos 系统的 /etc/yum.repos.d/目录下重新清理生成缓存就好了。
命令为:yum clean all && yum makecache
大家可以用docker run -d -p 8081:8081 zouchengli/nexus3-apk 临时启动一个,公司有的话最好。直接搞起。
大家准备两台或多台服务器吧。我这里准备三台。
我安装的centos7迷你版。也就是目前官网提供的最小容量镜像。
下载地址为:https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2003.iso
1.节点准备(3个节点)
node1 | 192.168.168.81 | Cloudera Manager Server&Agent ,MariaDB |
node2 | 192.168.168.82 | Cloudera Manager Agent |
node3 | 192.168.168.83 | Cloudera Manager Agent |
2.配置主机名和hosts解析(所有节点)
编辑/etc/hostname,修改主机名,并使用命令hostname使其立刻生效。编辑文件/etc/hosts,增加如下内容。
192.168.168.81 node1
192.168.168.82 node2
192.168.168.83 node3
3.关闭防火墙和SELinux
[root@node1 ~]# systemctl stop firewalld && systemctl disable firewalld
[root@node1 ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
[root@node1 ~]# setenforce 0
4.配置时间同步服务器和客户端(一般都自带了,没有的话可以安装)
[root@node1 ~]# yum -y install chrony
编辑 /etc/chrony.conf 文件
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
server ntp5.aliyun.com iburst
server ntp6.aliyun.com iburst
server ntp7.aliyun.com iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
allow 192.168.168.0/24
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
重启服务
[root@node1 ~]# systemctl enable chronyd && systemctl restart chronyd
检查时间同步
[root@node1 ~]# chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ 120.25.115.20 2 8 377 222 -1144us[-1144us] +/- 21ms
^* 203.107.6.88 2 8 377 230 -2508us[-2312us] +/- 18ms
节点2,3同样安装
[root@node2 ~]# yum -y install chrony
节点2,3同样编辑 /etc/chrony.conf 文件
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 192.168.168.81 iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
节点2,3同样重启服务
[root@node2 ~]# systemctl enable chronyd && systemctl restart chronyd
检查时间同步
[root@node2 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.168.81 3 6 377 14 +18us[ +21us] +/- 18ms
5.禁用透明大页面压缩,CDH配置必须
[root@node1 ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag
[root@node1 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
并将上面的两条命令写入开机自启动/etc/rc.local。
6.优化交换分区
[root@node1 ~]# echo "vm.swappiness = 10" >> /etc/sysctl.conf
[root@node1 ~]# sysctl -p
7.安装jdk8,cdh server && agent
[root@node1 ~]# yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
[root@node1 ~]# yum -y install cloudera-manager-server cloudera-manager-agent
其他节点只需要安装agent即可
[root@node2 ~]# yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
[root@node2 ~]# yum -y install cloudera-manager-agent
8.安装数据库
[root@node1 ~]# yum -y install mariadb*
修改配置文件/etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
transaction-isolation = READ-COMMITTED
symbolic-links = 0
key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
log_bin=/var/lib/mysql/mysql_binary_log
server_id=1
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
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
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
!includedir /etc/my.cnf.d
启动服务(内存必须大于4G)
[root@node1 ~]# systemctl enable mariadb && systemctl restart mariadb
初始化数据库 root默认初始密码为空,第一步直接回车即可。
[root@node1 ~]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
9,下载mysql驱动jar包(所有节点)
[root@node1 ~]# mkdir -p /usr/share/java
[root@node1 ~]# cd /usr/share/java
[root@node1 java]# curl -O https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar
[root@node1 java]# mv mysql-connector-java-5.1.38.jar mysql-connector-java.jar
10.制作一个cdh.sql文件,内容如下:
CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON scm.* TO 'scm'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON amon.* TO 'amon'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON rman.* TO 'rman'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON hue.* TO 'hue'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON metastore.* TO 'hive'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON sentry.* TO 'sentry'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON nav.* TO 'nav'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON navms.* TO 'navms'@'%' IDENTIFIED BY 'clzlinux';
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON oozie.* TO 'oozie'@'%' IDENTIFIED BY 'clzlinux';
关系对应图
完成后执行该文件
[root@node1 ~]# mysql -uroot -p<ROOT_PASSWORD> < cdh.sql
[root@node1 ~]# mysql -uroot -pcdh6pwd
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| amon |
| hue |
| metastore |
| mysql |
| nav |
| navms |
| oozie |
| performance_schema |
| rman |
| scm |
| sentry |
+--------------------+
12 rows in set (0.01 sec)
MariaDB [(none)]>
11.设置 Cloudera Manager 数据
[root@node1 ~]# /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm
Enter SCM password:
JAVA_HOME=/usr/lib/jvm/java-openjdk
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing: /usr/lib/jvm/java-openjdk/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.
[ main] DbCommandExecutor INFO Successfully connected to database.
All done, your SCM database is configured correctly!
12.启动服务
[root@node1 ~]# systemctl start cloudera-scm-server
[root@node1 ~]# tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
13.WEB访问地址http://192.168.168.81:7180 默认用户名密码都是admin。