linux查看磁盘使用率及清理
查看同一目录下其他目录的使用率
1 |
du -sh * |
清理文件(确保该文件不被使用,否则空间不释放)
1 2 3 |
#查看未释放文件的进程,并杀死 lsof | grep delete kill -9 pid |
1 |
du -sh * |
1 2 3 |
#查看未释放文件的进程,并杀死 lsof | grep delete kill -9 pid |
原文:http://www.cnblogs.com/itech/archive/2012/05/15/2502284.html
一、inode是什么?
使用ls -i命令,可以看到文件名对应的inode号码:
ln命令可以创建硬链接:
九 实际问题
在一台配置较低的Linux服务器(内存、硬盘比较小)的/data分区内创建文件时,系统提示磁盘空间不足,用df -h命令查看了一下磁盘使用情况,发现/data分区只使用了66%,还有12G的剩余空间,按理说不会出现这种问题。 后来用df -i查看了一下/data分区的索引节点(inode),发现已经用满(IUsed=100%),导致系统无法创建新目录和文件。
查找原因:
/data/cache目录中存在数量非常多的小字节缓存文件,占用的Block不多,但是占用了大量的inode。
解决方案:
1、删除/data/cache目录中的部分文件,释放出/data分区的一部分inode。
2、用软连接将空闲分区/opt中的newcache目录连接到/data/cache,使用/opt分区的inode来缓解/data分区inode不足的问题:
ln -s /opt/newcache /data/cache
1 |
yum install hbase-master |
1 2 3 |
[root@hadoop01 ~]# service hbase-master start starting master, logging to /var/log/hbase/hbase-hbase-master-hadoop01.out Started HBase master daemon (hbase-master):[ OK ] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
[root@hadoop01 ~]# yum install hbase-thrift Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile c6-http | 2.9 kB 00:00 cdh5.3.1 | 2.9 kB 00:00 cm5.3.1 | 2.9 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package hbase-thrift.x86_64 0:0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Installing: hbase-thrift x86_64 0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6 cdh5.3.1 5.2 k Transaction Summary ================================================================================================== Install 1 Package(s) Total download size: 5.2 k Installed size: 4.5 k Is this ok [y/N]: y Downloading Packages: hbase-thrift-0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6.x86_64.rpm | 5.2 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : hbase-thrift-0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6.x86_64 1/1 Verifying : hbase-thrift-0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6.x86_64 1/1 Installed: hbase-thrift.x86_64 0:0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6 Complete! |
1 2 3 |
[root@hadoop01 ~]# service hbase-thrift start starting thrift, logging to /var/log/hbase/hbase-hbase-thrift-hadoop01.out Started HBase thrift daemon (hbase-thrift):[ OK ] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
[root@hadoop01 ~]# yum install hbase-rest Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package hbase-rest.x86_64 0:0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================== Package Arch Version Repository Size ================================================================================================== Installing: hbase-rest x86_64 0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6 cdh5.3.1 4.7 k Transaction Summary ================================================================================================== Install 1 Package(s) Total download size: 4.7 k Installed size: 4.5 k Is this ok [y/N]: y Downloading Packages: hbase-rest-0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6.x86_64.rpm | 4.7 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : hbase-rest-0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6.x86_64 1/1 Verifying : hbase-rest-0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6.x86_64 1/1 Installed: hbase-rest.x86_64 0:0.98.6+cdh5.3.1+74-1.cdh5.3.1.p0.17.el6 Complete! |
修改hbase-site.xml
1 2 3 4 |
<property> <name>hbase.rest.port</name> <value>60050</value> </property> |
1 2 3 |
[root@hadoop01 ~]# service hbase-rest start starting rest, logging to /var/log/hbase/hbase-hbase-rest-hadoop01.out Started HBase rest daemon (hbase-rest):[ OK ] |
安装至此,即可单机享用HBase。
Node Name | Master | ZooKeeper | RegionServer |
---|---|---|---|
hadoop01 |
yes |
yes |
no |
hadoop02 |
backup |
yes |
yes |
hadoop03 |
no |
yes |
yes |
1 |
yum install hbase-master |
1 |
yum install hbase-regionserver |
编辑/etc/hbase/conf/regionservers,添加hadoop02、03.
1 2 3 4 |
[root@hadoop01 conf]# vim regionservers hadoop02 hadoop03 |
新增文件/etc/hbase/conf/backup-masters,添加一行hadoop02
1 2 3 |
[root@hadoop01 conf]# vim backup-masters hadoop02 |
编辑/etc/hbase/conf/hbase-site.xml
1 2 3 4 5 6 7 8 |
<property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.rootdir</name> <value>hdfs://hadoop01:8020/hbase</value> </property> |
在/etc/hbase/conf/hbase-site.xml添加参数
1 2 3 4 5 6 7 8 |
<property> <name>hbase.zookeeper.quorum</name> <value>hadoop01,hadoop02,hadoop03</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/var/lib/zookeeper</value> </property> |
其中dataDir参数参考本机的/etc/zookeeper/conf/zoo.cfg。
1 2 |
hdfs dfs -mkdir /hbase hdfs dfs -chown hbase /hbase |
1 2 3 4 5 6 7 8 |
[root@hadoop01 conf]# scp backup-masters hbase-site.xml regionservers hadoop02:/etc/hbase/conf backup-masters 100% 9 0.0KB/s 00:00 hbase-site.xml 100% 3291 3.2KB/s 00:00 regionservers 100% 52 0.1KB/s 00:00 [root@hadoop01 conf]# scp backup-masters hbase-site.xml regionservers hadoop03:/etc/hbase/conf backup-masters 100% 9 0.0KB/s 00:00 hbase-site.xml 100% 3291 3.2KB/s 00:00 regionservers 100% 52 0.1KB/s 00:00 |
1 |
service hbase-master start |
1 |
service hbase-regionserver start |
在各服务器执行:jps
hadoop01:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@hadoop01 ~]# jps 2917 ResourceManager 9145 NameNode 2773 NodeManager 2349 32369 Jps <strong>32138 HMaster</strong> 2139 JournalNode 3333 RunJar 4114 Worker 3867 Master 3511 RunJar 2667 JobHistoryServer 2604 Bootstrap <strong>1992 QuorumPeerMain</strong> 8950 DataNode |
hadoop02:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@hadoop02 ~]# jps 7365 -- process information unavailable 4764 Jps 3387 Worker 16481 -- process information unavailable 2537 NodeManager <strong>4450 HMaster</strong> 3140 Master <strong>1799 QuorumPeerMain</strong> 7511 DataNode 2171 2379 Bootstrap 1960 JournalNode <strong>4618 HRegionServer</strong> |
hadoop03:
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@hadoop03 ~]# jps 3316 Worker 5521 DataNode 2749 RunJar 2477 NodeManager 18027 Jps <strong>17887 HRegionServer</strong> 2199 1979 JournalNode <strong>1837 QuorumPeerMain</strong> 2417 Bootstrap 3070 Master |
单机模式安装、启动 HBase:http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/cdh_ig_hbase_standalone_start.html
HBase分布式安装配置:http://hbase.apache.org/book.html#_introduction
HBase分布式安装配置(伪分布式):
http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/cdh_ig_hbase_pseudo_configure.html
HBase分布式安装配置(伪分布式->集群):
http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/cdh_ig_hbase_cluster_deploy.html
原文:(安装)http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/cdh_ig_hbase_install.html
(BlockCache)http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/admin_hbase_blockcache_configure.html
1 |
[root@hadoop01 conf]# yum install hbase |
HDFS datanode有最大伺服文件数限制。该上限由dfs.datanode.max.transfer.threads参数控制。在加载HBase之前,确认已经在$HADOOP_HOME/conf/hdfs-site.xml文件中配置了该参数:
1 2 3 4 |
<property> <name>dfs.datanode.max.transfer.threads</name> <value>4096</value> </property> |
将配置文件发送到集群,并重启HDFS以生效。
否则会报与block相关的奇怪错误。
扩展阅读:
堆内存与堆外内存:http://bananalighter.com/java-off-heap-on-heap/
块缓存1:http://www.cnblogs.com/panfeng412/archive/2012/09/24/hbase-block-cache-mechanism.html
块缓存2:http://punishzhou.iteye.com/blog/1277141
HBase提供了堆内存及堆外内存两种块缓存的实现。
堆内存:默认的堆内存块缓存实现是LruBlockCache(java)。桶缓存可以用堆内存,也可以用堆外内存。
结合:如果操作的数据超出堆容量,可以使用桶缓存作为堆内存LruBlockCache的二级缓存(L2 cache)。这个实现在CombinedBlockCache中有涉及。
原文:http://www.infoq.com/cn/news/2014/12/external-memory-heap-memory/
一般情况下,Java中分配的非空对象都是由Java虚拟机的垃圾收集器管理的,也称为堆内内存(on-heap memory)。虚拟机会定期对垃圾内存进行回收,在某些特定的时间点,它会进行一次彻底的回收(full gc)。彻底回收时,垃圾收集器会对所有分配的堆内内存进行完整的扫描,这意味着一个重要的事实——这样一次垃圾收集对Java应用造成的影响,跟堆的大小是成正比的。过大的堆会影响Java应用的性能。
对于这个问题,一种解决方案就是使用堆外内存(off-heap memory)。堆外内存意味着把内存对象分配在Java虚拟机的堆以外的内存,这些内存直接受操作系统管理(而不是虚拟机)。这样做的结果就是能保持一个较小的堆,以减少垃圾收集对应用的影响。
但是Java本身也在不断对堆内内存的实现方式做改进。两者各有什么优缺点?Vanilla Java博客作者Peter Lawrey撰写了一篇文章,在文中他对三种方式:用new来分配对象、对象池(object pool)和堆外内存,进行了详细的分析。
用new来分配对象内存是最基本的一种方式,Lawery提到:
在Java 5.0之前,分配对象的代价很大,以至于大家都使用内存池。但是从5.0开始,对象分配和垃圾回收变得快多了,研发人员发现了性能的提升,纷纷简化他们的代码,不再使用内存池,而直接用new来分配对象。从5.0开始,只有一些分配代价较大的对象,比如线程、套接字和数据库链接,用内存池才会有明显的性能提升。
对于内存池,Lawery认为它主要用于两类对象。第一类是生命周期较短,且结构简单的对象,在内存池中重复利用这些对象能增加CPU缓存的命中率,从而提高性能。第二种情况是加载含有大量重复对象的大片数据,此时使用内存池能减少垃圾回收的时间。对此,Lawery还以StringInterner为例进行了说明。
最后Lawery分析了堆外内存,它和内存池一样,也能缩短垃圾回收时间,但是它适用的对象和内存池完全相反。内存池往往适用于生命期较短的可变对象,而生命期中等或较长的对象,正是堆外内存要解决的。堆外内存有以下特点:
Lawery还提到对外内存最重要的还不是它能改进性能,而是它的确定性。
当然堆外内存也有它自己的问题,最大的问题就是你的数据结构变得不那么直观,如果数据结构比较复杂,就要对它进行串行化(serialization),而串行化本身也会影响性能。另一个问题是由于你可以使用更大的内存,你可能开始担心虚拟内存(即硬盘)的速度对你的影响了。
Lawery还介绍了OpenHFT公司提供三个开源库:Chronicle Queue、Chronicle Map和Thread Affinity,这些库可以帮助开发人员使用堆外内存来保存数据。采用堆外内存有很多好处,同时也带来挑战,对堆外内存感兴趣的读者可以阅读Lawery的原文来了解更多信息。
1 2 3 |
[root@hadoop01 ~]# locale -a | grep 18030 zh_CN.gb18030 [root@hadoop01 ~]# |
1 2 3 4 |
[root@hadoop01 ~]# vim /etc/sysconfig/i18n LANG="en_US.UTF-8" SYSFONT="latarcyrheb-sun16" |
1 2 |
LANG="zh_CN.gb18030" SYSFONT="latarcyrheb-sun16" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@hadoop01 ~]# locale LANG=zh_CN.gb18030 LC_CTYPE="zh_CN.gb18030" LC_NUMERIC="zh_CN.gb18030" LC_TIME="zh_CN.gb18030" LC_COLLATE="zh_CN.gb18030" LC_MONETARY="zh_CN.gb18030" LC_MESSAGES="zh_CN.gb18030" LC_PAPER="zh_CN.gb18030" LC_NAME="zh_CN.gb18030" LC_ADDRESS="zh_CN.gb18030" LC_TELEPHONE="zh_CN.gb18030" LC_MEASUREMENT="zh_CN.gb18030" LC_IDENTIFICATION="zh_CN.gb18030" LC_ALL= |
参考:http://linux.vbird.org/linux_server/0210network-secure.php#portlimit
1 2 3 4 5 |
[root@hadoop01 ~]# netstat -tunl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:10033 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:4242 0.0.0.0:* LISTEN |
加了-l则将输出端口筛选掉了。
以下命令行输出均应为IP,这里全部替换为主机名。
1 2 3 4 5 |
[root@hadoop01 ~]# netstat -tun Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 hadoop01:41906 hadoop01:8020 TIME_WAIT tcp 0 0 hadoop01:59464 hadoop01:2181 ESTABLISHED |
从hadoop02机器ssh到hadoop01,观察hadoop01机器上的端口变化。
1 2 3 4 |
[root@hadoop02 ~]# ssh hadoop01 Last login: Wed Apr 1 14:00:09 2015 from 10.62.250.103 Authorized users only.All activities will be monitored and reported. [root@hadoop01 ~]# |
1 2 3 4 |
[root@hadoop01 ~]# netstat -tunp Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name <strong>tcp 0 0 hadoop01:22 hadoop02:34751 ESTABLISHED 6591/sshd</strong> |
1 2 3 4 5 |
[root@hadoop01 ~]# netstat -tunp | grep sshd tcp 0 0 hadoop01:22 hadoop02:34751 ESTABLISHED 6591/sshd [root@hadoop01 ~]# kill -9 6591 [root@hadoop01 ~]# netstat -tunp | grep sshd [root@hadoop01 ~]# |
查看登录机器的提示
1 2 3 |
[root@hadoop01 ~]# Connection to hadoop01 closed by remote host. Connection to hadoop01 closed. [root@hadoop02 ~]# |
直接引用鸟哥的用法文档:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@www ~]# nmap [掃瞄類型] [掃瞄參數] [hosts 位址與範圍] 選項與參數: [掃瞄類型]:主要的掃瞄類型有底下幾種: -sT:掃瞄 TCP 封包已建立的連線 connect() ! -sS:掃瞄 TCP 封包帶有 SYN 標籤的資料 -sP:以 ping 的方式進行掃瞄 -sU:以 UDP 的封包格式進行掃瞄 -sO:以 IP 的協定 (protocol) 進行主機的掃瞄 [掃瞄參數]:主要的掃瞄參數有幾種: -PT:使用 TCP 裡頭的 ping 的方式來進行掃瞄,可以獲知目前有幾部電腦存活(較常用) -PI:使用實際的 ping (帶有 ICMP 封包的) 來進行掃瞄 -p :這個是 port range ,例如 1024-, 80-1023, 30000-60000 等等的使用方式 [Hosts 位址與範圍]:這個有趣多了,有幾種類似的類型 192.168.1.100 :直接寫入 HOST IP 而已,僅檢查一部; 192.168.1.0/24 :為 C Class 的型態, 192.168.*.* :嘿嘿!則變為 B Class 的型態了!掃瞄的範圍變廣了! 192.168.1.0-50,60-100,103,200 :這種是變形的主機範圍啦!很好用吧! |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@hadoop01 ~]# nmap hadoop02 Starting Nmap 5.51 ( http://nmap.org ) at 2015-04-01 14:53 CST Nmap scan report for hadoop02 (10.62.228.212) Host is up (0.00025s latency). Not shown: 993 closed ports PORT STATE SERVICE 22/tcp open ssh 111/tcp open rpcbind 2049/tcp open nfs 4242/tcp open vrml-multi-use 8042/tcp open fs-agent 14000/tcp open scotty-ft 60020/tcp open unknown MAC Address: 00:50:56:89:65:62 (VMware) Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@hadoop01 ~]# nmap -sTU localhost Starting Nmap 5.51 ( http://nmap.org ) at 2015-04-02 09:25 CST Nmap scan report for localhost (127.0.0.1) Host is up (0.00035s latency). Not shown: 1988 closed ports PORT STATE SERVICE 22/tcp open ssh 111/tcp open rpcbind 631/tcp open ipp 2049/tcp open nfs 3306/tcp open mysql 4242/tcp open vrml-multi-use 8042/tcp open fs-agent 8888/tcp open sun-answerbook 10000/tcp open snet-sensor-mgmt 14000/tcp open scotty-ft 111/udp open rpcbind 631/udp open|filtered ipp Nmap done: 1 IP address (1 host up) scanned in 1.33 seconds |
本处隐去了原始IP,用192.168.1.*示意。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
[root@hadoop01 ~]# nmap -sP 192.168.1.1/24 Starting Nmap 5.51 ( http://nmap.org ) at 2015-04-02 09:26 CST Nmap scan report for 192.168.1.200 Host is up (0.00094s latency). MAC Address: 00:50:56:89:50:91 (VMware) Nmap scan report for 192.168.1.201 Host is up (0.00064s latency). MAC Address: 00:50:56:89:08:64 (VMware) Nmap scan report for 192.168.1.202 Host is up (0.00093s latency). MAC Address: 00:50:56:89:50:91 (VMware) Nmap scan report for 192.168.1.203 Host is up (0.00093s latency). MAC Address: 00:50:56:89:3E:57 (VMware) Nmap scan report for 192.168.1.204 Host is up (0.00093s latency). MAC Address: 00:50:56:89:2B:BA (VMware) Nmap scan report for 192.168.1.205 Host is up (0.00052s latency). MAC Address: 00:50:56:89:6B:10 (VMware) Nmap scan report for 192.168.1.206 Host is up (0.00088s latency). MAC Address: 00:50:56:89:24:AC (VMware) Nmap scan report for 192.168.1.208 Host is up (0.00046s latency). MAC Address: 00:50:56:89:68:1B (VMware) Nmap scan report for hadoop01 (192.168.1.211) Host is up. Nmap scan report for hadoop02 (192.168.1.212) Host is up (0.00072s latency). MAC Address: 00:50:56:89:65:62 (VMware) Nmap scan report for hadoop03 (192.168.1.213) Host is up (0.0011s latency). MAC Address: 00:50:56:89:05:C9 (VMware) Nmap scan report for 192.168.1.250 Host is up (0.0014s latency). MAC Address: 74:8E:F8:CA:2A:40 (Brocade Communications Systems) Nmap scan report for 192.168.1.251 Host is up (0.0014s latency). MAC Address: 74:8E:F8:CA:2A:00 (Brocade Communications Systems) Nmap scan report for 192.168.1.252 Host is up (0.093s latency). MAC Address: 90:17:AC:BF:F2:B5 (Unknown) Nmap scan report for 192.168.1.253 Host is up (0.045s latency). MAC Address: 90:17:AC:BF:F2:A1 (Unknown) Nmap scan report for 192.168.1.254 Host is up (0.049s latency). MAC Address: 00:00:5E:00:01:1C (USC Information Sciences Inst) Nmap done: 256 IP addresses (16 hosts up) scanned in 32.64 seconds |