大數據集群Linux CentOS 7.6 系統調優篇


            大數據集群Linux CentOS 7.6 系統調優篇

                                     作者:尹正傑

版權聲明:原創作品,謝絕轉載!否則將追究法律責任。

 

 

 

一.設置主機hosts文件

1>.修改主機名

[root@node100.yinzhengjie.org.cn ~]# cat /etc/hostname 
node100.yinzhengjie.org.cn
[root@node100.yinzhengjie.org.cn ~]# 

2>. 添加集群各節點主機名稱映射關系

[root@node100.yinzhengjie.org.cn ~]# cat /etc/hosts
172.30.1.100 node100.yinzhengjie.org.cn
172.30.1.101 node101.yinzhengjie.org.cn
172.30.1.102 node102.yinzhengjie.org.cn
172.30.1.103 node103.yinzhengjie.org.cn
172.30.1.104 node104.yinzhengjie.org.cn
172.30.1.105 node105.yinzhengjie.org.cn
172.30.1.106 node106.yinzhengjie.org.cn
172.30.1.107 node107.yinzhengjie.org.cn
172.30.1.108 node108.yinzhengjie.org.cn
[root@node100.yinzhengjie.org.cn ~]# 

3>.顯示優化(針對命令行終端顯示信息稍作修改,編輯/etc/bashrc)

1.設置ps1變量的顯示

    PS1(是數字1而不是字母l),每個版本bash的PS1變量內的特殊符號可能有些小的差異,你可以先man bash 一下。下面是FC4環境下默認的特殊符號所代表的意義:

    \d :代表日期,格式為weekday month date,例如:"Mon Aug 1"

    \H :完整的主機名稱。例如:我的機器名稱為:fc4.linux,則這個名稱就是fc4.linux

    \h :僅取主機的第一個名字,如上例,則為fc4,.linux則被省略

    \t :顯示時間為24小時格式,如:HH:MM:SS

    \T :顯示時間為12小時格式

    \A :顯示時間為24小時格式:HH:MM

    \u :當前用戶的賬號名稱

    \v :BASH的版本信息

    \w :完整的工作目錄名稱。家目錄會以 ~代替

    \W :利用basename取得工作目錄名稱,所以只會列出最后一個目錄

    \# :下達的第幾個命令

    \$ :提示字符,如果是root時,提示符為:# ,普通用戶則為:$

    默認的PS1內容為: PS1='[\u@\h \W]\$ ' ,所以默認的提示符就是: [root@linux ~]#。
設置ps1變量的顯示
設置ps1變量的顏色

我們能夠通過配置PS1變量使提示符成為彩色。在PS1中配置字符序列顏色的格式為:
 
    \[\e[F;Bm\]
 
    基本上是夾在 "\e["(轉義開方括號)和 "m" 之間數字值。假如指定一個以上的數字代碼,則用分號將他們分開。
    
    其中 F 為字體顏色,編號30~37; B 為背景色,編號40~47。
 
    可通過 \e[0m 關閉顏色輸出;特別的,當B為1時,將顯示加亮加粗的文字,請看下面的顏色表和代碼表。
 
    顏色表
    
    前景     背景     顏色
    ---------------------------------------
        40         黑色
        41         紅色
        42         綠色
        43         黃色
        44         藍色
        45         紫色
        46         青色
        47         白色
設置ps1變量的顏色
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "

 

二.關閉防火牆和selinux

1>.關閉防火牆

[root@node100.yinzhengjie.org.cn ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-06-08 21:13:36 CST; 16min ago
     Docs: man:firewalld(1)
 Main PID: 8863 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─8863 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Jun 08 21:13:35 node100.yinzhengjie.org.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 08 21:13:36 node100.yinzhengjie.org.cn systemd[1]: Started firewalld - dynamic firewall daemon.
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Hint: Some lines were ellipsized, use -l to show in full.
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# systemctl status firewalld          #查看防火牆當前狀態
[root@node100.yinzhengjie.org.cn ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-06-08 21:13:36 CST; 16min ago
     Docs: man:firewalld(1)
 Main PID: 8863 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─8863 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Jun 08 21:13:35 node100.yinzhengjie.org.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 08 21:13:36 node100.yinzhengjie.org.cn systemd[1]: Started firewalld - dynamic firewall daemon.
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Hint: Some lines were ellipsized, use -l to show in full.
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# systemctl stop firewalld
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2019-06-08 21:30:20 CST; 5s ago
     Docs: man:firewalld(1)
  Process: 8863 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 8863 (code=exited, status=0/SUCCESS)

Jun 08 21:13:35 node100.yinzhengjie.org.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 08 21:13:36 node100.yinzhengjie.org.cn systemd[1]: Started firewalld - dynamic firewall daemon.
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-bond0': [Errno 13] ...bond0'
Jun 08 21:13:39 node100.yinzhengjie.org.cn firewalld[8863]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7fc506f7b14...bond0'
Jun 08 21:30:19 node100.yinzhengjie.org.cn systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jun 08 21:30:20 node100.yinzhengjie.org.cn systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# systemctl stop firewalld           #停止防火牆運行
[root@node100.yinzhengjie.org.cn ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# systemctl disable firewalld         #禁止防火牆服務開機自啟

2>.關閉selinux

[root@node100.yinzhengjie.org.cn ~]# sed -i s'#SELINUX=enforcing#SELINUX=disabled#' /etc/selinux/config

3>.關閉DNS PTR反向查詢(sshd服務優化)

  UseDNS 選項打開狀態下,當客戶端試圖登錄SSH服務器時,服務器端先根據客戶端的IP地址進行DNS PTR反向查詢出客戶端的主機名,然后根據查詢出的客戶端主機名進行DNS正向A記錄查詢,驗證與其原始IP地址是否一致,這是防止客戶端欺騙的一種措施,但一般我們的是動態IP不會有PTR記錄,打開這個選項不過是在白白浪費時間而已,不如將其關閉。

  具體操作如下:

[root@node100.yinzhengjie.org.cn ~]# grep UseDNS /etc/ssh/sshd_config
#UseDNS yes
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# sed -i 's@#UseDNS yes@UseDNS no@g' /etc/ssh/sshd_config
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# grep UseDNS /etc/ssh/sshd_config
UseDNS no
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# sed -i 's@#UseDNS yes@UseDNS no@g' /etc/ssh/sshd_config

4>.關閉GSSAPI身份驗證(ssh服務優化)

  GSSAPIAuthentication  當這個參數開啟( GSSAPIAuthentication  yes )的時候,通過SSH登陸服務器時候會有些會很慢!這是由於服務器端啟用了GSSAPI。登陸的時候客戶端需要對服務器端的IP地址進行反解析,如果服務器的IP地址沒有配置PTR記錄,那么就容易在這里卡住了。
  
  具體操作如下:

[root@node100.yinzhengjie.org.cn ~]# grep GSSAPIAuthentication /etc/ssh/sshd_config
GSSAPIAuthentication yes
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# sed -i 's@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# grep GSSAPIAuthentication /etc/ssh/sshd_config
GSSAPIAuthentication no
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# systemctl restart sshd
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# sed -i 's@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config

5>.檢查DNS配置

[root@node100.yinzhengjie.org.cn ~]# hostname --fqdn
node100.yinzhengjie.org.cn
[root@node100.yinzhengjie.org.cn ~]# 

 

.關閉透明大頁(重啟后生效)

一.透明大頁(Transparent Huge Pages,簡稱THP)
    在Linux6.x之后的平台,在安裝Oracle數據庫的時候都建議關閉透明大頁。Linux下的大頁分為兩種類型:標准大頁(Huge Pages)和透明大頁(Transparent Huge Pages)。
1>.標准大頁(Huge Pages)
    是從Linux Kernel 2.6后被引入的。目的是使用更大的內存頁面(memory page size) 以適應越來越大的系統內存,讓操作系統可以支持現代硬件架構的大頁面容量功能。
2>.透明大頁(Transparent Huge Pages)縮寫為THP,
    這個是RHEL 6開始引入的一個功能。

3>.HP和THP的區別
    這兩者的區別在於大頁的分配機制,標准大頁管理是預分配的方式,而透明大頁管理則是動態分配的方式。目前透明大頁與傳統大頁混合使用會出現一些問題,導致性能問題和系統重啟。
    ORACLE官方不建議在使用RedHat 6, OEL 6, SLES 11 and UEK2 kernels 時開啟透明大頁(THP),因為透明大頁存在一些問題:
        
      3.1>.在RAC環境下 透明大頁(Transparent HugePages )會導致異常節點重啟和性能問題;
        
      3.2>.在單機環境中,透明大頁(Transparent HugePages ) 也會導致一些異常的性能問題;
      3.3>.THP是一個使用Huge Pages自動化的抽象層。它會引起cpu占用率增大,需要將其關閉。



二.關閉透明大頁
    Linux7 默認情況下 是開啟透明大頁功能的。默認情況下,狀態為always,需要調整為never。
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# uname -r
3.10.0-957.el7.x86_64
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /sys/kernel/mm/transparent_hugepage/enabled 
[always] madvise never
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /etc/default/grub  | grep GRUB_CMDLINE_LINUX        #在原有的配置上添加:transparent_hugepage=never
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=VolGroup/lv_root rd.lvm.lv=VolGroup/lv_swap rhgb quiet transparent_hugepage=never"
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-abf2be07fc8c594fb87ff254b58fc5d6
Found initrd image: /boot/initramfs-0-rescue-abf2be07fc8c594fb87ff254b58fc5d6.img
done
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# reboot                                             #重啟操作系統后,配置就會生效!
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /sys/kernel/mm/transparent_hugepage/enabled                #重啟后,查看陪你已經被關閉!
always madvise [never]
[root@node101.yinzhengjie.org.cn ~]# 
CentOS7.x版本關閉透明大頁的另外一種方法,僅供參考!(查看透明大頁的作用戳我)
  據Cloudera和Hortonworks的專家介紹,THP壓縮會降低Hadoop的性能。所以,禁用脆皮整理是一個很好的做法。具體操作如下:  

[root@node100.yinzhengjie.org.cn ~]# vi /etc/rc.d/rc.local [root@node100.yinzhengjie.org.cn ~]# [root@node100.yinzhengjie.org.cn ~]# tail -8 /etc/rc.d/rc.local #ADD BY YINZHENGJIE if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi [root@node100.yinzhengjie.org.cn ~]# [root@node100.yinzhengjie.org.cn ~]# ll /etc/rc.d/rc.local -rw-r--r--. 1 root root 752 Jun 8 21:47 /etc/rc.d/rc.local [root@node100.yinzhengjie.org.cn ~]# [root@node100.yinzhengjie.org.cn ~]# chmod +x /etc/rc.d/rc.local [root@node100.yinzhengjie.org.cn ~]# [root@node100.yinzhengjie.org.cn ~]# ll /etc/rc.d/rc.local -rwxr-xr-x. 1 root root 752 Jun 8 21:47 /etc/rc.d/rc.local [root@node100.yinzhengjie.org.cn ~]#

  注意,如果沒有配置的話,我們在安裝CDH服務也能成功安裝,可能會出現如下圖所示的提示信息:

 

五.修改Linux內核參數

[root@node100.yinzhengjie.org.cn ~]# tail -8 /etc/sysctl.conf           #編輯內核參數文件,對Linux內核參數的修改如下
#Add by yinzhengjie
fs.aio-max-nr=1048576
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096    262144 16777216
net.ipv4.tcp_wmem=4096  262144 16777216
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# sysctl -p                  #我們使用該命令就可以讓"/etc/sysctl.conf"中的配置生效
fs.aio-max-nr = 1048576                                #最大並發I/O請求數
net.core.rmem_default = 262144                            #操作系統接收緩沖區的默認大小
net.core.wmem_default = 262144                            #操作系統發送緩沖區的默認大小
net.core.rmem_max = 16777216                             #操作系統接收緩沖區最大值
net.core.wmem_max = 16777216                             #操作系統發送緩沖區最大值
net.ipv4.tcp_rmem = 4096    262144 16777216                    #接收窗口尺寸的最小,默認,最大值
net.ipv4.tcp_wmem = 4096  262144 16777216                     #發送窗口尺寸的最小,默認,最大值
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 

 

六.增加文件限制

為了避免集群中的任何文件描述符錯誤,需要增加單個用戶或進程一次可以打開的文件數量的限制。可以使用以下命令檢查當前限制。

[root@node100.yinzhengjie.org.cn ~]# ulimit -Sn        #軟限制
1024
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ulimit -Hn        #硬限制,很顯然,在大數據集群環境中,我們不應該使用默認配置,Hortonworks推薦10000或者更多。
4096
[root@node100.yinzhengjie.org.cn ~]# 

通過對limits的設置來優化系統性能
[root@node100.yinzhengjie.org.cn ~]# tail -7 /etc/security/limits.conf
#ADD BY YINZHENGJIE
* soft nofile 1048576
* hard nofile 1048576
* soft nproc 1048576
* hard nproc 1048576
* soft memlock unlimited
* hard memlock unlimited 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# tail -3 /etc/security/limits.d/20-nproc.conf
#ADD BY YINZHENGJIE
* soft nproc 1048576
root soft nproc unlimited
[root@node100.yinzhengjie.org.cn ~]#


以上參數輸出解讀:
  第一列表示用戶和組
    如果是"*",則表示所有用戶或組進行限制。

  第二列表示軟限制還是硬限制,
    當進程使用的資源超過軟限制時系統日志會有警告產生,當進程使用的資源達到硬限制時,則無法繼續使用更多的限制,甚至有的程序會直接拋出異常,比如MySQL程序。

  第三列表示限制的資源類型
    如nofile表示打開文件描述符的最大數目,memlock表示最大鎖定內存地址空間(KB),nporc表示最大數量的進程,as表示地址空間的限制(KB),cpu表示最大CPU時間(分鍾)等等,這些在"/etc/security/limits.conf"配置文件有相應的說明。

  第四列表示限制的最大值
    也就是我們針對某個參數配置的具體數值。比如"* soft nofile 1048576",表示任何用戶對於文件句柄數的軟限制最大打開文件描述符是1048576。

溫馨提示:
  "/etc/security/limits.conf" 配置文件可限制文件打開數,系統進程等資源,在該文件配置中寫的最大用戶進程數是受"/etc/security/limits.d/90-nproc.conf"配置上限影響的。
  一般系統普通用戶進程數滿了都是修改/etc/security/limits.d/90-nproc.conf文件。

 

七.禁用Swap  

  理想情況下,服務器都不應該swap,尤其是DataNodes。

  可以使用一下命令檢查服務器上的swap狀態。
[root@node100.yinzhengjie.org.cn ~]# swapon -s
Filename                Type        Size    Used    Priority
/dev/dm-1                                  partition    1572860    0    -2
[root@node100.yinzhengjie.org.cn ~]# 

  可以使用以下命令在這些服務器上完全禁用該功能。
[root@node100.yinzhengjie.org.cn ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           3.7G        133M        3.4G         11M        174M        3.3G
Swap:          1.5G          0B        1.5G
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# swapoff -a
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# swapon -s
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           3.7G        132M        3.4G         11M        173M        3.3G
Swap:            0B          0B          0B
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 

  默認情況下,大多數Linux操作系統的swappiness被設置為60.如果swappiness設置為0,除非內存不足,Linux將避免使用磁盤,而設置100表示操作系統立即將程序切換到磁盤。我們知道,這是為60意味着從內存使用量達到操作系統分配的內存的一半左右的時間開始,操作系統會相當頻繁地使用磁盤上的交換文件。例如,如果將swappiness調低到10,則只有當RAM占用率達到90%左右時,操作系統才會使用磁盤上的交換文件。
[root@node100.yinzhengjie.org.cn ~]# cat /proc/sys/vm/swappiness 
30
[root@node100.yinzhengjie.org.cn ~]#

  Linux管理員可以將以下設置添加到"/etc/sysctl.conf"文件中來更改系統的swappiness值:
[root@node100.yinzhengjie.org.cn ~]# tail -1 /etc/sysctl.conf 
vm.swappiness = 1
[root@node100.yinzhengjie.org.cn ~]#

  管理員必須重新啟動服務器或者執行"sysctl -p"指定才能使新的swappiness設置生效。對於將swappiness值設置多低,沒有特別明確的強制規定。Cloudera專家建議將其設置為1。如果你的服務器是256G的內存的且你確定你的程序永遠不必發生OOM,可以將改值設置為0.
[root@node100.yinzhengjie.org.cn ~]# sysctl -q vm.swappiness
vm.swappiness = 1
[root@node100.yinzhengjie.org.cn ~]#

 

八.禁用IPv6

  IPv6被認為是IPv4的替代產品,它用來解決現有IPv4地址空間即將耗盡的問題。但我們的大數據集群一般都在內網運行。壓根就用不到IPv6的地址,因此開始IPv6功能對系統占用的資源是浪費的,因此我們可以考慮將其禁用。

  可以通過編輯"/etc/sysctl.conf"文件並在文件末尾加以下來禁用IPv6:
[root@node100.yinzhengjie.org.cn ~]# tail -1 /etc/sysctl.conf 
net.ipv6.conf.all.disable_ipv6 = 1
[root@node100.yinzhengjie.org.cn ~]#

  有的網友說除了上面一行,還得添加"net.ipv6.conf.default.disable_ipv6 = 1""net.ipv6.conf.lo.disable_ipv6 = 1"兩個參數,其實這兩個參數壓根就不需要往上寫,我們"net.ipv6.conf.all.disable_ipv6"就以及表示禁用當前服務器所有的網卡的ipv6功能啦~

 

九.磁盤設置

1>.掛載磁盤

  確保在掛載所有磁盤時使用noatime時間以及掛載所有目錄時使用nodir時間。這樣,可以避免在對Linux文件系統中的文件或目錄進行讀取操作時的不必要寫入操作,從而提高集群性能。

[root@node100.yinzhengjie.org.cn ~]# egrep -v "^#|^$" /etc/fstab 
/dev/mapper/centos-root /                       xfs     defaults,noatime,nodiratime        0 0
UUID=db0c809d-1a32-4009-b8f1-ca48ddfb294a /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/sdb1        /yinzhengjie        xfs    defaults,noatime,nodiratime    0 0
[root@node100.yinzhengjie.org.cn ~]# 

2>.測試磁盤I/O速度

博主推薦閱讀:https://www.cnblogs.com/yinzhengjie/p/9935478.html

[root@node100.yinzhengjie.org.cn ~]# hdparm -t /dev/sdb1

/dev/sdb1:
Timing buffered disk reads: 2502 MB in 3.01 seconds = 832.18 MB/sec          #如果你沒有看到70MB以上的速度,這意味着有一個潛在的問題存在,即你的磁盤性能讀取很低!可能會對服務造成影響!(需要檢查磁盤是否有故障)
[root@node100.yinzhengjie.org.cn ~]#

3>.檢查服務器的BIOS設置

    通過確保不啟用磁盤驅動IDE仿真等功能來保證服務器BIOS為最佳性能配置。存儲和系統管理員一般會關注這個配置。

 

十.更換默認的yum源

1>.創建備份目錄

[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 32
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# mkdir -p /etc/yum.repos.d/{default,back}
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 32
drwxr-xr-x  2 root root    6 Jun 13 05:27 back
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
drwxr-xr-x  2 root root    6 Jun 13 05:27 default
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# mkdir -p /etc/yum.repos.d/{default,back}

2>.備份所有默認的配置文件

[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 32
drwxr-xr-x  2 root root    6 Jun 13 05:27 back
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
drwxr-xr-x  2 root root    6 Jun 13 05:27 default
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# mv /etc/yum.repos.d/*repo /etc/yum.repos.d/default/
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 0
drwxr-xr-x 2 root root   6 Jun 13 05:27 back
drwxr-xr-x 2 root root 187 Jun 13 05:28 default
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# mv /etc/yum.repos.d/*repo /etc/yum.repos.d/default/

3>.下載阿里的yum源

[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 0
drwxr-xr-x 2 root root   6 Jun 13 05:27 back
drwxr-xr-x 2 root root 187 Jun 13 05:28 default
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  31161      0 --:--:-- --:--:-- --:--:-- 31537
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 4
drwxr-xr-x 2 root root    6 Jun 13 05:27 back
-rw-r--r-- 1 root root 2523 Jun 13 05:30 CentOS-Base.repo
drwxr-xr-x 2 root root  187 Jun 13 05:28 default
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4>.安裝第三方軟件源REPL

[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 4
drwxr-xr-x 2 root root    6 Jun 13 05:27 back
-rw-r--r-- 1 root root 2523 Jun 13 05:30 CentOS-Base.repo
drwxr-xr-x 2 root root  187 Jun 13 05:28 default
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# yum -y install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                                                                                                        | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                                      | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                                     | 3.4 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================================================
 Package                                                         Arch                                                      Version                                                 Repository                                                 Size
===================================================================================================================================================================================================================================================
Installing:
 epel-release                                                    noarch                                                    7-11                                                    extras                                                     15 k

Transaction Summary
===================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-11.noarch.rpm                                                                                                                                                                                                |  15 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                                                                                                                                                        1/1 
  Verifying  : epel-release-7-11.noarch                                                                                                                                                                                                        1/1 

Installed:
  epel-release.noarch 0:7-11                                                                                                                                                                                                                       

Complete!
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 12
drwxr-xr-x 2 root root    6 Jun 13 05:27 back
-rw-r--r-- 1 root root 2523 Jun 13 05:30 CentOS-Base.repo
drwxr-xr-x 2 root root  187 Jun 13 05:28 default
-rw-r--r-- 1 root root  951 Oct  2  2017 epel.repo
-rw-r--r-- 1 root root 1050 Oct  2  2017 epel-testing.repo
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# yum -y install epel-release

5>.生成緩存(此步驟可選,如果網絡比較卡的話可能會需要5~10分鍾左右)

[root@node100.yinzhengjie.org.cn ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                                                                                        | 6.6 kB  00:00:00     
 * base: mirrors.aliyun.com
 * epel: ftp.riken.jp
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                                                                                                        | 3.6 kB  00:00:00     
epel                                                                                                                                                                                                                        | 5.3 kB  00:00:00     
extras                                                                                                                                                                                                                      | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                                     | 3.4 kB  00:00:00     
(1/15): base/7/x86_64/filelists_db                                                                                                                                                                                          | 7.1 MB  00:00:03     
(2/15): epel/x86_64/group_gz                                                                                                                                                                                                |  88 kB  00:00:03     
(3/15): epel/x86_64/prestodelta                                                                                                                                                                                             | 1.6 kB  00:00:00     
base/7/x86_64/other_db         FAILED                                                                      25% [=========================                                                                        ] 190 kB/s |  10 MB  00:02:37 ETA 
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/fbebcd3de05e22bd1cd526e594f235968401471d4a9aef3c1ad356b6d1965365-other.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 10 MB  00:02:37 ETA 
Trying other mirror.
(4/15): epel/x86_64/other_db                                                                                                                                                                                                | 3.2 MB  00:00:23     
(5/15): extras/7/x86_64/filelists_db                                                                                                                                                                                        | 243 kB  00:00:00     
(6/15): extras/7/x86_64/prestodelta                                                                                                                                                                                         |  62 kB  00:00:00     
(7/15): extras/7/x86_64/other_db                                                                                                                                                                                            | 125 kB  00:00:00     
(8/15): updates/7/x86_64/filelists_db                                                                                                                                                                                       | 4.0 MB  00:00:01     
(9/15): updates/7/x86_64/prestodelta                                                                                                                                                                                        | 750 kB  00:00:00     
(10/15): updates/7/x86_64/other_db                                                                                                                                                                                          | 629 kB  00:00:00     
(11/15): base/7/x86_64/other_db                                                                                                                                                                                             | 2.6 MB  00:00:01     
epel/x86_64/updateinfo_zck     FAILED                                                                      49% [================================================                                                 ] 505 kB/s |  20 MB  00:00:40 ETA 
https://mirror.ps.kz/epel/7/x86_64/repodata/4584885fc665ab476c27c0577d8e28c8028ae125d7626bf6a7ab3e5bfcdafb08-updateinfo.xml.zck: [Errno 14] curl#7 - "Failed to connect to 2a00:5da0:1:1::141: Network is unreachable" kB/s |  20 MB  00:00:40 ETA 
Trying other mirror.
epel/x86_64/primary_db         FAILED                                                                      50% [================================================-                                                ] 150 kB/s |  20 MB  00:02:13 ETA 
http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/42c44d09589f67a9fc551051298e8c6578d592b91074731d6c51dbb9ae770a9a-primary.sqlite.bz2: [Errno 12] Timeout on http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/42c44d09589f67a9fc551051298e8c6578d592b91074731d6c51dbb9ae770a9a-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(12/15): epel/x86_64/updateinfo                                                                                                                                                                                             | 977 kB  00:00:48     
epel/x86_64/filelists_db       FAILED                                                                      51% [=================================================-                                               ]  40 kB/s |  20 MB  00:08:05 ETA 
http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/7/x86_64/repodata/8956b7e5ab6ff28caf8d112085e1e800b6d2fd9229a98bbcd9900c4c4d09c8c7-filelists.sqlite.bz2: [Errno 12] Timeout on http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/7/x86_64/repodata/8956b7e5ab6ff28caf8d112085e1e800b6d2fd9229a98bbcd9900c4c4d09c8c7-filelists.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(13/15): epel/x86_64/updateinfo_zck                                                                                                                                                                                         | 1.4 MB  00:01:46     
(14/15): epel/x86_64/filelists_db                                                                                                                                                                                           |  11 MB  00:03:26     
(15/15): epel/x86_64/primary_db                                                                                                                                                                                             | 6.8 MB  00:07:37     
Metadata Cache Created
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# yum makecache

6>.備份yum 源

[root@node100.yinzhengjie.org.cn ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/back/
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total 12
drwxr-xr-x 2 root root   30 Jun 13 05:43 back
-rw-r--r-- 1 root root 2523 Jun 13 05:30 CentOS-Base.repo
drwxr-xr-x 2 root root  187 Jun 13 05:28 default
-rw-r--r-- 1 root root  951 Oct  2  2017 epel.repo
-rw-r--r-- 1 root root 1050 Oct  2  2017 epel-testing.repo
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/back/
total 4
-rw-r--r-- 1 root root 2523 Jun 13 05:43 CentOS-Base.repo
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/default/
total 32
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/back/

7>. 檢查某個命令屬於哪個安裝包(比如檢查ifconfig屬於哪個安裝包)

[root@node100.yinzhengjie.org.cn ~]# yum provides ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: ftp.yz.yamagata-u.ac.jp
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
net-tools-2.0-0.24.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ifconfig



[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# yum provides ifconfig
[root@node100.yinzhengjie.org.cn ~]# yum provides htpasswd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: ftp.riken.jp
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
httpd-tools-2.4.6-88.el7.centos.x86_64 : Tools for use with the Apache HTTP Server
Repo        : base
Matched from:
Filename    : /usr/bin/htpasswd



httpd-tools-2.4.6-89.el7.centos.x86_64 : Tools for use with the Apache HTTP Server
Repo        : updates
Matched from:
Filename    : /usr/bin/htpasswd



[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# yum provides htpasswd
[root@node100.yinzhengjie.org.cn ~]# yum -y install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: ftp.riken.jp
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================================================
 Package                                                  Arch                                                  Version                                                                  Repository                                           Size
===================================================================================================================================================================================================================================================
Installing:
 net-tools                                                x86_64                                                2.0-0.24.20131004git.el7                                                 base                                                306 k

Transaction Summary
===================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 306 k
Installed size: 918 k
Downloading packages:
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm                                                                                                                                                                               | 306 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.24.20131004git.el7.x86_64                                                                                                                                                                                       1/1 
  Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                                                                                                                                                                                       1/1 

Installed:
  net-tools.x86_64 0:2.0-0.24.20131004git.el7                                                                                                                                                                                                      

Complete!
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# yum -y install net-tools

 

 

十一.安裝JDK1.8,並替換JCE文件(Kerberos等需要加密的組件會用到)

詳情請參考:https://www.cnblogs.com/yinzhengjie/p/10739218.html

1>.打開Oracle官方網站下載相應的平台的安裝包(https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2>.擴充密鑰長度(下載JCE文件)

Kerberos 需要使用256為的AES加密算法,而JRE默認中的密鑰長度比較短,並且不足以支撐。所以我們需要升級集群中所有服務器節點JRE的安全策略,使其能夠解除密鑰長度的限制。修改的方式是下載並替換JRE中的Unlimited JCEPolicy文件。

以JDK1.8為例,JCE8的下載地址為:https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html。

3>.將下載的jdk版本進行解壓安裝並配置環境變量

[root@node100.yinzhengjie.org.cn ~]# yum -y install lrzsz
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================
 Package                          Arch                              Version                                   Repository                       Size
====================================================================================================================================================
Installing:
 lrzsz                            x86_64                            0.12.20-36.el7                            base                             78 k

Transaction Summary
====================================================================================================================================================
Install  1 Package

Total download size: 78 k
Installed size: 181 k
Downloading packages:
lrzsz-0.12.20-36.el7.x86_64.rpm                                                                                              |  78 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : lrzsz-0.12.20-36.el7.x86_64                                                                                                      1/1 
  Verifying  : lrzsz-0.12.20-36.el7.x86_64                                                                                                      1/1 

Installed:
  lrzsz.x86_64 0:0.12.20-36.el7                                                                                                                     

Complete!
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# yum -y install lrzsz          #安裝Linux的工具
[root@node100.yinzhengjie.org.cn ~]# ll
total 187336
-rw-r--r--. 1 root root 8409 Mar 24 22:46 jce_policy-8.zip
-rw-r--r--. 1 root root 191817140 Mar 24 22:27 jdk-8u201-linux-x64.tar.gz
[root@node100.yinzhengjie.org.cn ~]#
[root@node100.yinzhengjie.org.cn ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   13G  1.4G   12G  11% /
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G   12M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1                 50G   33M   50G   1% /yinzhengjie
/dev/sdb1               1014M  146M  869M  15% /boot
tmpfs                    378M     0  378M   0% /run/user/0
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /yinzhengjie/
total 0
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# mkdir /yinzhengjie/softwares 
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# tar -zxf jdk-8u201-linux-x64.tar.gz -C /yinzhengjie/softwares/
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/jdk1.8.0_201/
total 25980
drwxr-xr-x. 2 10 143     4096 Dec 16 03:45 bin
-r--r--r--. 1 10 143     3244 Dec 16 03:45 COPYRIGHT
drwxr-xr-x. 3 10 143      132 Dec 16 03:45 include
-rw-r--r--. 1 10 143  5207434 Dec 12 17:07 javafx-src.zip
drwxr-xr-x. 5 10 143      185 Dec 16 03:45 jre
drwxr-xr-x. 5 10 143      245 Dec 16 03:45 lib
-r--r--r--. 1 10 143       40 Dec 16 03:45 LICENSE
drwxr-xr-x. 4 10 143       47 Dec 16 03:45 man
-r--r--r--. 1 10 143      159 Dec 16 03:45 README.html
-rw-r--r--. 1 10 143      424 Dec 16 03:45 release
-rw-r--r--. 1 10 143 21103945 Dec 16 03:45 src.zip
-rw-r--r--. 1 10 143   108109 Dec 12 17:07 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r--. 1 10 143   155002 Dec 16 03:45 THIRDPARTYLICENSEREADME.txt
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# vi /etc/profile
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# tail -3 /etc/profile
#Add by yinzhengjie
JAVA_HOME=/yinzhengjie/softwares/jdk1.8.0_201
PATH=$PATH:$JAVA_HOME/bin
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# source /etc/profile
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 

4>.將下載后的jce文件拷貝已經安裝的jdk1.8目錄中($JAVA_HOME/jre/lib/security/)

[root@node100.yinzhengjie.org.cn ~]# yum -y install zip unzip

 

[root@node100.yinzhengjie.org.cn ~]# ll
total 187336
-rw-r--r--. 1 root root      8409 Mar 24 22:46 jce_policy-8.zip
-rw-r--r--. 1 root root 191817140 Mar 24 22:27 jdk-8u201-linux-x64.tar.gz
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# unzip jce_policy-8.zip 
Archive:  jce_policy-8.zip
   creating: UnlimitedJCEPolicyJDK8/
  inflating: UnlimitedJCEPolicyJDK8/local_policy.jar  
  inflating: UnlimitedJCEPolicyJDK8/README.txt  
  inflating: UnlimitedJCEPolicyJDK8/US_export_policy.jar  
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll
total 187336
-rw-r--r--. 1 root root      8409 Mar 24 22:46 jce_policy-8.zip
-rw-r--r--. 1 root root 191817140 Mar 24 22:27 jdk-8u201-linux-x64.tar.gz
drwxrwxr-x. 2 root root        76 Dec 21  2013 UnlimitedJCEPolicyJDK8
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll UnlimitedJCEPolicyJDK8/
total 16
-rw-rw-r--. 1 root root 3035 Dec 21  2013 local_policy.jar
-rw-r--r--. 1 root root 7323 Dec 21  2013 README.txt
-rw-rw-r--. 1 root root 3023 Dec 21  2013 US_export_policy.jar
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/jdk1.8.0_201/jre/lib/security/        #查看為拷貝JCE文件之前目錄結構
total 164
-rw-r--r-- 1 10 143 4054 Dec 15 14:45 blacklist
-rw-r--r-- 1 10 143 1273 Dec 15 14:45 blacklisted.certs
-rw-r--r-- 1 10 143 104430 Dec 15 14:45 cacerts
-rw-r--r-- 1 10 143 2466 Dec 15 14:45 java.policy
-rw-r--r-- 1 10 143 41528 Dec 15 14:45 java.security
-rw-r--r-- 1 10 143 98 Dec 15 14:45 javaws.policy
drwxr-xr-x 4 10 143 38 Dec 15 14:45 policy
-rw-r--r-- 1 10 143 0 Dec 15 14:45 trusted.libraries
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# mv UnlimitedJCEPolicyJDK8/*.jar /yinzhengjie/softwares/jdk1.8.0_201/jre/lib/security/
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/jdk1.8.0_201/jre/lib/security/        #成功移動到該目錄
total 172
-rw-r--r--. 1   10  143   4054 Dec 16 03:45 blacklist
-rw-r--r--. 1   10  143   1273 Dec 16 03:45 blacklisted.certs
-rw-r--r--. 1   10  143 104430 Dec 16 03:45 cacerts
-rw-r--r--. 1   10  143   2466 Dec 16 03:45 java.policy
-rw-r--r--. 1   10  143  41528 Dec 16 03:45 java.security
-rw-r--r--. 1   10  143     98 Dec 16 03:45 javaws.policy
-rw-rw-r--. 1 root root   3035 Dec 21  2013 local_policy.jar
drwxr-xr-x. 4   10  143     38 Dec 16 03:45 policy
-rw-r--r--. 1   10  143      0 Dec 16 03:45 trusted.libraries
-rw-rw-r--. 1 root root   3023 Dec 21  2013 US_export_policy.jar
[root@node100.yinzhengjie.org.cn ~]# 
[root@node100.yinzhengjie.org.cn ~]# 

5>.如果沒有安裝JDK可能會報錯如下

安裝完JDK后我們需要做一些軟連接,該鏈接為CM默認查找JDK環境的路徑,如果你盡管安裝JDK但沒有做軟連接可能會遇到下面的坑,這個問題是因為網友在我博客中留言我中看到的,我找到了解決方案,原鏈接為:https://www.cnblogs.com/yinzhengjie/p/9638360.html#4252486。

 

 

問題分析
  
  Inspector did not run successfully.一般是由於沒有配置JDK環境。

  這種情況應該是你安裝了Oracle版本的JDK且自定義了JDK HOME路徑,盡管你將自己的JDK加入到“/etc/profile”中,CM Agent並不識別,它識別JDK的路徑是通過讀取自己的配置文件,即:“/opt/cloudera-manager/cm-5.15.1/lib64/cmf/service/common/cloudera-config.sh”。

解決方案有兩種:
  (1)一種是將jdk環境加入“local JAVA8_HOME_CANDIDATES”屬性中;
  (2)另一種就是配置軟連接,將“/usr/java/jdk1.8”指向你服務的JDK PATH即可。
  我推薦大家使用第二種方法,做一個軟連接即可也不需要去修改CM的配置文件,具體操作如下:
    [root@node101.yinzhengjie.org.cn ~]# mkdir /usr/java && cd /usr/java
    [root@node101.yinzhengjie.org.cn /usr/java]# 
    [root@node101.yinzhengjie.org.cn /usr/java]# ln -s /yinzhengjie/softwares/jdk1.8.0_201/ /usr/java/jdk1.8
    [root@node101.yinzhengjie.org.cn /usr/java]# 
    [root@node101.yinzhengjie.org.cn /usr/java]# ll
    total 0
    lrwxrwxrwx 1 root root 36 Jun 9 18:57 jdk1.8 -> /yinzhengjie/softwares/jdk1.8.0_201/
    [root@node101.yinzhengjie.org.cn /usr/java]#

 

 

十二.克隆虛擬機(經過上述修改后,接下來我們需要克隆出來8台虛擬機用於CDH大數據進群部署)

1>.進入克隆向導界面

 

2>.選擇克隆源

 

3>.選擇"鏈接克隆"

 

4>.自定義虛擬機名稱和存儲路徑

 

5>.克隆完成

 

6>.重復以上步驟,克隆其余7台虛擬機

 

7>.將虛擬機環境歸類

 

8>.編輯克隆后的虛擬機硬件配置並開機

9>.修改IP地址和主機名稱

 

10>.完成其它剩余7台虛擬機的IP地址修改,當然你可以隨意修改虛擬機的硬件配置喲


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM