随笔-314  评论-209  文章-0  trackbacks-0

最新评论

共3页: 1    
re: hive中reduce个数设定 xzc 2018-03-07 11:43  
use dbhive;
set mapreduce.job.queuename=root.xqueue;
set hive.exec.stagingdir=/tmp/hive-staging;
#set hive.exec.reducers.bytes.per.reducer=1024000000;
set mapred.reduce.tasks = 50;
insert overwrite directory '/user/gxhb/bill_fee_1707/event_cdr' row format delimited fields terminated by '#' select rowkeyid,event_type_id,select_col,merge_col,base_table_name from tmp_bill_fee_1707 a where base_table_name='event_cdr';
sync_time=`cat ods_data_msg_sync_time`
diff_time=$(($(date %s) - $(date %s -d "${sync_time}")));

a=sunceenjoy
if echo $a|grep -qe '^sun' ;then echo yes;else echo no ;fi;

hostname=i001.hadoop.gx.cn
if [ "${hostname:0:1}" == "n" -o "${hostname:0:1}" == "i" ]; then echo true; else echo false; fi
re: shell判断文件是否存在 xzc 2017-06-17 09:57  
hostname=i001
if [ "${hostname:0:1}" == "n" -o "${hostname:0:1}" == "i" ]; then echo true; else echo false; fi

curl是linux下一个很强大的http命令行工具,其功能十分强大。

一、curl对http的常规访问

1. 访问网站

$ curl

回车之后,www.linuxidc.com 的html 显示在屏幕上了

2. 保存页面

用curl option: -o

$ curl -o page.html

可以看到屏幕上出现一个下载页面进度指示,等到100%,就保存完成了.

二、get模式

get模式什么option都不用,只需要把变量写在url里面就可以了,

例如:

$ curl /test.cgi?param1=nickwolfe¶m2=12345

三、post模式

使用 option -d,

例如:

$ curl -d "param2=nickwolfe¶m2=12345" /login.cgi

更多
xzc 2017-05-18 09:46  
netstat -nat|grep -i "10000"|awk '{print $5}'|awk -f: '{print $1}'|sort|uniq -c|sort -rn
netstat -na|grep established|awk '{print $5}'|awk -f: '{print $1}'|sort|uniq -c|sort -rn

netstat用法:
-a (all)显示所有选项,默认不显示listen相关
-t (tcp)仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化成数字。
-l 仅列出有在 listen (监听) 的服務状态

-p 显示建立相关链接的程序名
-r 显示路由信息,路由表
-e 显示扩展信息,例如uid等
-s 按各个协议进行统计
-c 每隔一个固定时间,执行该netstat命令。

提示:listen和listening的状态只有用-a或者-l才能看到
xzc 2017-05-17 23:13  
netstat -nat|grep -i "10000"
xzc 2017-04-25 17:44  
kerberos认证过程(3次通信)
1.次通信
[客户端] -> [明文]用户id -> [kdc](authentication server) -> [kdc密码]tgt(tgs会话密码) [客户端密码]用户id/tgs会话密码 -> [客户端]
2.次通信
[客户端] -> [tgs会话密码]用户id [明文]http服务名 tgt(tgs会话密码) ->[kdc](ticket granting server) -> [服务端密码]st(服务会话密码) [tgs会话密码]http服务名/服务会话密码 -> [客户端]
3.次通信
[客户端] -> [服务会话密码]用户id [服务端密码]st(服务会话密码) -> [服务端] -> [服务会话密码]http服务名 -> [客户端]
注:客户端:java代码客户端
kdc:kerberos认证服务器
服务端:http服务器
xzc 2017-04-25 15:57  
krb5kdc --认证
kadmin --管理账户
xzc 2017-04-14 11:30  
[@i002 ~]$ more /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1

#restrict 91.4.0.0 netmask 255.255.255.0
#restrict 91.5.0.0 netmask 255.255.255.0
#restrict 91.5.1.0 netmask 255.255.255.0

server 134.192.232.14

# unset default server
#server 127.127.1.0
#fudge 127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
xzc 2017-04-14 11:29  
ntpq -p
service ntpd status
service ntpd stop && ntpdate 134.201.27.12 && service ntpd start

