1 前言
现在借着做项目的机会在CentOS 7.3环境中再次部署了一套比较新的版本。基于共享的精神,本文给有需要的人参阅。
旧一点的版本安装请参阅(CentOS 6):
<a href="http://cmdschool.blog.51cto.com/2420395/1775398" target="_blank">http://cmdschool.blog.51cto.com/2420395/1775398</a>
2 实践部分
2.1 基本信息
Hostname=HD0[1-5].cmdschool.org
Ipaddress=10.168.0.2[4-8]
OS Version=CentOS 7.3
2.2 环境配置
2.2.1 配置IP地址
In HD01-05:
1
2
3
4
5
6
7
8
9
10
11
<code>nmcli connection delete </code><code>"Wired connection 1"</code>
<code>nmcli connection show</code>
<code>nmcli device show</code>
<code>nmcli connection add ifname ens192 con-name ens192 </code><code>type</code> <code>ethernet</code>
<code>nmcli connection modify ens192 ipv4.address </code><code>"10.168.0.XX/24"</code>
<code>nmcli connection modify ens192 ipv4.gateway </code><code>"10.168.0.1"</code>
<code>nmcli connection modify ens192 ipv4.dns </code><code>"202.96.128.86 202.96.128.166"</code>
<code>nmcli connection modify ens192 ipv4.method manual</code>
<code>nmcli connection modify ens192 ipv6.method ignore</code>
<code>nmcli connection modify ens192 connection.autoconnect </code><code>yes</code>
<code>nmcli connection up ens192</code>
注:第五行的“XX”部分是主机号
2.2.2 配置主机名称
hostnamectl set-hostname HDXX.sae.com.hk
注:“XX”部分是主机名称编号
2.2.3 关闭SELinux
<code>getenforce</code>
如果显示如下:
<code>Enforcing</code>
则执行:
<code>setenforce 0</code>
<code>sed</code> <code>-i </code><code>'s/SELINUX=enforcing/SELINUX=disabled/g'</code> <code>/etc/selinux/config</code>
2.2.4 配置名称解析
<code>echo</code> <code>'10.168.0.24 hd01.cmdschool.org'</code> <code>>> </code><code>/etc/hosts</code>
<code>echo</code> <code>'10.168.0.25 hd02.cmdschool.org'</code> <code>>> </code><code>/etc/hosts</code>
<code>echo</code> <code>'10.168.0.26 hd03.cmdschool.org'</code> <code>>> </code><code>/etc/hosts</code>
<code>echo</code> <code>'10.168.0.27 hd04.cmdschool.org'</code> <code>>> </code><code>/etc/hosts</code>
<code>echo</code> <code>'10.168.0.28 hd05.cmdschool.org'</code> <code>>> </code><code>/etc/hosts</code>
2.2.5 配置时区
<code>rm</code> <code>/etc/localtime</code>
<code>ln</code> <code>-s </code><code>/usr/share/zoneinfo/Asia/Shanghai</code> <code>/etc/localtime</code>
2.2.6 关闭防火墙并设置开机不启动
<code>systemctl stop firewalld</code>
<code>systemctl disable firewalld</code>
2.2.7 优化虚拟内存需求率
In HD01-05:
1)检查虚拟内存需求率
<code>cat</code> <code>/proc/sys/vm/swappiness</code>
显示如下:
<code> </code><code>30</code>
2)临时降低虚拟内存需求率
<code>sysctl vm.swappiness=0</code>
3)永久降低虚拟内存需求率
<code>echo</code> <code>'vm.swappiness = 0'</code> <code>> </code><code>/etc/sysctl</code><code>.d</code><code>/swappiness</code><code>.conf</code>
并运行如下命令使生效
<code>sysctl -p</code>
2.2.8 解决透明大页面问题
1)检查透明大页面问题
<code>cat</code> <code>/sys/kernel/mm/transparent_hugepage/defrag</code>
如果显示为:
<code>[always] madvise never</code>
2)临时关闭透明大页面问题
<code>echo</code> <code>never > </code><code>/sys/kernel/mm/transparent_hugepage/defrag</code>
确认配置生效:
应该显示为:
<code>always madvise [never]</code>
3)配置开机自动生效
<code>echo</code> <code>'echo never > /sys/kernel/mm/transparent_hugepage/defrag'</code> <code>>> </code><code>/etc/rc</code><code>.</code><code>local</code>
<code>chmod</code> <code>+x </code><code>/etc/rc</code><code>.d</code><code>/rc</code><code>.</code><code>local</code>
2.2.9 安装JDK
1)查询是否存在yum安装的java包
<code>rpm -qa | </code><code>grep</code> <code>java</code>
注意:存在yum安装的rpm包可能导致Sqoop无法启动
2)安装jdk1.8
<code>mkdir</code> <code>/usr/java</code>
<code>cd</code> <code>/usr/java</code>
<code>wget http:</code><code>//download</code><code>.oracle.com</code><code>/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64</code><code>.</code><code>tar</code><code>.gz</code>
<code>tar</code> <code>-xf jdk-8u121-linux-x64.</code><code>tar</code><code>.gz</code>
2)配置jdk变量环境
<code>echo</code> <code>'export JAVA_HOME=/usr/java/jdk1.8.0_121'</code> <code>>> </code><code>/etc/profile</code>
<code>echo</code> <code>'export JRE_HOME=${JAVA_HOME}/jre'</code> <code>>> </code><code>/etc/profile</code>
<code>echo</code> <code>'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib'</code> <code>>> </code><code>/etc/profile</code>
<code>echo</code> <code>'export PATH=${JAVA_HOME}/bin:$PATH'</code> <code>>> </code><code>/etc/profile</code>
3)导入java环境变量
<code>source</code> <code>/etc/profile</code>
4)测试jdk的配置
<code>java -version</code>
2.3 yum源的安装配置
2.3.1 yum源配置
1)增加yum源
<code>curl https:</code><code>//archive</code><code>.cloudera.com</code><code>/cm5/redhat/7/x86_64/cm/cloudera-manager</code><code>.repo > </code><code>/etc/yum</code><code>.repos.d</code><code>/cloudera-manager</code><code>.repo</code>
<code>yum </code><code>install</code> <code>-y https:</code><code>//dev</code><code>.mysql.com</code><code>/get/mysql57-community-release-el7-10</code><code>.noarch.rpm</code>
注:此出隐含条件是有系统默认的yum源并可在线更新
2)开启5.6版的源
<code>vim </code><code>/etc/yum</code><code>.repos.d</code><code>/mysql-community</code><code>.repo</code>
开启5.6的源并修改如下:
12
13
<code>[mysql56-community]</code>
<code>name=MySQL 5.6 Community Server</code>
<code>baseurl=http:</code><code>//repo</code><code>.mysql.com</code><code>/yum/mysql-5</code><code>.6-community</code><code>/el/7/</code><code>$basearch/</code>
<code>enabled=1</code>
<code>gpgcheck=1</code>
<code>gpgkey=</code><code>file</code><code>:</code><code>///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql</code>
<code>[mysql57-community]</code>
<code>name=MySQL 5.7 Community Server</code>
<code>baseurl=http:</code><code>//repo</code><code>.mysql.com</code><code>/yum/mysql-5</code><code>.7-community</code><code>/el/7/</code><code>$basearch/</code>
<code>enabled=0</code>
注:修改enabled选项等于1表示开启,0表示关闭(其他源都配置为0)
2.3.2 安装基本的工具
In HD02-05:
1)安装配置工具
<code>yum </code><code>install</code> <code>-y vim wget openssh-clients</code>
2)安装python
<code>yum </code><code>install</code> <code>-y python</code>
3)安装ntpd
<code>yum </code><code>install</code> <code>-y chrony</code>
2.3.3 Cloudera Manager端yum源配置
In HD01:
1)安装Cloudera Manager包
<code>yum </code><code>install</code> <code>-y cloudera-manager-daemons cloudera-manager-server</code>
2)安装mysql
<code>yum </code><code>install</code> <code>-y mysql-community-server mysql-community-devel mysql-community-client mysql-community-libs mysql-community-common mysql-community-libs-compat</code>
2.3.4 Cloudera Manager Agent端yum源配置
安装Cloudera Manager Agent包
<code>yum </code><code>install</code> <code>-y cloudera-manager-agent cloudera-manager-daemons</code>
2.4 配置前的准备配置
2.4.1权限检查(单用户模式适用,可选)
检查以下目录cloudera-scm用户具有完全的权限
检查当前目录权限:
<code>ls</code> <code>-ld </code><code>/opt/cloudera/</code>
<code>drwxr-xr-x. 4 cloudera-scm cloudera-scm 36 Apr 15 19:35 </code><code>/opt/cloudera/</code>
检查子目录权限:
<code>ls</code> <code>-lR </code><code>/opt/cloudera/</code>
显示如下
<code>/opt/cloudera/</code><code>:</code>
<code>total 0</code>
<code>drwxr-xr-x. 2 cloudera-scm cloudera-scm 6 Mar 19 23:26 csd</code>
<code>drwxr-xr-x. 2 cloudera-scm cloudera-scm 6 Mar 19 23:26 parcel-repo</code>
<code>/opt/cloudera/csd</code><code>:</code>
<code>/opt/cloudera/parcel-repo</code><code>:</code>
同样,检查服务器或客户端目录权限
<code>ls</code> <code>-ld </code><code>/var/log/cloudera-scm-server/</code>
<code>ls</code> <code>-lR </code><code>/var/log/cloudera-scm-server/</code>
<code>ls</code> <code>-ld </code><code>/var/lib/cloudera-scm-agent/</code>
<code>ls</code> <code>-lR </code><code>/var/lib/cloudera-scm-agent/</code>
2.4.2 检查线程限制配置
<code>vim </code><code>/etc/security/limits</code><code>.d</code><code>/cloudera-scm</code><code>.conf</code>
修改配置如下:
<code>#</code>
<code># (c) Copyright 2014 Cloudera, Inc.</code>
<code>cloudera-scm soft nofile 32768</code>
<code>cloudera-scm soft nproc 65536</code>
<code>cloudera-scm hard nofile 1048576</code>
<code>cloudera-scm hard nproc unlimited</code>
<code>cloudera-scm hard memlock unlimited</code>
<code>cloudera-scm soft memlock unlimited</code>
2.4.3 指定运行单用户模式的用户名(单用户模式适用,不配置)
<code>vim </code><code>/etc/default/cloudera-scm-agent</code>
并取消以下行的注释
<code>USER=</code><code>"cloudera-scm"</code>
2.4.4 创建压缩包存放目录
<code>mkdir</code> <code>-p </code><code>/opt/cloudera/parcels</code>
<code>chown</code> <code>cloudera-scm:cloudera-scm </code><code>/opt/cloudera/parcels</code>
2.4.5 配置无密码的sudo访问(非默认单用户模式适用,可选)
<code>visudo</code>
增加如下组:
<code>%cloudera-scm ALL=(ALL) NOPASSWD: ALL</code>
确认包含如下行:
<code>Defaults secure_path = </code><code>/sbin</code><code>:</code><code>/bin</code><code>:</code><code>/usr/sbin</code><code>:</code><code>/usr/bin</code>
2.4.6 配置su的limit
<code>vim </code><code>/etc/pam</code><code>.d</code><code>/su</code>
加入如下配置:
<code>session required pam_limits.so</code>
2.4.7 NTP的配置
In HD01-5:
1)确认包含如下配置:
<code>cat</code> <code>/etc/chrony</code><code>.conf</code>
应该包含如下配置:
<code>server 0.centos.pool.ntp.org iburst</code>
<code>server 1.centos.pool.ntp.org iburst</code>
<code>server 2.centos.pool.ntp.org iburst</code>
<code>server 3.centos.pool.ntp.org iburst</code>
2)启动并配置ntpd服务自动启动
<code>systemctl restart chronyd</code>
<code>systemctl </code><code>enable</code> <code>chronyd</code>
3)触发时间同步
<code>chronyc sources</code>
2.4.8 安装MySQL JDBC Driver
<code>cd</code> <code>~</code>
<code>wget http:</code><code>//dev</code><code>.mysql.com</code><code>/get/Downloads/Connector-J/mysql-connector-java-5</code><code>.1.39.</code><code>tar</code><code>.gz</code>
<code>tar</code> <code>zxvf mysql-connector-java-5.1.39.</code><code>tar</code><code>.gz</code>
<code>mkdir</code> <code>/usr/share/java/</code>
<code>cp</code> <code>mysql-connector-java-5.1.39</code><code>/mysql-connector-java-5</code><code>.1.39-bin.jar </code><code>/usr/share/java/mysql-connector-java</code><code>.jar</code>
2.4.9 配置公钥认证
In HD01:
1)生成秘钥
ssh-keygen -t rsa
注:以上一路回车
2)复制公钥到各个被登录的服务器
<code>ssh</code><code>-copy-</code><code>id</code> <code>-i ~/.</code><code>ssh</code><code>/id_rsa</code><code>.pub [email protected]</code>
<code>ssh</code><code>-copy-</code><code>id</code> <code>-i ~/.</code><code>ssh</code><code>/id_rsa</code><code>.pub [email protected]</code>
<code>ssh</code><code>-copy-</code><code>id</code> <code>-i ~/.</code><code>ssh</code><code>/id_rsa</code><code>.pub [email protected]</code>
<code>ssh</code><code>-copy-</code><code>id</code> <code>-i ~/.</code><code>ssh</code><code>/id_rsa</code><code>.pub [email protected]</code>
<code>ssh</code><code>-copy-</code><code>id</code> <code>-i ~/.</code><code>ssh</code><code>/id_rsa</code><code>.pub [email protected]</code>
3)测试免密码登录
<code>ssh</code> <code>10.168.0.24</code>
<code>ssh</code> <code>10.168.0.25</code>
<code>ssh</code> <code>10.168.0.26</code>
<code>ssh</code> <code>10.168.0.27</code>
<code>ssh</code> <code>10.168.0.28</code>
注:以上如果无需密码登记即成功
2.5 Cloudera Manager安装配置
2.5.1 修改mysql参数
1)关闭数据库
<code>systemctl stop mysqld</code>
2)备份ib_logfile文件
<code>mkdir</code> <code>/var/lib/backup</code>
<code>cd</code> <code>/var/lib/mysql/</code>
<code>mv</code> <code>ib_logfile* </code><code>/var/lib/backup/</code>
3)修改MySQL配置
<code>cp</code> <code>/etc/my</code><code>.cnf </code><code>/etc/my</code><code>.cnf.default</code>
<code>vim </code><code>/etc/my</code><code>.cnf</code>
修改参数如下:
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<code>[mysqld]</code>
<code>datadir=</code><code>/var/lib/mysql</code>
<code>socket=</code><code>/var/lib/mysql/mysql</code><code>.sock</code>
<code>user=mysql</code>
<code># Recommended in standard MySQL setup</code>
<code>sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES</code>
<code>transaction-isolation = READ-COMMITTED</code>
<code># Disabling symbolic-links is recommended to prevent assorted security risks;</code>
<code># to do so, uncomment this line:</code>
<code># symbolic-links = 0</code>
<code>key_buffer_size = 32M</code>
<code>max_allowed_packet = 32M</code>
<code>thread_stack = 256K</code>
<code>thread_cache_size = 64</code>
<code>query_cache_limit = 8M</code>
<code>query_cache_size = 64M</code>
<code>query_cache_type = 1</code>
<code>max_connections = 550</code>
<code>#expire_logs_days = 10</code>
<code>#max_binlog_size = 100M</code>
<code>#log_bin should be on a disk with enough free space. Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your system</code>
<code>#and chown the specified folder to the mysql user.</code>
<code>log_bin=</code><code>/var/lib/mysql/mysql_binary_log</code>
<code>server-</code><code>id</code><code>=1</code>
<code># For MySQL version 5.1.8 or later. Comment out binlog_format for older versions.</code>
<code>binlog_format = mixed</code>
<code>read_buffer_size = 2M</code>
<code>read_rnd_buffer_size = 16M</code>
<code>sort_buffer_size = 8M</code>
<code>join_buffer_size = 8M</code>
<code># InnoDB settings</code>
<code>innodb_file_per_table = 1</code>
<code>innodb_flush_log_at_trx_commit = 2</code>
<code>innodb_log_buffer_size = 64M</code>
<code>innodb_buffer_pool_size = 4G</code>
<code>innodb_thread_concurrency = 8</code>
<code>innodb_flush_method = O_DIRECT</code>
<code>innodb_log_file_size = 512M</code>
<code>[mysqld_safe]</code>
<code>log-error=</code><code>/var/log/mysqld</code><code>.log</code>
<code>pid-</code><code>file</code><code>=</code><code>/var/run/mysqld/mysqld</code><code>.pid</code>
<code>sql_mode=STRICT_ALL_TABLES</code>
2.5.2 启动并设置开机自动启动
<code>systemctl start mysqld</code>
<code>systemctl </code><code>enable</code> <code>mysqld</code>
2.5.3 初始化数据库
<code>mysql_secure_installation</code>
向导如下:
<code>[...]</code>
<code>Enter current password </code><code>for</code> <code>root (enter </code><code>for</code> <code>none):</code>
<code>OK, successfully used password, moving on...</code>
<code>Set root password? [Y</code><code>/n</code><code>] y</code>
<code>New password:</code>
<code>Re-enter new password:</code>
<code>Remove anonymous </code><code>users</code><code>? [Y</code><code>/n</code><code>] y</code>
<code>Disallow root login remotely? [Y</code><code>/n</code><code>] n</code>
<code>Remove </code><code>test</code> <code>database and access to it [Y</code><code>/n</code><code>] y</code>
<code>Reload privilege tables now? [Y</code><code>/n</code><code>] y</code>
<code>All </code><code>done</code><code>!</code>
2.5.4 准备scm库
数据库配置:
<code>mysql -uroot -p</code>
<code>create database scm default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on *.* to scm@</code><code>'hd01.cmdschool.org'</code> <code>identified by </code><code>'scm'</code><code>;</code>
<code>flush privileges;</code>
修改数据库连接参数:
<code>cp</code> <code>/etc/cloudera-scm-server/db</code><code>.properties </code><code>/etc/cloudera-scm-server/db</code><code>.properties.default</code>
<code>vim </code><code>/etc/cloudera-scm-server/db</code><code>.properties</code>
修改如下参数:
<code>com.cloudera.cmf.db.</code><code>type</code><code>=mysql</code>
<code>com.cloudera.cmf.db.host=hd01.cmdschool.org</code>
<code>com.cloudera.cmf.db.name=scm</code>
<code>com.cloudera.cmf.db.user=scm</code>
<code>com.cloudera.cmf.db.password=scm</code>
<code>com.cloudera.cmf.db.setupType=EXTERNAL</code>
2.5.5 创建附加数据库(可选)
1)附加数据库列表
Role
Database
User
Password
Activity Monitor
amon
amon_password
Reports Manager
rman
rman_password
Hive Metastore Server
metastore
hive
hive_password
Sentry Server
sentry
sentry_password
Cloudera Navigator Audit Server
nav
nav_password
Cloudera Navigator Metadata Server
navms
navms_password
2)创建数据库并配置管理账号密码
<code>create database amon default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on amon.* to </code><code>'amon'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'amon_password'</code><code>;</code>
<code>create database rman default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on rman.* to </code><code>'rman'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'rman_password'</code><code>;</code>
<code>create database metastore default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on metastore.* to </code><code>'hive'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'hive_password'</code><code>;</code>
<code>create database sentry default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on sentry.* to </code><code>'sentry'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'sentry_password'</code><code>;</code>
<code>create database nav default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on nav.* to </code><code>'nav'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'nav_password'</code><code>;</code>
<code>create database navms default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on navms.* to </code><code>'navms'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'navms_password'</code><code>;</code>
2.5.6 配置Oozie库(可选)
1)数据库权限配置
<code>create database oozie default character </code><code>set</code> <code>utf8;</code>
<code>grant all privileges on oozie.* to </code><code>'oozie'</code><code>@</code><code>'localhost'</code> <code>identified by </code><code>'oozie'</code><code>;</code>
<code>grant all privileges on oozie.* to </code><code>'oozie'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'oozie'</code><code>;</code>
2)配置Oozie库所需软连接
<code>cd</code> <code>/opt/cloudera/parcels/CDH/lib/oozie/lib/</code>
<code>ln</code> <code>-s </code><code>/usr/share/java/mysql-connector-java</code><code>.jar mysql-connector-java.jar</code>
2.5.7 启动服务并配置开机启动
<code>/etc/init</code><code>.d</code><code>/cloudera-scm-server</code> <code>start</code>
<code>chkconfig cloudera-scm-server on</code>
2.5.8 故障排除
<code>tail</code> <code>-f </code><code>/var/log/cloudera-scm-server/cloudera-scm-server</code><code>.out</code>
2.6 Cloudera Manager Agent安装
2.6.1 创建压缩包存放目录
2.6.2 指定管理服务器和指定包存放目录
<code>vim </code><code>/etc/cloudera-scm-agent/config</code><code>.ini</code>
确保参数如下并启用:
<code>server_host=hd01.cmdschool.org</code>
<code>server_port=7182</code>
<code>parcel_dir=</code><code>/opt/cloudera/parcels</code>
2.6.3 指定运行单用户模式的用户名(仅用于单用户模式,不配置)
取消以下行的注释
2.6.4 启动服务并配置服务器开机启动
<code>/etc/init</code><code>.d</code><code>/cloudera-scm-agent</code> <code>start</code>
<code>chkconfig cloudera-scm-agent on</code>
2.6.5 故障排除
如下命令监控启动服务的错误输出
<code>tail</code> <code>-f </code><code>/var/log/cloudera-scm-agent/cloudera-scm-agent</code><code>.out</code>
2.7 登陆配置
<a href="http://10.168.0.24:7180/cmf/login" target="_blank">http://10.168.0.24:7180/cmf/login</a>
<a href="https://s2.51cto.com/wyfs02/M01/92/2F/wKioL1j9SXehTXjBAABv28_4NQo119.png" target="_blank"></a>
注:界面部分请跟着向导走,相对容易,这是不再详述。
本文转自 tanzhenchao 51CTO博客,原文链接:http://blog.51cto.com/cmdschool/1916322,如需转载请自行联系原作者