一、Linux常用腳本
ps -ef|grep -i tom
scp root@/172.19.2.75:/home/root/full.tar.gz /home/daisy/full.tar.gz
pwd
hadoop dfsadmin -report
route 或者 netstat -r
route add default gw 10.25.125.1
service network restart
8.配置網卡命令
首先進入目錄/etc/sysconfig/network-scriptDEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=IP地址
USERCTL=no
PEERDNS=yes
GATEWAY=網關地址
/etc/init.d/iptables status
暫時關閉防火牆:
/etc/init.d/iptables stop
禁止防火牆在系統啓動時啓動
/sbin/chkconfig --level 2345 iptables off
重啓iptables:
/etc/init.d/iptables restart
即時生效,重啓後失效
service 方式
開啓: service iptables start
關閉: service iptables stop
執行清楚命令
iptables -F
10.uname -r/uname -a 查看操作系統版本
11.cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
du -sm * | sort -n //統計當前目錄大小 並安大小 排序
du -sk *|grep -data //查看一個文件夾大小
du data *|wc -l //查看當前目錄下文件數
hadoop fs -du /data1/hive/warehouse/
kill 命令
hadoop job -kill jobid
chown --help 幫助
chown -R cup:hadoop data/
crontab -l 查看定時
crontab -e 設置定時
前5個字段分別表示:
分鐘:0-59
小時:1-23
日期:1-31
月份:1-12
星期:0-6(0表示週日)
二、hive非交互模式命令
eg:hive -f script.sql
eg:hive -e 'select * from table a'
hive執行過程中,會在終端上顯示mapreduce的進度。如果不想顯示進度,可以使用-S選項。
這個靜音模式很實用,,通過第三方程序調用,第三方程序通過hive的標準輸出獲取結果集。
eg:$HIVE_HOME/bin/hive -S -e 'select a.col from tab1 a' > tab1.csv
三、Sqoop常用命令
sqoop list-databases --connect jdbc:mysql://localhost:3306/ -username 111 -password 111
sqoop list-tables --connect jdbc:mysql://localhost:3306/test --username 111 --password 111
sqoop create-hive-table --connect jdbc:mysql://localhost:3306/test --table users --username dyh --password 000000
--hive-table users --fields-terminated-by "\0001" --lines-terminated-by "\n";
參數說明:
--fields-terminated-by "\0001" 是設置每列之間的分隔符,"\0001"是ASCII碼中的1,它也是hive的默認行內分隔符,
而sqoop的默認行內分隔符爲"," --lines-terminated-by "\n" 設置的是每行之間的分隔符,此處爲換行符,也是默認的分隔符;
注意:只是複製表的結構,表中的內容沒有複製
sqoop import --connect jdbc:mysql://localhost:3306/test --username dyh --password 000000
--table users --hive-import --hive-table users -m 2 --fields-terminated-by "\0001";
參數說明:
-m 2 表示由兩個map作業執行;
--fields-terminated-by "\0001" 需同創建hive表時保持一致;
sqoop export --connect jdbc:mysql://192.168.20.118:3306/test --username dyh --password 000000
--table users --export-dir /user/hive/warehouse/users/part-m-00000 --input-fields-terminated-by '\0001'
sqoop import --append --connect jdbc:mysql://192.168.20.118:3306/test --username dyh --password 000000
--query "select id,age,name from userinfos where \$CONDITIONS" -m 1 --target-dir /user/hive/warehouse/userinfos2
--fields-terminated-by "
sqoop import --append --connect jdbc:mysql://192.168.20.118:3306/test --username dyh --password 000000
--table userinfos --columns "id,age,name" --where "id > 3 and (age = 88 or age = 80)" -m 1
--target-dir /user/hive/warehouse/userinfos2 --fields-terminated-by ",";