server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org
xzc 2016-05-07 16:05  
find ./ -inum 83068 -print -exec rm -rf {} \;
xzc 2016-05-07 15:47  
根据i节点删除
ls -i
find ./ -inum 83068 -print -exec rm {} \;
xzc 2016-05-07 15:46  
find ./ -ctime 30 -print -exec rm {} \;
xzc 2016-04-01 15:01  
#测试
index_value1="a b c"
index_value2="1 2 3"
ifs=$ifs
echo ":${ifs}:"
ifs=$'\n'
for i1 in ${index_value1}
do
echo ${i1}
ifs=$ifs
for i2 in ${index_value2}
do
echo ${i1} ${i2}
done
done
xzc 2016-03-31 16:41  
select date_add(now(),interval -1 hour);select date_add(current_time(),interval -1 hour);
xzc 2016-03-30 10:33  
select str_to_date('20160322 12:00:00', '%y%m%d %t');;
xzc 2016-03-24 12:09  
comm -23 ${logs_path}/${shell_name}_${file_name_prefix}_ftp.log ${logs_path}/${shell_name}_${file_name_prefix}_hdfs.log
xzc 2016-03-24 12:07  
#取10分钟前的日期,解决日期跨界问题
day_id=`date -d '30 minute ago' %y%m%d`
xzc 2016-02-14 14:56  
rsync -a --delete blanktest/ inf_ws_exchange_log_bak/
xzc 2015-12-21 15:54  
linux的终端上,没有windows的搜索那样好用的图形界面工具,但find命令确是很强大的。

  比如按名字查找一个文件,可以用 find / -name targetfilename 。 唉,如果只知道名字,不知道地点,这样也不失为一个野蛮有效的方法。

  按时间查找也有参数 -atime 访问时间 -ctime 改变状态的时间 -mtime修改的时间。但要注意,这里的时间是以24小时为单位的。查看man手册后使用,你会很迷惑: -mtime n: files data was last modified n*24 hours ago. 字面上的理解是最后一次修改发生在n个24小时以前的文件,但实际上

  find ./ -mtime 0:返回最近24小时内修改过的文件。

  find ./ -mtime 1 : 返回的是前48~24小时修改过的文件。而不是48小时以内修改过的文件。

  那怎么返回10天内修改过的文件?find还可以支持表达式关系运算,所以可以把最近几天的数据一天天的加起来:

  find ./ -mtime 0 -o -mtime 1 -o -mtime 2 ……虽然比较土,但也算是个方法了。

  还有没有更好的方法,我也想知道。

  另外, -mmin参数-cmin / - amin也是类似的。

xzc 2015-11-27 18:08  
linux系统中,利用grep打印匹配的上下几行

如果在只是想匹配模式的上下几行,grep可以实现。

$grep -5 'parttern' inputfile //打印匹配行的前后5行

$grep -c 5 'parttern' inputfile //打印匹配行的前后5行

$grep -a 5 'parttern' inputfile //打印匹配行的后5行

$grep -b 5 'parttern' inputfile //打印匹配行的前5行

it动力测试如下:
查看mysql慢日志中ip地址为192.168.0.10发送过来的sql语句的后面三行

c/c code复制内容到剪贴板
tail -50 /usr/local/mysql/data/sql-slow.log |grep -3 '192.168.0.10'
xzc 2015-10-28 11:35  
$ find /home/gxeda/data -type f
/home/gxeda/data/p_cdr_table_type=5/.hive-staging_hive_2015-10-27_15-12-31_755_7195444337062300569-7182/_tmp.-ext-10000/000000_0
/home/gxeda/data/p_cdr_table_type=5/.hive-staging_hive_2015-10-27_15-12-31_755_7195444337062300569-7182/-ext-10001/tmpstats-0
/home/gxeda/data/p_cdr_table_type=5/000000_0
/home/gxeda/data/p_cdr_table_type=12/000000_0
/home/gxeda/data/p_cdr_table_type=3/000000_0
/home/gxeda/data/p_cdr_table_type=10/000000_0
$ find /home/gxeda/data -type f ! -path "*/.*"
/home/gxeda/data/p_cdr_table_type=5/000000_0
/home/gxeda/data/p_cdr_table_type=12/000000_0
/home/gxeda/data/p_cdr_table_type=3/000000_0
/home/gxeda/data/p_cdr_table_type=10/000000_0
xzc 2015-09-23 16:58  
curl -s -w " ::::: bdpapp01(9701): "%{time_total}"s\n" --header "token:xxx_token" --connect-timeout 60 --max-time 60 "
xzc 2015-09-23 16:56  
curl -x post --header "token:xxx_token" "
xzc 2015-09-21 11:35  
function myfunc()
{
local myresult='some value'
echo "$myresult"
}

result=$(myfunc) # or result=`myfunc`
echo $result
xzc 2015-09-21 11:35  
function myfunc()
{
local __resultvar=$1
local myresult='some value'
eval $__resultvar="'$myresult'"
}

