ITeye博客

The Big Data Way

heipark · 共 366 篇文章

[置顶] 我的linux命令笔记

允许非root用户使用“sudo” root身份登录系统,执行“visudo”,根据示例添加新的一个规则(记住输入的密码是当前用户密码,而不是root密码) #不需要密码执行sudo命令 hadoop ALL=(ALL) NOPASSWD: ALL 日期 时间戳转日期 date -d '1970-01-01 UTC 1312438633.724 seconds' +"%Y-%m-%d %T" #显示现在日期 echo `date -d now +%Y%m%d` #显示昨天日期 echo `date -d yesterday +%Y%m%d` #加减时间 date +%Y%m%d --date…

2011-06-13 13:30 · Linux · 评论(0)

shell下使用log4j 1.x “No appenders could be found for logger”问题两个处理办法

错误: log4j:WARN No appenders could be found for logger (org.apache.flink.core.fs.FileSystem). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 现象: 不打印log 方法一,通过classpath指定log4j.properties配置文件路径(是路径!) java -cla…

2018-05-25 23:25 · Java · Linux · 评论(0)

flink1.3.2 quickstart 遇到问题

官方文档: https://ci.apache.org/projects/flink/flink-docs-release-1.3/quickstart/setup_quickstart.html win7安装遇到问题: 问题:nc无法执行: 解决: 下载地址:https://joncraton.org/files/nc111nt_safe.zip 执行命令:nc.exe -l -p 9000 Linux安装遇到问题: 问题: $./start-local.sh 报错:sed: invalid option -- E 原因: 我执行的机器是CentOS 5.7,sed不支持-E,所以要修改下…

2017-08-14 15:29 · flink · 评论(0)

python dict根据key和value排序

根据key排序 a = {'a':1, 'c':2, 'b':3} [(k,a[k]) for k in sorted(a.keys())] #返回 [('a', 1), ('b', 3), ('c', 2)] 根据value排序 a = {'a':1, 'c':2, 'b':3} sorted(a.items(), key=lambda d:d[1], reverse = True) #返回list:[('b', 3), ('c', 2), ('a', 1)]

2017-02-14 19:37 · python · 评论(0)

使用python class变量的风险

class Parent(object): x = 1 class Child1(Parent): pass class Child2(Parent): pass print Parent.x, Child1.x, Child2.x # 1 1 1 Child1.x = 2 print Parent.x, Child1.x, Child2.x # 1 2 1 Parent.x = 3 print Parent.x, Child1.x, Child2.x # 3 2 3 这段代码重点在第三次print结果“3 2 3” 当子类没有重新设置父类的变量时,会直接使用父类的变量,所以当父类变量发生变…

2016-12-14 12:50 · python · 评论(0)

linux screen命令

script /dev/null # 将屏幕操作输出到null 创建一个screen: screen -S <xxxx> 创建一个屏幕:按住ctrl + a(后简称c-a),再按c(ctrl + d退出) 切换屏幕:c-a, n (或者c-a, p ) 分割窗口:Ctrl + a S (S大写),(Ctrl + a Tab使光标到下面的窗口中,然后按 Ctrl + a c来创建新屏幕) 快速切换screen:c-a,1,2,3... 两个窗口快速切换:c-a, c-a 显示所有窗口列表:C-a w 参考: http://www.cnblogs.com/mchina/archive/2013/…

2016-06-29 13:55 · Linux · 评论(0)

记录linux下安装python MySQLdb

#下载:mysql-python/ https://sourceforge.net/projects/mysql-python/files/mysql-python/ #安装mysql-python 解压缩tar包 python setup.py build # 报错找不到mysql_config时,vi site.cfg python setup.py install #安装mysql及其客户端 yum install mysql-devel mysql-server #遇到错误 1. 执行MySQLdb.connect()报错"2027: Malformed packet",出现这个问题…

2016-06-27 21:21 · python · 评论(0)

通过java class文件确定其编译器版本

方法一: hexdump -C XXX.class 返回信息:ca fe ba be 00 00 00 34 ..... 前几位"ca fe ba be"是固定的,后面34标识,当前class是JDK8编译的。 对照表: Java SE 9 = 53 (0x35 hex), [3] Java SE 8 = 52 (0x34 hex), Java SE 7 = 51 (0x33 hex), Java SE 6.0 = 50 (0x32 hex), Java SE 5.0 = 49 (0x31 hex), 方法二 javap -verbose Xxxx (不要加.class) 返回信息头几行:m…

2016-06-23 10:45 · Java · 评论(0)

python new-style class和old-stype class使用super的方式

#old-style class class Base(): def __init__(self, name): self.name = name class Child(Base): def __init__(self,name): Base.__init__(self,name) print self.name Child('zs') #new-style class class Base(object): def __init__(self, name): self.name = name class Child(Base): def __init__(self,name): supe…

2015-12-01 22:27 · python · 评论(0)

python unittest加载自己写的测试

在python unittest库中TestLoader中还有,discover是最简单的方式,另外可以直接使用nose。 def discover(): loader = unittest.TestLoader() suite1 = loader.discover('/xx/xx/xx') suite2 = loader.discover('/yy/yy/yy') alltests = unittest.TestSuite((suite1, suite2)) return unittest.TextTestRunner(verbosity=2).run(alltests)

2015-12-01 22:23 · python · 评论(0)

python类变量,类方法,静态方法

一、class object、class variable 首先class在python里面是一个对象,它有独立区域存储属于自己的数据,而不需要实例化。 class Hehe(object): count = 0 # class variable def __init__(self, c): Hehe.count = Hehe.count + c print 'addres same' if id(Hehe.count) == id(self.count) else 'addres not same' #addres same self.count = self.count + c # in…

2015-08-05 11:52 · python · 评论(0)

python2.7 print不换行的三种方法

方法一: import sys sys.stdout.write("go ") sys.stdout.write("home") sys.stdout.flush() 方法二:函数方式调用print函数 from __future__ import print_function print('go ', end='') print('home', end='') 方法三: print 'go', print 'home' 这种方法如果你直接执行python执行命令,然后敲入命令,是不行的,但如果放到文件里面运行,是可以的 -end

2015-07-30 10:54 · python · 评论(0)

linux expect

1. 创建、编辑文件go.sh #!/usr/bin/expect spawn sudo su admin expect "*password*" { send "13456\r\n" } interact 2. 设置权限 chmod u+x go.sh 3. 运行 ./go.sh 因为我们要使用expect执行,所以使用命令sh go.sh是不行的,会报“linux expect spawn: command not found”错误。

2015-07-17 17:08 · 评论(0)

Linux通过网络端口(或者PID)查找运行程序路径

nginx运行在38989端口 1. netstat -anp | grep 38989 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:38989 0.0.0.0:* LISTEN 81287 /nginx -s start 程序PID为: 81287 2. 查看/proc ll /proc/81287 lrwxrwxrwx 1 admin admin 0 Ma…

2015-05-07 16:47 · Linux · 评论(2)

nginx学习记录

1. 使用监控页面 安装: 安装时添加--with-http_stub_status_module配置,命令如下: ./configure --prefix=<your_path> --with-http_stub_status_module make make install 配置: conf/nginx.conf添加: location /nginx_status { stub_status on; access_log off; #allow x.x.x.x #deny all; } 效果 浏览器访问:http://x.x.x.x/nginx_status,效果如下: Active c…

2015-04-28 17:42 · 服务器 · 评论(0)