宣傳片拍攝制作報價明細(xì)百度關(guān)鍵詞seo外包
四、大數(shù)據(jù)集群服務(wù)器搭建
1. 新增Linux服務(wù)器
1.1、克隆虛擬機(jī)
學(xué)習(xí)環(huán)境中,一般使用VMware虛擬機(jī)克隆Linux系統(tǒng),用來進(jìn)行集群服務(wù)器的搭建。
VMware支持兩種類型的克隆:完整克隆、鏈接克隆 ?
完整克隆是和原始虛擬機(jī)完全獨(dú)立的一個復(fù)制,它不和原始虛擬機(jī)共享任何資源??梢悦撾x原始虛擬機(jī)獨(dú)立使用。鏈接克隆需要和原始虛擬機(jī)共享同一虛擬磁盤文件,不能脫離原始虛擬機(jī)獨(dú)立運(yùn)行。但采用共享磁盤文件卻大大縮短了創(chuàng)建克隆虛擬機(jī)的時間,同時還節(jié)省了寶貴的物理磁盤空間。通過鏈接克隆,可以輕松的為不同的任務(wù)創(chuàng)建一個獨(dú)立的虛擬機(jī)。
虛擬機(jī)克隆的前置條件:虛擬機(jī)處于關(guān)閉狀態(tài)。
虛擬機(jī)克隆的流程:
1.2、修改虛擬機(jī)的硬件配置
1.3、修改虛擬機(jī)的網(wǎng)絡(luò)配置
修改主機(jī)名hostname:
vim /etc/hostname
node2.itcast.cn
修改IP地址
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet" # 網(wǎng)卡類型 以太網(wǎng)
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33" #網(wǎng)卡名稱
UUID="74c3b442-480d-4885-9ffd-e9f0087c9cf7"
DEVICE="ens33"
ONBOOT="yes" #是否開機(jī)啟動網(wǎng)卡服務(wù)
IPADDR="192.168.88.152" #IP地址
PREFIX="24" #子網(wǎng)掩碼 等效: NETMASK=255.255.255.0
GATEWAY="192.168.88.2" #網(wǎng)關(guān)服務(wù)
DNS1="192.168.88.2" #網(wǎng)關(guān)DNS解析
DOMAIN="114.114.114.114" #公網(wǎng)DNS解析 114.114.114.114 谷歌:8.8.8.8 阿里百度DNS
IPV6_PRIVACY="no
systemctl restart network ? # 重啟網(wǎng)絡(luò)服務(wù)
2. 關(guān)閉防火墻
2.1、關(guān)閉firewalld
# 查看防火墻狀態(tài) systemctl status firewalld
# 關(guān)閉防火墻
systemctl stop firewalld
# 關(guān)閉防火墻開機(jī)自啟動
systemctl disable firewalld
# centos服務(wù)開啟關(guān)閉命令
centos6:(某些可以在centos7下使用)
service 服務(wù)名 start|stop|status|restart
chkconfig on|off 服務(wù)名
centos7:
systemctl start|stop|status|restart 服務(wù)名
systemctl disable|enable 服務(wù)名 #開機(jī)自啟動 關(guān)閉自啟
2.2、關(guān)閉SElinux
安全增強(qiáng)型 Linux(Security-Enhanced Linux)簡稱 SELinux,它是一個 Linux 內(nèi)核模塊,也是 Linux 的一個安全子系統(tǒng)。
SELinux 主要由美國國家安全局開發(fā)。2.6 及以上版本的 Linux 內(nèi)核都已經(jīng)集成了 SELinux 模塊。
SELinux 主要作用就是最大限度地減小系統(tǒng)中服務(wù)進(jìn)程可訪問的資源(最小權(quán)限原則)。
注意需要重啟才能生效。
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
3. 修改主機(jī)名
使用vi編輯器,修改主機(jī)名:
vim /etc/hostname root
重啟后生效
4. 修改hosts映射
分別編輯每臺虛擬機(jī)的hosts文件,在原有內(nèi)容的基礎(chǔ)上,填下以下內(nèi)容:
注意:不要修改文件原來的內(nèi)容,三臺虛擬機(jī)的配置內(nèi)容都一樣。
vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.88.151 node1.itcast.cn node1
192.168.88.152 node2.itcast.cn node2
192.168.88.153 node3.itcast.cn node3
5. SSH免密登錄
# 實現(xiàn)node1----->node2
# step1
在node1生成公鑰私鑰
ssh-keygen 一頓回車 在當(dāng)前用戶的home下生成公鑰私鑰 隱藏文件
[root@node1 .ssh]# pwd
/root/.ssh
[root@node1 .ssh]# ll
total 12
-rw------- 1 root root 1675 May 20 11:59 id_rsa
-rw-r--r-- 1 root root 402 May 20 11:59 id_rsa.pub
-rw-r--r-- 1 root root 183 May 20 11:50 known_hosts
# step2
copy公鑰給node2
ssh-copy-id node2
注意第一次需要密碼
# step3
[root@node1 .ssh]# ssh node2
Last login: Thu May 20 12:03:30 2021 from node1.itcast.cn
[root@node2 ~]# exit
logout
Connection to node2 closed.
# 課程要求:至少打通node1---->node1 node2 node3 這三個免密登錄
# 至于所有機(jī)器之間要不要互相免密登錄 看心情
6. 時鐘同步
命令 | 英文 | 含義 |
---|---|---|
ntpdate 互聯(lián)網(wǎng)時間服務(wù)器地址 | Network Time Protocol | 同步時間 |
阿里云時鐘同步服務(wù)器:ntpdate ntp4.aliyun.com
7. 遠(yuǎn)程文件拷貝
遠(yuǎn)程文件拷貝命令:scp
scp是 remote file copy program 的縮寫, scp是遠(yuǎn)程文件拷貝命令
7.1、從本機(jī)拷貝到遠(yuǎn)程服務(wù)器
準(zhǔn)備工作
# 創(chuàng)建目錄
mkdir -p /export/aaa/bbb/ccc
# 創(chuàng)建文件
touch /export/aaa/01.txt /export/aaa/02.txt
# 顯示
tree /export/aaa
1、文件
語法格式
拷貝文件
scp local_file remote_username@remote_ip:remote_folder
需求: 將本地 01.txt 文件 復(fù)制到 192.168.153.102 機(jī)器的 /export目錄下 ?
scp ?/export/aaa/01.txt ? root@192.168.153.102:/export
scp ?/export/aaa/02.txt ? root@hadoop02:/export
scp ?/export/aaa/02.txt ? hadoop02:/export
2、文件夾
語法格式
拷貝目錄
scp -r local_folder remote_username@remote_ip:remote_folder
需求: 將本地 aaa 目錄 復(fù)制到 192.168.150.102 機(jī)器的 /export 目錄下
scp -r /export/aaa root@192.168.153.102:/export
scp -r /export/aaa root@hadoop02:/export
scp -r /export/aaa hadoop02:/export
7.2、從遠(yuǎn)程服務(wù)器復(fù)制到本機(jī)
準(zhǔn)備工作
# 創(chuàng)建目錄
mkdir -p /export/a1/b1/c1
# 創(chuàng)建文件
touch /export/a1/111.txt touch /export/a1/222.txt
# 顯示內(nèi)容
tree /export/a1
1、文件
語法格式
scp remote_username@remote_ip:remote_file local_folder
練習(xí): 將 hadoop02的 111.txt 文件 復(fù)制到 hadoop01的 export目錄下
scp root@192.168.100.202:/export/a1/111.txt /export
scp root@hadoop02:/export/a1/222.txt /export
scp hadoop02:/export/a1/222.txt /export
2 目錄
語法格式
scp -r remote_username@remote_ip:remote_folder local_folder
練習(xí): 將hadoop02的 /export/a1/ 目錄 復(fù)制到 hadoop01 的 export目錄下
scp -r root@192.168.100.202:/export/a1 /export
scp -r hadoop02:/export/a1 /export
五、Shell編程
1. 什么是Shell
1.1、簡介
Shell 是一個用 C 語言編寫的程序, 通過 Shell 用戶可以訪問操作系統(tǒng)內(nèi)核服務(wù)。?
它類似于 DOS 下的 command 和后來的 cmd.exe。Shell既是一種命令語言,又是一種程序設(shè)計語言。?
Shell script 是一種為shell編寫的腳本程序。?Shell 編程一般指shell腳本編程,不是指開發(fā)shell自身。
1.2、Shell解釋器
Shell編程跟java、php編程一樣,只要有一個能編寫代碼的文本編輯器和一個能解釋執(zhí)行的腳本解釋器就可以了。?
Linux的Shell解釋器種類眾多,一個系統(tǒng)可以存在多個 shell,可以通過cat ?/etc/shells 命令查看系統(tǒng)中安裝的 shell。?
bash 由于易用和免費(fèi),在日常工作中被廣泛使用。同時, bash 也是大多數(shù)Linux 系統(tǒng)默認(rèn)的 Shell。
總結(jié):java執(zhí)行需要虛擬機(jī)解釋器, 同理shell程序執(zhí)行也需要解析器
2. 快速入門
2.1、編寫Shell腳本
使用 vi 編輯器新建一個文件hello.sh(擴(kuò)展名并不影響腳本執(zhí)行)
#!/bin/bash
echo "Hello World !"
# ! 是一個約定的標(biāo)記,它告訴系統(tǒng)這個腳本需要什么解釋器來執(zhí)行,即使用哪一種 Shell
echo命令 用于向窗口輸出文本。?
給shell程序賦予執(zhí)行權(quán)限:?
chmod +x ./hello.sh ?# 使腳本具有執(zhí)行權(quán)限 ?
2.2、執(zhí)行Shell腳本
執(zhí)行shell程序:
./hello.sh ?#執(zhí)行腳本 ?
直接寫 hello.sh,linux 系統(tǒng)會去 PATH 里尋找有沒有叫hello.sh的。??
用 ./hello.sh 告訴系統(tǒng)說,就在當(dāng)前目錄找
還可以作為解釋器參數(shù)運(yùn)行。直接運(yùn)行解釋器,其參數(shù)就是 shell 腳本的文件名,如:sh ?/root/shelldemo/hello.sh
在使用解釋器直接執(zhí)行shell程序這種方式來運(yùn)行腳本,不需要考慮腳本程序的執(zhí)行權(quán)限了
小結(jié):?使用vi編輯器,創(chuàng)建shell程序文件。通常使用.sh作為shell程序后綴名。
shell程序的基本格式:
1、指定解釋器信息。默認(rèn):/bin/bash
2、書寫shell程序代碼
3、保存shell程序代碼
4、執(zhí)行shell程序 ? ? 提前:給shell程序授予可執(zhí)行權(quán)限 ? ?
第一種:./xxx.sh ? #在當(dāng)前目錄中執(zhí)行shell程序 ? ?
第二種:/xx/xxx.sh ? #書寫全路徑的shell程序 ? ?
第三種:sh /xx/xxx.sh ?#把shell程序作用/bin/sh解釋器的參數(shù),通過運(yùn)行解釋器來執(zhí)行shell