myfunc result
echo $result
xzc 2015-09-10 11:24  
dmidecode -t system
xzc 2015-03-31 10:11  
select @@global.tx_isolation,@@tx_isolation;
xzc 2015-01-15 20:00  
set [session | global] transaction isolation level {read uncommitted | read committed | repeatable read | serializable}
xzc 2015-01-15 20:00  
set global tx_isolation='read-committed';
xzc 2014-12-29 16:54  
netstat -pt|grep 60030
ps -ef|grep 8080

lsof -i :60030

xzc 2014-12-08 21:14  
netstat -apn |awk '{print $4}'|awk -f: '{print $2}' >ss.txt
xzc 2014-12-01 09:42  
import java.util.date
date.new().gettime()
scan 'hispp_wo_order_info', {timerange => [1416455654039, 2416455654039]}
scan 'hispp_wo_order_info', {columns => 'cf:row_woi_id', timerange => [1416455654039, 2416455654039]}
xzc 2012-07-18 11:27  
shell如何实现 数字自动补零 字符串自动补零 awk
作者:lorry 日期:2012-01-12
字体大小: 小 中 大

大家在处理数据文件的时候,可能会遇到这个问题,shell 对字符串进行处理,如果字符串 长度不足3位,需要左边自动补0。比如:12,自动补齐为 012
解决的方法有两种,一种是shell的pringf命令,另一种是使用神器awk :

printf "d\n" 12
echo 12|awk '{printf("d\n",$0)}'
xzc 2012-07-12 21:22  
sql> select wm_concat(lan_id) from rr_lan;

wm_concat(lan_id)
--------------------------------------------------------------------------------
471,470,472,473,474,475,476,477,478,479,482,483
xzc 2012-07-12 11:19  
sql> select replace(wm_concat(menu_name), ',', '->')
2 from (select level, a.*
3 from mm_menu a
4 start with menu_id = 1021057
5 connect by menu_id = prior super_id
6 order by level desc);

