07年大学毕业,到现在快10年了。一直做数据相关的开发工作,感觉对一个系统的评估越来越集中在两条上。
1. 是否是分布式系统
可以避免种异常情况,提供可靠性和高扩展性
2. 自动化程度如何
减小人力的介入
量化自我和极简主义的窝藏点
07年大学毕业,到现在快10年了。一直做数据相关的开发工作,感觉对一个系统的评估越来越集中在两条上。
1. 是否是分布式系统
可以避免种异常情况,提供可靠性和高扩展性
2. 自动化程度如何
减小人力的介入
想到有三种方法:
1. logstash
2. kafka-connect-elasticsearch
3. elasticsearch-river-kafka-1.2.1-plugin
方法一:简单,只需启动一个代理程序
方法二:与confluent绑定紧,有些复杂
方法三:代码很久没更新,后续支持比较差
logstash使用如下:
input {
kafka {
zk_connect => “kafka:2181”
group_id => “logstash”
topic_id => “apache_logs”
consumer_threads => 16
}
}
output {
elasticsearch {
document_id => “%{my_uuid}”
}
}
https://www.elastic.co/blog/just-enough-kafka-for-the-elastic-stack-part2
环境: spark 1.6, ElasticSearch 1.6.1, elasticsearch-hadoop
通过 elasticsearch-hadoop可以将spark 处理后的数据保存在Elastic上,后续数据的检查和查询非常方便。
https://db-blog.web.cern.ch/blog/prasanth-kothuri/2016-05-integrating-hadoop-and-elasticsearch-%E2%80%93-part-2-%E2%80%93-writing-and-querying
https://www.elastic.co/guide/en/elasticsearch/hadoop/master/spark.html
https://spark-packages.org/package/elastic/elasticsearch-hadoop
awk -F”\\\\t” ‘$2==”mob” && $6>=1000{print $0}’ /home/hdp-guanggao/huangqiang/tab_stats/load_search_index_alert_daily_stat
2017-01-16 mob 1 NULL NULL 13830 0 0 5609 5743.577000000127 9931.434000000025
2017-01-16 mob 1 100 137 11010 11010 24841 739 955.905000000001 1511.187999999999
2017-01-16 mob 1 100 209 10756 10756 24192 759 890.9829000000002 1451.3469999999988
2017-01-16 mob 1 36 276 174784 27841 47541 1333 1073.7799999999966 1797.8559999999936
2017-01-16 mob 1 99 NULL 1044051 177367 380066 8369 7046.894000000293 11722.183999999928
2017-01-16 mob 1 99 0 63728 10888 23481 497 383.7400000000007 685.7949999999996
2017-01-16 mob 1 99 141 9287 1560 3351 68 49.469999999999985 75.745
2017-01-16 mob 1 99 99 9241 1552 3229 87 74.70999999999997 113.146
详细使用参考
由于经常需要给各个老大发报表,需要将种pdf导出的报表合并成一个。在网上发现一款不错的软件cpdf,支持各个平台。使用如下:
cpdf 11.pdf 12.pdf 13.pdf 14.pdf 15.pdf -o out.pdf
具体详细的使用请参考文档
http://www.coherentpdf.com/usage-examples.html
环境:Ubuntu 14.04
sudo vi /etc/default/grub
修改
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
改成
GRUB_CMDLINE_LINUX_DEFAULT=”text”
sudo update-grub
sudo reboot
在使用linux的crontab定时调用程序时会经常判断程序是否已经启用,之前是直接在程序中判断程序是否启动。后来找到一种比较简洁的方法flock,它是一种文件锁的方式。
[adadmin@s11 ~]$ flock
flock (util-linux-ng 2.17.2)
Usage: flock [-sxun][-w #] fd#
flock [-sxon][-w #] file [-c] command…
flock [-sxon][-w #] directory [-c] command…
-s –shared Get a shared lock
-x –exclusive Get an exclusive lock
-u –unlock Remove a lock
-n –nonblock Fail rather than wait
-w –timeout Wait for a limited amount of time
-o –close Close file descriptor before running command
-c –command Run a single command string through the shell
-h –help Display this text
-V –version Display version
使用如下:
先创建一个文件
touch test_flock.lock
调用如下(以python test_flock.py为示例)
flock -nx test_flock.lock python test_flock.py
最近在想一个问题,使用spark mllib训练后的模型如何做一个在线预测的服务? 毕竟mllib只提供离线的训练和预测。想到大概有四种方法:
1. 使用spark streaming + kafka
直接使用spark streaming加载训练好的模型,然后通过从kafka上读取特征来预测数据,并将预测结果写回kafka中供客户端获取到。
2. spark + grpc
通过将spark mllib中的predict函数做成rpc service的形式,具体参考:
https://scalapb.github.io/grpc.html
3. spark + spray
通过spark mllib中的predict函数做restful的形式来预测。
4. spark + python flask
通过python调用spark mllib训练好的模型,借助flash提供接口
5. spark + python grpc
通过python grpc调用spark mllib训练好的模型,提供其它语言rpc接口
目前方法1, 4, 5是可行, 方法2,3并没有实际实现的经验,还需再探索。
jerry@ubuntu:~/serving$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import tensorflow
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py”, line 23, in <module>
from tensorflow.python import *
File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py”, line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py”, line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File “/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py”, line 24, in swig_import_helper
_mod = imp.load_module(‘_pywrap_tensorflow’, fp, pathname, description)
ImportError: numpy.core.multiarray failed to import
升级numpy至最新版本
sudo pip install numpy –upgrade
sudo mv /usr/lib/python2.7/dist-packages/numpy /usr/lib/python2.7/dist-packages/numpy_old
查看新的numpy路径
import numpy
numpy.__path__
最近使用pip安装包发现非常之慢,估计是gfw搞的鬼。没办法只好使用国内的镜像。
vi ~/.pip/pip.conf
[global]
index-url = http://pypi.douban.com/simple
或者
[global]
trusted-host = mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple