1. 程式人生 > >大資料linux系統部分命令解析(2)0912

大資料linux系統部分命令解析(2)0912

1.檢視ip ifconfig 解釋: ifconfig 常用命令關閉網絡卡,檢視ip。請看幫助! NAME ifconfig - configure a network interface

SYNOPSIS ifconfig [interface] ifconfig interface [aftype] options | address … OPTIONS interface The name of the interface. This is usually a driver name followed by a unit number, for example eth0 for the first Ethernet interface.

   up     This flag causes the interface to be activated.  It is implicitly specified if an address is assigned to the interface.

   down   This flag causes the driver for this interface to be shut down.

   [-]arp Enable or disable the use of the ARP protocol on this interface.

   [-]promisc
          Enable or disable the promiscuous mode of the interface.  If selected, all packets on the network  will  be  received  by  the
          interface.

   [-]allmulti
          Enable or disable all-multicast mode.  If selected, all multicast packets on the network will be received by the interface.

   metric N
          This parameter sets the interface metric. It is not available under GNU/Linux.

   mtu N  This parameter sets the Maximum Transfer Unit (MTU) of an interface.

   dstaddr addr
          Set  the remote IP address for a point-to-point link (such as PPP).  This keyword is now obsolete; use the pointopoint keyword
          instead.

   netmask addr
          Set the IP network mask for this interface.  This value defaults to the usual class A, B or C network mask  (as  derived  from
          the interface IP address), but it can be set to any value.

   add addr/prefixlen
          Add an IPv6 address to an interface.

   del addr/prefixlen
          Remove an IPv6 address from an interface.

linux ifconfig : 192.168.137.190

啟動關閉指定網絡卡:

ifconfig eth0 up ifconfig eth0 down ifconfig eth0 up為啟動網絡卡eth0,ifconfig eth0 down為關閉網絡卡eth0。ssh登陸linux伺服器操作要小心,關閉了就不能開啟了,除非你有多網絡卡。

為網絡卡配置和刪除IPv6地址:

ifconfig eth0 add 33ffe:3240:800:1005::2/64 #為網絡卡eth0配置IPv6地址 ifconfig eth0 del 33ffe:3240:800:1005::2/64 #為網絡卡eth0刪除IPv6地址 用ifconfig修改MAC地址:

ifconfig eth0 hw ether 00:AA:BB:CC:dd:EE 配置IP地址:

[[email protected] ~]# ifconfig eth0 192.168.2.10 [[email protected] ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 [[email protected] ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255 啟用和關閉arp協議:

ifconfig eth0 arp #開啟網絡卡eth0 的arp協議 ifconfig eth0 -arp #關閉網絡卡eth0 的arp協議 設定最大傳輸單元:

ifconfig eth0 mtu 1500 #設定能通過的最大資料包大小為 1500 bytes 【站長推薦】淘寶購物省錢小竅門,有些商品優惠力度高達50%,非常誇張!

ping hadoop000

[[email protected] ~]# hostname -i
192.168.137.190
[[email protected] ~]# 

/etc/hosts檔案

hosts 檔案相當於本地的DNS。 DNS 又涉及到正向解析 反向解析等等。 192.168.137.190 hadoop000 [[email protected] etc]# cat hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 [[email protected] etc]# [[email protected] etc]# [[email protected] etc]# cat host.conf multi on [[email protected] etc]# cat hosts.allow #

hosts.allow This file contains access rules which are used to

allow or deny connections to network services that

either use the tcp_wrappers library or that have been

started through a tcp_wrappers-enabled xinetd.

#

See ‘man 5 hosts_options’ and ‘man 5 hosts_access’

for information on rule syntax.

See ‘man tcpd’ for information on tcp_wrappers

#

2.如何判斷Linux服務是否存活 2.1 程序 ps -ef|grep httpd 2.2 埠號 netstat -nlp|grep 1943

第一步測試網路聯通性,通過系統命令抓取相關的資料。檢查路由資訊! ping xxx服務所在的機器的ip: 第二步 檢視xxx服務的埠號和服務地址 首先定位應用是否有相關程序, 檢查服務地址狀態是up or down。 第三步 telnet 192.168.137.190 80 這是ping ip加埠號 [[email protected] ~]# yum install telnet [[email protected] ~]# telnet 192.168.137.190 80 Trying 192.168.137.190… Connected to 192.168.137.190. Escape character is ‘^]’. 連成功

