1 前言html
如今藉着作項目的機會在CentOS 7.3環境中再次部署了一套比較新的版本。基於共享的精神,本文給有須要的人蔘閱。java
舊一點的版本安裝請參閱(CentOS 6):python
http://cmdschool.blog.51cto.com/2420395/1775398mysql
2 實踐部分linux
2.1 基本信息sql
Hostname=HD0[1-5].cmdschool.org數據庫
Ipaddress=10.168.0.2[4-8]vim
OS Version=CentOS 7.3centos
2.2 環境配置bash
2.2.1 配置IP地址
In HD01-05:
nmcli connection delete "Wired connection 1" nmcli connection show nmcli device show nmcli connection add ifname ens192 con-name ens192 type ethernet nmcli connection modify ens192 ipv4.address "10.168.0.XX/24" nmcli connection modify ens192 ipv4.gateway "10.168.0.1" nmcli connection modify ens192 ipv4.dns "202.96.128.86 202.96.128.166" nmcli connection modify ens192 ipv4.method manual nmcli connection modify ens192 ipv6.method ignore nmcli connection modify ens192 connection.autoconnect yes nmcli connection up ens192
注:第五行的「XX」部分是主機號
2.2.2 配置主機名稱
In HD01-05:
hostnamectl set-hostname HDXX.sae.com.hk
注:「XX」部分是主機名稱編號
2.2.3 關閉SELinux
In HD01-05:
getenforce
若是顯示以下:
Enforcing
則執行:
setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2.2.4 配置名稱解析
In HD01-05:
echo '10.168.0.24 hd01.cmdschool.org' >> /etc/hosts echo '10.168.0.25 hd02.cmdschool.org' >> /etc/hosts echo '10.168.0.26 hd03.cmdschool.org' >> /etc/hosts echo '10.168.0.27 hd04.cmdschool.org' >> /etc/hosts echo '10.168.0.28 hd05.cmdschool.org' >> /etc/hosts
2.2.5 配置時區
In HD01-05:
rm /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2.2.6 關閉防火牆並設置開機不啓動
In HD01-05:
systemctl stop firewalld systemctl disable firewalld
2.2.7 優化虛擬內存需求率
In HD01-05:
1)檢查虛擬內存需求率
cat /proc/sys/vm/swappiness
顯示以下:
30
2)臨時下降虛擬內存需求率
sysctl vm.swappiness=0
3)永久下降虛擬內存需求率
echo 'vm.swappiness = 0' > /etc/sysctl.d/swappiness.conf
並運行以下命令使生效
sysctl -p
2.2.8 解決透明大頁面問題
In HD01-05:
1)檢查透明大頁面問題
cat /sys/kernel/mm/transparent_hugepage/defrag
若是顯示爲:
[always] madvise never
2)臨時關閉透明大頁面問題
echo never > /sys/kernel/mm/transparent_hugepage/defrag
確認配置生效:
cat /sys/kernel/mm/transparent_hugepage/defrag
應該顯示爲:
always madvise [never]
3)配置開機自動生效
echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.local chmod +x /etc/rc.d/rc.local
2.2.9 安裝JDK
In HD01-05:
1)查詢是否存在yum安裝的java包
rpm -qa | grep java
注意:存在yum安裝的rpm包可能致使Sqoop沒法啓動
2)安裝jdk1.8
mkdir /usr/java cd /usr/java wget http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz tar -xf jdk-8u121-linux-x64.tar.gz
2)配置jdk變量環境
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_121' >> /etc/profile echo 'export JRE_HOME=${JAVA_HOME}/jre' >> /etc/profile echo 'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' >> /etc/profile echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> /etc/profile
3)導入java環境變量
source /etc/profile
4)測試jdk的配置
java -version
2.3 yum源的安裝配置
In HD01-05:
2.3.1 yum源配置
1)增長yum源
curl https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/cloudera-manager.repo > /etc/yum.repos.d/cloudera-manager.repo yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
注:此出隱含條件是有系統默認的yum源並可在線更新
2)開啓5.6版的源
vim /etc/yum.repos.d/mysql-community.repo
開啓5.6的源並修改以下:
[mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
注:修改enabled選項等於1表示開啓,0表示關閉(其餘源都配置爲0)
2.3.2 安裝基本的工具
In HD02-05:
1)安裝配置工具
yum install -y vim wget openssh-clients
2)安裝python
yum install -y python
3)安裝ntpd
yum install -y chrony
2.3.3 Cloudera Manager端yum源配置
In HD01:
1)安裝Cloudera Manager包
yum install -y cloudera-manager-daemons cloudera-manager-server
2)安裝mysql
yum install -y mysql-community-server mysql-community-devel mysql-community-client mysql-community-libs mysql-community-common mysql-community-libs-compat
2.3.4 Cloudera Manager Agent端yum源配置
In HD01-05:
安裝Cloudera Manager Agent包
yum install -y cloudera-manager-agent cloudera-manager-daemons
2.4 配置前的準備配置
2.4.1權限檢查(單用戶模式適用,可選)
In HD01-05:
檢查如下目錄cloudera-scm用戶具備徹底的權限
檢查當前目錄權限:
ls -ld /opt/cloudera/
顯示以下:
drwxr-xr-x. 4 cloudera-scm cloudera-scm 36 Apr 15 19:35 /opt/cloudera/
檢查子目錄權限:
ls -lR /opt/cloudera/
顯示以下
/opt/cloudera/: total 0 drwxr-xr-x. 2 cloudera-scm cloudera-scm 6 Mar 19 23:26 csd drwxr-xr-x. 2 cloudera-scm cloudera-scm 6 Mar 19 23:26 parcel-repo /opt/cloudera/csd: total 0 /opt/cloudera/parcel-repo: total 0
一樣,檢查服務器或客戶端目錄權限
ls -ld /var/log/cloudera-scm-server/ ls -lR /var/log/cloudera-scm-server/ ls -ld /var/lib/cloudera-scm-agent/ ls -lR /var/lib/cloudera-scm-agent/
2.4.2 檢查線程限制配置
In HD01-05:
vim /etc/security/limits.d/cloudera-scm.conf
修改配置以下:
# # (c) Copyright 2014 Cloudera, Inc. # cloudera-scm soft nofile 32768 cloudera-scm soft nproc 65536 cloudera-scm hard nofile 1048576 cloudera-scm hard nproc unlimited cloudera-scm hard memlock unlimited cloudera-scm soft memlock unlimited
2.4.3 指定運行單用戶模式的用戶名(單用戶模式適用,不配置)
In HD01-05:
vim /etc/default/cloudera-scm-agent
並取消如下行的註釋
USER="cloudera-scm"
2.4.4 建立壓縮包存放目錄
mkdir -p /opt/cloudera/parcels chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
2.4.5 配置無密碼的sudo訪問(非默認單用戶模式適用,可選)
In HD01-05:
visudo
增長以下組:
%cloudera-scm ALL=(ALL) NOPASSWD: ALL
確認包含以下行:
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
2.4.6 配置su的limit
In HD01-05:
vim /etc/pam.d/su
加入以下配置:
session required pam_limits.so
2.4.7 NTP的配置
In HD01-5:
1)確認包含以下配置:
cat /etc/chrony.conf
應該包含以下配置:
server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst
2)啓動並配置ntpd服務自動啓動
systemctl restart chronyd systemctl enable chronyd
3)觸發時間同步
chronyc sources
2.4.8 安裝MySQL JDBC Driver
In HD01-05:
cd ~ wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.39.tar.gz tar zxvf mysql-connector-java-5.1.39.tar.gz mkdir /usr/share/java/ cp mysql-connector-java-5.1.39/mysql-connector-java-5.1.39-bin.jar /usr/share/java/mysql-connector-java.jar
2.4.9 配置公鑰認證
In HD01:
1)生成祕鑰
ssh-keygen -t rsa
注:以上一路回車
2)複製公鑰到各個被登陸的服務器
ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.168.0.24 ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.168.0.25 ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.168.0.26 ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.168.0.27 ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.168.0.28
3)測試免密碼登陸
ssh 10.168.0.24 ssh 10.168.0.25 ssh 10.168.0.26 ssh 10.168.0.27 ssh 10.168.0.28
注:以上若是無需密碼登記即成功
2.5 Cloudera Manager安裝配置
In HD01:
2.5.1 修改mysql參數
1)關閉數據庫
systemctl stop mysqld
2)備份ib_logfile文件
mkdir /var/lib/backup cd /var/lib/mysql/ mv ib_logfile* /var/lib/backup/
3)修改MySQL配置
cp /etc/my.cnf /etc/my.cnf.default vim /etc/my.cnf
修改參數以下:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Recommended in standard MySQL setup sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES transaction-isolation = READ-COMMITTED # Disabling symbolic-links is recommended to prevent assorted security risks; # to do so, uncomment this line: # symbolic-links = 0 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 #expire_logs_days = 10 #max_binlog_size = 100M #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 #and chown the specified folder to the mysql user. log_bin=/var/lib/mysql/mysql_binary_log server-id=1 # For MySQL version 5.1.8 or later. Comment out binlog_format for older versions. binlog_format = mixed read_buffer_size = 2M read_rnd_buffer_size = 16M sort_buffer_size = 8M join_buffer_size = 8M # InnoDB settings 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/mysqld.log pid-file=/var/run/mysqld/mysqld.pid sql_mode=STRICT_ALL_TABLES
2.5.2 啓動並設置開機自動啓動
systemctl start mysqld systemctl enable mysqld
2.5.3 初始化數據庫
mysql_secure_installation
嚮導以下:
[...] Enter current password for root (enter for none): OK, successfully used password, moving on... [...] Set root password? [Y/n] y New password: Re-enter new password: Remove anonymous users? [Y/n] y [...] Disallow root login remotely? [Y/n] n [...] Remove test database and access to it [Y/n] y [...] Reload privilege tables now? [Y/n] y All done!
2.5.4 準備scm庫
數據庫配置:
mysql -uroot -p create database scm default character set utf8; grant all privileges on *.* to scm@'hd01.cmdschool.org' identified by 'scm'; flush privileges;
修改數據庫鏈接參數:
cp /etc/cloudera-scm-server/db.properties /etc/cloudera-scm-server/db.properties.default vim /etc/cloudera-scm-server/db.properties
修改以下參數:
com.cloudera.cmf.db.type=mysql com.cloudera.cmf.db.host=hd01.cmdschool.org com.cloudera.cmf.db.name=scm com.cloudera.cmf.db.user=scm com.cloudera.cmf.db.password=scm com.cloudera.cmf.db.setupType=EXTERNAL
2.5.5 建立附加數據庫(可選)
1)附加數據庫列表
Role | Database | User | Password |
Activity Monitor | amon | amon | amon_password |
Reports Manager | rman | rman | rman_password |
Hive Metastore Server | metastore | hive | hive_password |
Sentry Server | sentry | sentry | sentry_password |
Cloudera Navigator Audit Server | nav | nav | nav_password |
Cloudera Navigator Metadata Server |
navms | navms | navms_password |
2)建立數據庫並配置管理帳號密碼
mysql -uroot -p create database amon default character set utf8; grant all privileges on amon.* to 'amon'@'%' identified by 'amon_password'; create database rman default character set utf8; grant all privileges on rman.* to 'rman'@'%' identified by 'rman_password'; create database metastore default character set utf8; grant all privileges on metastore.* to 'hive'@'%' identified by 'hive_password'; create database sentry default character set utf8; grant all privileges on sentry.* to 'sentry'@'%' identified by 'sentry_password'; create database nav default character set utf8; grant all privileges on nav.* to 'nav'@'%' identified by 'nav_password'; create database navms default character set utf8; grant all privileges on navms.* to 'navms'@'%' identified by 'navms_password'; flush privileges;
2.5.6 配置Oozie庫(可選)
1)數據庫權限配置
mysql -uroot -p create database oozie default character set utf8; grant all privileges on oozie.* to 'oozie'@'localhost' identified by 'oozie'; grant all privileges on oozie.* to 'oozie'@'%' identified by 'oozie'; flush privileges;
2)配置Oozie庫所需軟鏈接
cd /opt/cloudera/parcels/CDH/lib/oozie/lib/ ln -s /usr/share/java/mysql-connector-java.jar mysql-connector-java.jar
2.5.7 啓動服務並配置開機啓動
/etc/init.d/cloudera-scm-server start chkconfig cloudera-scm-server on
2.5.8 故障排除
tail -f /var/log/cloudera-scm-server/cloudera-scm-server.out
2.6 Cloudera Manager Agent安裝
In HD01-05:
2.6.1 建立壓縮包存放目錄
mkdir -p /opt/cloudera/parcels chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
2.6.2 指定管理服務器和指定包存放目錄
vim /etc/cloudera-scm-agent/config.ini
確保參數以下並啓用:
server_host=hd01.cmdschool.org server_port=7182 parcel_dir=/opt/cloudera/parcels
2.6.3 指定運行單用戶模式的用戶名(僅用於單用戶模式,不配置)
vim /etc/default/cloudera-scm-agent
取消如下行的註釋
USER="cloudera-scm"
2.6.4 啓動服務並配置服務器開機啓動
/etc/init.d/cloudera-scm-agent start chkconfig cloudera-scm-agent on
2.6.5 故障排除
以下命令監控啓動服務的錯誤輸出
tail -f /var/log/cloudera-scm-agent/cloudera-scm-agent.out
2.7 登錄配置
In HD01:
http://10.168.0.24:7180/cmf/login
注:界面部分請跟着嚮導走,相對容易,這是再也不詳述。
參閱文檔
============================
Overview:
https://www.cloudera.com/documentation/enterprise/latest/topics/installation_installation.html
Managed Service Database:
系統地址:
https://www.centos.org/download/mirrors/
CDH地址:
https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/
Java地址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
支持信息參考:
https://www.cloudera.com/documentation/enterprise/release-notes/topics/rn_consolidated_pcm.html