tomcat/bin/catalina.sh
中的 #CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=19000,server=y,suspend=n"
css
mysql -uusername -p1234556 -hdb.org --port=5003
管理->主机网络管理器->手动配置网卡
->配置仅主机网络属性:ip和网络掩码设置->网络->网卡1
选择网络地址转换(NAT)
,混杂模式(所有容许)
, 网卡2
:选择仅主机网络sudo vim /etc/network/interfaces
,配置以下# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.101
netmask 255.255.255.0
复制代码
sudo vim /etc/resolvconf/resolv.conf.d/base
# 根据我的电脑设置
# ipconfig /all windows查看
nameserver 8.8.8.8
复制代码
sudo reboot
重启便可netstat -aon | findstr 16661
taskkill /F /PID 14560
date +%Y%m%d -d '+1 day/min'
,转换成时间戳date -d '2013-2-22 22:14' +%s
, 时间戳转换成日期date -d @1512088011 +'%Y%m%d'
netstat -aon
lsof -p
(list open file):查看进程使用的文件,-p指定pid
awk -F"\t" '{if($2 == "1"){print $1}}' | less
,没法匹配出数据java
grep 后面 跟less/more不会对查询结果标红mysql
修改css后页面没有刷新linux
缓存问题,能够在css加载语句的后面添加?v=1.0.0让浏览器从新加载资源。web
js find 过滤器算法
var rs = extObj.find("tr[role!='head'][role!='foot']");
实现多重条件选择sql
Jetty 热部署apache
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
<stopPort>9977</stopPort>
<stopKey>foo</stopKey> <scanIntervalSeconds>0</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
</configuration>
</plugin>
复制代码
ctrl+shift+f9
从新build当前文件 ctrl+f9
从新build整个目录问题:ubuntu
2017-10-25 21:52:17,528 FATAL [main] org.apache.hadoop.mapred.YarnChild: Error running child : java.lang.OutOfMemoryError: Direct buffer memory
复制代码
解决: reduce 阶段,申请使用操做系统的内存,没有控制好,出现了内存泄露,致使的内存溢出。申请内存超过8192MB和不能被1024MB整除的资源请求vim
-Xmx
Java Heap最大值,默认值为物理内存的1/4,最佳设值应该视物理内存大小及计算机内其余内存开销而定;-Xms
Java Heap初始值,Server端JVM最好将-Xms和-Xmx设为相同值,开发测试机JVM能够保留默认值;-Xmn
Java Heap Young区大小,不熟悉最好保留默认值;-Xss
每一个线程的Stack大小,不熟悉最好保留默认值;Map和Reduce阶段不能对集合进行写操做。即便写了在reduce阶段也读不出来。
map和reduce会在不一样的服务器上操做,全局变量没法生效。 一、经过Configuration保存String变量; 二、在reduce或者map阶段读取小文件存入内存,进行操做。
reduce阶段,==Iterable的迭代只能遍历一次==,第二次遍历后没有数据,因此会形成结果匹配错误。因此应该先将数据保存,再遍历。
set class 要在set configuration以后这样才会保存配置
若是reduce的Value不输出值得话,返回类型用NullWritable.get(),这样能够保证文件中在key的后面不会出现tab
Mapper Reducer类的子类要是static,不然会报初始化错误
==对于MR的return要谨慎使用,防止跳出,部分结果没法输出==
%b:打印文件大小(目录为0)
%n:打印文件名
%o:打印block size (咱们要的值)
%r:打印备份数
%y:打印UTC日期 yyyy-MM-dd HH:mm:ss
%Y:打印自1970年1月1日以来的UTC微秒数
%F:目录打印directory, 文件打印regular file
复制代码
hadoop job -status jobid job_1509011180094_5418072
结果说明:
Uber job : false-----uber模式:false,Uber模式简单地能够理解成JVM重用。
以Uber模式运行MR做业,全部的Map Tasks和Reduce Tasks将会在ApplicationMaster所在的容器(container)中运行,
也就是说整个MR做业运行的过程只会启动AM container,由于不须要启动
mapper 和reducercontainers,因此AM不须要和远程containers通讯,整个过程简单了。
Number of maps: 13702 -----map总数:
Number of reduces: 500 -----reduces总数
map() completion: 1.0
reduce() completion: 1.0
Job state: SUCCEEDED -----job状态
retired: false
reason for failure: -----failure缘由
Counters: 58 -----counter总数
File System Counters -----这个group表示job与文件系统交互的读写统计
FILE: Number of bytes read=0 -----job读取本地文件系统的文件字节数。假定咱们当前map的输入数
据都来自于HDFS,那么在map阶段,这个数据应该是0。但reduce在在执
行前,它的输入数据是通过Shuffle的merge后存储在reduce端本地磁盘
中,因此这个数据就是全部reduce的总输入字节数。
FILE: Number of bytes written=5654852533 -----map的中间结果都会spill到本地磁盘中,在map执行完后,造成
最终的spill文件。因此map端这里的数据就表示MapTask往本地磁盘
中共写了多少字节。与Map端相对应的是,reduce端在Shuffle时,会
不断拉取Map端的中间结果,而后作merge并不断spill到本身的本地
磁盘中。最终造成一个单独文件,这个文件就是reduce的输入文件。
FILE: Number of read operations=0 -----
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=3560544443952 -----job执行过程当中,累计写入HDFS的数据大小,整个job执行过程当中
,只有map端运行时,才会从HDFS读取数据,这些数据不限于源文件
内容,还包括全部map的split元数据。因此这个值应该比
FileInputFormatCounter.BYTES_READ要略大些。
HDFS: Number of bytes written=317076139 -----Reduce的最终结果都会写入HDFS,就是一个Job执行结果的总量。
HDFS: Number of read operations=70010
HDFS: Number of large read operations=0
HDFS: Number of write operations=4491
VIEWFS: Number of bytes read=0
VIEWFS: Number of bytes written=0
VIEWFS: Number of read operations=0
VIEWFS: Number of large read operations=0
VIEWFS: Number of write operations=0
Job Counters -----这个group描述与job调度相关的统计
Killed map tasks=4
Launched map tasks=13706 -----此job启动了多少个map task
Launched reduce tasks=500 -----此job启动了多少个reduce task
Data-local map tasks=13043 -----Job在被调度时,若是启动了一个data-local(源文件的副本在执行map task的TaskTracker本地)
Rack-local map tasks=663 ----- 处理的文件不在map task节点上
Total time spent by all maps in occupied slots (ms)=437335720 -----全部map task占用slot的总时间,包含执行时间和建立/销毁子JVM的时间
Total time spent by all reduces in occupied slots (ms)=83963148 -----
Total time spent by all map tasks (ms)=218667860
Total time spent by all reduce tasks (ms)=27987716
Total vcore-seconds taken by all map tasks=218667860
Total vcore-seconds taken by all reduce tasks=27987716
Total megabyte-seconds taken by all map tasks=557165707280
Total megabyte-seconds taken by all reduce tasks=128631542736
Map-Reduce Framework -----这个Countergroup包含了至关多的job执行细节数据。
这里须要有个概念认识是:通常状况下,record就表示一行数据,
而相对的byte表示这行数据的大小是多少,这里的group
表示通过reduce merge后像这样的输入形式{"aaa",[5,2,8,...]}
"Map input records=4486906030" -----全部MapTask从HDFS读取的文件总行数
Map output records=93940285 -----MapTask的直接输出record是多少,就是在map方法中调用
context.write的次数,也就是未通过Combine时的原生输出条数。
Map output bytes=5011599765 -----Map的输出结果key/value都会被序列化到内存缓冲区中,
因此这里的bytes指序列化后的最终字节之和。
Map output materialized bytes=3532812262 -----map 输出物化到磁盘的数据量,
也就是reduce shuffle的数据量
Input split bytes=2839207
"Combine input records=93940285" -----Combiner是为了尽可能减小须要拉取和移动的数据
"Combine output records=79274144" -----通过Combiner后,相同key的数据通过压缩,
在map端本身解决了不少重复数据,表示最终在map端中间
文件中的全部条目数
Reduce input groups=13757989 -----Reduce总共读取了多少个这样的groups,
等于reduce处理的key个数
"Reduce shuffle bytes=3532812262" -----Reduce端的copy线程总共从map端抓去了多少的中间数据
,表示各个MapTask最终的中间文件总和。
"Reduce input records=79274144" -----若是有Combiner的话,那么这里的数值就会等于Map端
Combiner运算后的最后条数,若是没有,那么就会等于Map的输出条数
Reduce output records=0 -----全部reduce执行后输出的总条目数
"Spilled Records=79274144" -----spill过程在map和reduce端都会发生,
这里统计的是总共从内存往磁盘中spill了多少条数据。
Shuffled Maps =6851000 -----每一个reduce几乎都得从全部Map端拉取数据,
每一个copy线程拉取成功一个map的数据,那么增1,
因此它的总数基本等于reduce number*(map number - fiald)
Failed Shuffles=0 -----copy线程在抓取map端中间数据时,
若是由于网络链接异常或是IO异常,所引发的Shuffle错误次数。
"Merged Map outputs=6851000" -----记录着Shuffle过程当中总共经历了多少次merge动做
"GC time elapsed (ms)=2890881"
CPU time spent (ms)=299372980 -----job运行使用的cpu时间,是衡量任务的计算量
总结:任务运行使用的CPU时间=counter:
"Map-Reduce Framework:CPU time spent (ms)"
Physical memory (bytes) snapshot=12848748335104 -----进程的当前物理内存使用大小
Virtual memory (bytes) snapshot=45156357689344 -----进程的当前虚拟内存使用大小
Total committed heap usage (bytes)=31420302491648 -----获取jvm的当前堆大小
SHUFFLECOUNTER
SHUFFLE_IDLE_TIME=21427585
SHUFFLE_TOTAL_TIME=25507722
HIVE
CREATED_FILES=1
Shuffle Errors -----这组内描述Shuffle过程当中的各类错误状况发生次数,
基本定位于Shuffle阶段copy线程抓取map端中间数据时的各类错误。
BAD_ID=0 -----每一个map都有一个ID,
如attempt_201109020150_0254_m_000000_0,
若是reduce的copy线程抓取过来的元数据中的这个ID不是标准格式,
那么此Counter会增长。
CONNECTION=0 -----表示copy线程创建到map端的链接有误。
IO_ERROR=0 -----Reduce的copy线程若是在抓取map端数据时出现IOException,
那么这个值会相应增长。
WRONG_LENGTH=0 -----map端的那个中间结果是有压缩好的有格式数据,
它有两个length信息:元数据大小和压缩后数据大小。
若是这两个length信息传输的有误,那么此Counter会增长。
WRONG_MAP=0 -----每一个copy线程固然是有目的的:为某个reduce抓取
某些map的中间结果,若是当前抓取的map数据不是copy
线程以前定义好的map,那么就表示把数据拉错了。
WRONG_REDUCE=0 -----与上述描述一致,若是抓取的数据表示它不是
为此reduce而准备的,那仍是拉错数据了。
DESERIALIZE_ERRORS=0
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=0
复制代码
io.sort.mb:100m
io.sort.spill.percent:80%
达到必定百分比,从后台进程对buffer进行排序,而后spill到磁盘。若是map的输出基本有序能够适当提升这个阈值。
io.sort.factor:10
min.num.spill.for.combine:3
当job中设定了combiner,而且spill数最少有3个的时候, 那么combiner函数就会在merge产生结果文件以前运行。减小写入到磁盘文件的数据数量,一样是为了减小对磁盘的读写频率,有可能达到优化做业的目的。
mapred.compress.map.output:false
那么map在写中间结果时,就会将数据压缩后再写入磁盘,读结果时也会采用先解压后读取数据。cpu换IO
mapred.map.output.compression.codec:org.apache.hadoop.io.compress.De faultCodec(GzipCodec,LzoCodec,BZip2Codec,LzmaCodec)
当采用map中间结果压缩的状况下,用户还能够选择压缩时采用哪一种压缩格式进行压缩
Map逻辑处理后数据被展开,写磁盘次数剧增,能够观察日志中的spill次数,调整各个参数
中间结果能不展开就不展开,尽可能缩小Mapper和reducer之间的数据传递
处理速度很慢时候首先要怀疑Mapper和Reducer之间传输数据量过大
观察GC的状况,有时候是由于内存占用量高,频繁GC,严重影响处理速
适当控制mapper的数量,特别是有distribute cache的场景
distribute cache
tasktracker.http.threads:
决定做为server端的map用于提供数据传输服务的线程数
复制代码
mapred.reduce.parallel.copies:
决定做为client端的reduce同时从map端拉取数据的并行度(一次同时从多少个map拉数据)
复制代码
hive 查询,字段没法进行单引号比较,如p8='2',没法查到数据
当某一字段数据全是纯数字字符串的时候,它会自动转成数字去作比较。
10位的时间戳值,即1970-1-1至今的秒,能够用from_unixtime()
转为时间,而13位的所谓毫秒的是不能够的;from_unixtime(cast(substring(t3.time ,1,10)as BIGINT), 'yyyyMMdd HH:mm:ss')
insert overwrite/into table 只会有mapjob,没有reducejob
增长reduce数目
设置reduce的文件大小
set hive.merge.size.per.task = 10000000; set hive.merge.mapfiles=false; set hive.groupby.skewindata=true;
desc tablename;
show partitions tablename;
修改表名
alter table oldname rename to newname;
增长列
alter table tablename add columns (c1 type, c3 type);
hive增长分区映射到文件
alter table tablename drop if exists partition(dt='20171130');
alter table tablename add if not exists partition(dt='20171130') location 'path';
修改表的分割字符
alter table tablename set SERDEPROPERTIES('field.delim'='\t');
修改字段顺序
alter table tablename change column cololdname colnewname coltype after colname2;
mapred.compress.map.output ##指定map的输出是否压缩。有助于减少数据量,减少io压力,但压缩和解压有cpu成本,须要慎重选择压缩算法。
mapred.map.output.compression.codec ##map输出的压缩算法
mapred.output.compress ##reduce输出是否压缩
mapred.output.compression.codec ##控制mapred的输出的压缩的方式
hive.exec.compress.intermediate=true; ##hive中间数据压缩
set hive.exec.compress.intermediate=true;
set mapred.map.output.compression.codec= org.apache.hadoop.io.compress.SnappyCodec set mapred.map.output.compression.codec=com.hadoop.compression.lzo.LzoCodec;
set hive.exec.compress.output=false;
set hive.exec.compress.output=true;
set mapred.output.compression.codec=org.apache.hadoop.io.compress.SnappyCodec;
set hive.merge.smallfiles.avgsize=256000000; ###设置输出文件的平均值
set mapred.min.split.size=1;
set mapred.max.split.size=256000000;
set mapred.reduce.tasks=100;--直接指定Reduce个数
set mapred.exec.reducers.bytes.per.reducer=1G;
set io.sort.mb;--增大Mapper输出buffer的大小,避免Spill的发生
set io.sort.factor;--一次性可以合并更多的数据
set sort mapred.reduce.slowstart.completed.maps=0.05;--Reduce端copy的进度
set mapred.reduce.parallel.copies;--能够决定做为client端的Reduce同时从Map端拉取数据的并行度
set hive.default.fileformat = SequenceFile;
set hive.exec.compress.output = true;
对于sequencefile,有record和block两种压缩方式可选,block压缩比更高
set mapred.output.compression.type = BLOCK;
set hive.hadoop.supports.splittable.combineinputformat=true;--小文件合并
set hive.exec.mode.local.auto;--自动开启local mr模式
set hive.exec.mode.local.auto.tasks.max;--文件数量
set hive.exec.mode.local.auto.inputbytes.max;--数据量大小
set mapred.job.reuse.jvm.num.tasks=5;--一个jvm运行屡次任务以后再退出
set hive.auto.convert.join = true;
Hive会自动判断当前的join操做是否合适作Map join
set hive.map.aggr=true;
set hive.groupby.skewindata;
Reduce操做的时候,拿到的key并非全部相同值给同一个Reduce,而是随机分发,而后Reduce作聚合,作完以后再作一轮MR,拿前面聚合过的数据再算结果
job 并行
set hive.exec.parallel = true; set hive.exec.parallel.thread.number;
减小Job数 group by 代替 join