3.設定服務開機自啟動 [[email protected] ~]# chkconfig –list | grep http httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off [[email protected] ~]# chkconfig httpd on [[email protected] ~]# chkconfig –list | grep http httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off [[email protected] ~]#

4.檢視檔案內容 cat more less

實時檢視 tail -f xxx.log tail -F xxx.log -F = -f -retry

[[email protected] ruozedata]# touch jepson.log [[email protected] ruozedata]# [[email protected] ruozedata]# ll total 0 -rw-r–r–. 1 root root 0 Sep 12 21:42 jepson.log [[email protected] ruozedata]# tail -f jepson.log

[[email protected] ruozedata]# echo “www.ruozedata.com” >> jepson.log [[email protected] ruozedata]#

這是tab1視窗顯示 :www.ruozedata.com

log4j 200M 10份 jepson.log—>200M mv jepson.log jepson.log1 touch jepson.log

jepson.log1 jepson.log2 jepson.log3 … jepson.log10

[[email protected] ruozedata]# mv jepson.log jepson.log1 [[email protected] ruozedata]# touch jepson.log [[email protected] ruozedata]# [[email protected] ruozedata]# echo “www.ruozedata.com” >> jepson.log [[email protected] ruozedata]# echo “www.ruozedata.com” >> jepson.log [[email protected] ruozedata]# echo “www.ruozedata.com” >> jepson.log [[email protected] ruozedata]# echo “www.ruozedata.com” >> jepson.log [[email protected] ruozedata]#

這是tab1視窗顯示 無新資料

[[email protected] ruozedata]# tail -F jepson.log www.ruozedata.com www.ruozedata.com www.ruozedata.com www.ruozedata.com

[[email protected] ruozedata]# mv jepson.log jepson.log2 [[email protected] ruozedata]# touch jepson.log [[email protected] ruozedata]# echo “ruoze” >> jepson.log

這是tab1視窗顯示 有新資料 [[email protected] ruozedata]#

tail: jepson.log' has become inaccessible: No such file or directory tail:jepson.log’ has appeared; following end of new file ruoze

5.如何找命令 [[email protected] ~]# [[email protected] ~]# cat ruozedata/jepson.log ruoze [[email protected] ~]# cat1 ruozedata/jepson.log -bash: cat1: command not found [[email protected] ~]#

command not found: 1.輸入系統命令 [[email protected] ~]# which cat /bin/cat [[email protected] ~]# echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [[email protected] ~]# ll /usr/lib64/qt-3.3/bin/cat ls: cannot access /usr/lib64/qt-3.3/bin/cat: No such file or directory [[email protected] ~]# ll /usr/local/sbin/cat ls: cannot access /usr/local/sbin/cat: No such file or directory [[email protected] ~]# ll /bin/cat -rwxr-xr-x. 1 root root 48568 Nov 22 2013 /bin/cat

2.安裝服務的命令 安裝軟體的目錄/bin

$PATH

6.找檔案或資料夾 find / -name ‘abc’ 全文搜尋abc匹配的 find ./ -name ‘abc’ 當前目錄 find /tmp -name ‘abc’ 指定目錄

7.vi

題目: 如何使用vi清空一個檔案

echo ” > jepson.log1 cat /dev/null > jepson.log2

坑: 修改生產上面配置檔案 和其他同事的檔案,一定備份 cp jepson.log1 jepson.log1.20180912 vi jepson.log1

8.上傳下載 [[email protected] ~]# yum install lrzsz 上傳 win–>linux rz 下載 Linux–》win sz install.log

EditPlus工具

9.檔案大小 ll -h du -sh xxx.log

10.資料夾大小 du -sh xxxd

11.系統情況命令 記憶體: free -m 硬碟: df -h 負載: top

load average: 0.00, 0.00, 0.00 1min 5min 15min

10

哪些程序 負載高

12.壓縮解壓 zip -r ruoze.zip ruozedata/* unzip ruoze.zip

tar -czvf ruoze.tar.gz ruozedata/* tar -xzvf ruoze.tar.gz