replace(wm_concat(menu_name),'
--------------------------------------------------------------------------------
系统菜单->系统管理->数据质量->业务发展(分公司)->wifi场景建设效益监控报表
xzc 2012-06-01 10:37  
--周末
select day_id, to_char(day_id, 'day')
from (select to_date('201205', 'yyyymm') - 1 rownum day_id
from user_objects
where rownum <= to_char(last_day(to_date('201205', 'yyyymm')), 'dd'))
where to_char(day_id, 'd') in (1, 7);
select to_char(day_id, 'yyyymmdd')
from (select to_date('20120526', 'yyyymmdd') - rownum 1 day_id
from user_objects
where rownum <= substr(20120526, 7, 2))
where to_char(day_id, 'd') in (1, 7);
--星期一~星期五
select day_id, to_char(day_id, 'day')
from (select to_date('201205', 'yyyymm') - 1 rownum day_id
from user_objects
where rownum <= to_char(last_day(to_date('201205', 'yyyymm')), 'dd'))
where to_char(day_id, 'd') in (2, 3, 4, 5, 6);
select to_char(day_id, 'yyyymmdd')
from (select to_date('20120526', 'yyyymmdd') - rownum 1 day_id
from user_objects
where rownum <= substr(20120526, 7, 2))
where to_char(day_id, 'd') in (2, 3, 4, 5, 6);
xzc 2012-06-01 09:36  
--当月的日列表
select to_char(sysdate - rownum, 'yyyymmdd') day_id from user_objects where rownum < to_char(sysdate, 'dd');
--某月的日列表
select to_char(to_date('201007', 'yyyymm') - 1 rownum, 'yyyymmdd') day_id
from user_objects
where rownum <= to_char(last_day(to_date('201007', 'yyyymm')), 'dd');
xzc 2012-03-31 11:35  

sql> create table test(a varchar2(20), n varchar2(20));

table created
sql> insert into test values('a1','4');

1 row inserted

sql> insert into test values('a1','1');

1 row inserted

sql> insert into test values('a1','5');

1 row inserted

sql> insert into test values('a1','2');

1 row inserted

sql> insert into test values('a1','3');

1 row inserted

sql> insert into test values('a1','3');

1 row inserted

sql> insert into test values('a2','902404');

1 row inserted

sql> insert into test values('a2','33');

1 row inserted

sql> insert into test values('a2','33');

1 row inserted

sql> insert into test values('a2','33');

1 row inserted
sql> select a,
2 max(decode(tt,1,n,null)) test1,
3 max(decode(tt,2,n,null)) test2,
4 max(decode(tt,3,n,null)) test3,
5 max(decode(tt,4,n,null)) test4,
6 max(decode(tt,5,n,null)) test5,
7 max(decode(tt,6,n,null)) test6
8 from (
9 select a,n,
10 row_number() over(partition by a order by n) tt
11 from test
12 ) group by a
13 ;

a test1 test2 test3 test4 test5 test6
-------------------- -------------------- -------------------- -------------------- -------------------- -------------------- --------------------
a1 1 2 3 3 4 5
a2 33 33 33 902404
xzc 2012-03-31 11:28  
打横处理:
sql> select index_id, index_name, max(decode(ms_area_id, 100, index_value)), max(decode(ms_area_id, 806, index_value))
2 from rpt_group_bonus_mon
3 group by index_id, index_name
4 order by index_id;
xzc 2011-12-22 09:36  
function myclass(id, name)
{
this.id = id;
this.name = name;
}

myclass.prototype =
{
showmessage: function()
{
alert("id: " this.id ", name: " this.name);
},
showmessage2: function()
{
alert("method2");
}
}

var obj1 = new myclass(1, "johnson");
obj1.showmessage();
obj1.name="john";
obj1.showmessage();
var obj2 = new myclass(2, "amanda");
obj2.showmessage();
xzc 2011-12-22 09:36  
function subclass(){ }
subclass.prototype =
{
name: "sub"
}

function myclass()
{
//构造函数
}

myclass.prototype =
{
id: 1,
name: "johnson",
subobj: new subclass(),
showmessage: function()
{
alert("id: " this.id ", name: " this.name "subobj.name:" this.subobj.name);
}
}

var obj1 = new myclass();
obj1.subobj.name = "xxx";
obj1.showmessage();
var obj2 = new myclass();
obj2.showmessage();
xzc 2011-12-05 13:11  
--ip解释
select a.*,
substr(a.begin_ip_sub, 1, instr(a.begin_ip_sub, '.', 1, 1) - 1),
substr(a.begin_ip_sub,
instr(a.begin_ip_sub, '.', 1, 1) 1,
instr(substr(a.begin_ip_sub, instr(a.begin_ip_sub, '.', 1, 1) 1), '.') - 1),
substr(a.begin_ip_sub,
instr(a.begin_ip_sub, '.', 1, 2) 1,
instr(substr(a.begin_ip_sub, instr(a.begin_ip_sub, '.', 1, 2) 1), '.') - 1),
substr(a.begin_ip_sub, instr(a.begin_ip_sub, '.', 1, 3) 1)
from twb_ip_lan_config a;
xzc 2011-11-04 12:59  
public static final string tohex(byte b) {
return ("" "0123456789abcdef".charat(0xf & b >> 4) "0123456789abcdef".charat(b & 0xf));
}
这样比你那样方便多了 呵呵 用我给你的方法单个解析byte就可以了
xzc 2011-10-31 17:13  
grant all on sys.utl_file to edp_sso
grant read on directory data_pump_dir to edp_sso;
grant write on directory data_pump_dir to edp_sso;
xzc 2011-09-07 22:52  
用法说明:
awk -f ngn.awk ss.txt>new.txt
ss.txt为源文件
new.txt为处理结果文件
把ngn.awk放到shell目录下

#ngn.awk
begin {
fs = ":";
}
{
if(substr($1,1,9) == "endofuser") {
printf ("%s|%s\n",baseinfo,camelinfo);
authinfo = "";
baseinfo = "";
ssdata = "";
camelinfo ="";
} else if ($1 == "authinfo") {
#split($2,a,",");
#authinfo = "";
} else if ($1 == "baseinfo") {
split($2,a,",");
baseinfo=a[1]"|"a[2]"|"a[34]"|"a[40];
} else if($1 == "ssdata") {
#split($2,a,",");
#ssdata = "";
} else if($1 == "camelinfo") {
split($2,a,",");
camelinfo=a[6];
}
}
end {

}

xzc 2011-08-08 17:01  
fstyp -v /dev/vgdbprd/lvsapdata7
--------------------------------------------------
aes04p63[/#]fstyp -v /dev/vgdbprd/lvsapdata7
vxfs
version: 4
f_bsize: 8192
f_frsize: 4096
f_blocks: 30720000
f_bfree: 14132693
f_bavail: 13912126
f_files: 3532944
f_ffree: 3533168
f_favail: 3533168
f_fsid: 1073938446
f_basetype: vxfs
f_namemax: 254
f_magic: a501fcf5
f_featurebits: 0
f_flag: 0 <====================注意这里,0表示是一般文件系统,16表示是大文件系统.
f_fsindex: 7
f_size: 30720000
xzc 2011-08-08 17:01  
cat /etc/fstab
共3页: 1    
网站地图