linux磁盘满时,如何定位并删除文件

@1.一般情况
一般情况下先df看一下,然后cd到要满的盘,执行:
du -shx *
这样可以列出所有文件夹的大小(x参数会去除掉mount上去的目录,如samba挂上去的盘,这会干扰统计的)
进去如果有子文件夹,那就继续执行du -shx * 一级一级地找
@2.特殊情况(有文件被删除,却被某进程占用,并且还在写)
这种情况的表现是,用1中的方法无法找到占用磁盘的文件,而且du -shx整个盘得到的结果和df的结果差别很大,那肯定是有文件被删除,但被进程占用,而且还在写。这样的被删除文件仍然会占用磁盘,被写入时,空间自然下降了,这种情况用前面的方法是无法找到文件的。
方法:
lsof | grep deleted
这样就可以找到被删除的却还被进程占用的文件了,进程也被列出,把相关的进程重启一遍,空间就被释放了。

Sublime text 3 3103 注册码

Sublime text 3 (Build 3103) license key,these all tested available on 2016/02/10 .Feel free to enjoy them. :idea:

Sublime text 3 (Build 3103) license key

—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
B085E65E 2F5F5360 8489D422 FB8FC1AA
93F6323C FD7F7544 3F39C318 D95E6480
FCCC7561 8A4A1741 68FA4223 ADCEDE07
200C25BE DBBC4855 C4CFB774 C5EC138C
0FEC1CEF D9DCECEC D3A5DAD1 01316C36
—— END LICENSE ——
—– BEGIN LICENSE —–
Nicolas Hennion
Single User License
EA7E-866075
8A01AA83 1D668D24 4484AEBC 3B04512C
827B0DE5 69E9B07A A39ACCC0 F95F5410
729D5639 4C37CECB B2522FB3 8D37FDC1
72899363 BBA441AC A5F47F08 6CD3B3FE
CEFB3783 B2E1BA96 71AAF7B4 AFB61B1D
0CC513E7 52FF2333 9F726D2C CDE53B4A
810C0D4F E1F419A3 CDA0832B 8440565A
35BF00F6 4CA9F869 ED10E245 469C233E
—— END LICENSE ——
—– BEGIN LICENSE —–
Anthony Sansone
Single User License
EA7E-878563
28B9A648 42B99D8A F2E3E9E0 16DE076E
E218B3DC F3606379 C33C1526 E8B58964
B2CB3F63 BDF901BE D31424D2 082891B5
F7058694 55FA46D8 EFC11878 0868F093
B17CAFE7 63A78881 86B78E38 0F146238
BAE22DBB D4EC71A1 0EC2E701 C7F9C648
5CF29CA3 1CB14285 19A46991 E9A98676
14FD4777 2D8A0AB6 A444EE0D CA009B54
—— END LICENSE ——
—– BEGIN LICENSE —–
Alexey Plutalov
Single User License
EA7E-860776
3DC19CC1 134CDF23 504DC871 2DE5CE55
585DC8A6 253BB0D9 637C87A2 D8D0BA85
AAE574AD BA7D6DA9 2B9773F2 324C5DEF
17830A4E FBCF9D1D 182406E9 F883EA87
E585BBA1 2538C270 E2E857C2 194283CA
7234FF9E D0392F93 1D16E021 F1914917
63909E12 203C0169 3F08FFC8 86D06EA8
73DDAEF0 AC559F30 A6A67947 B60104C6
—— END LICENSE ——

Please support authorized software if you can. :razz:

Download software

Redis安装报错

最近有需求要折腾redis, 记录下过程中遇到的坑

错误描述

安装Redis 时报错:

zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error “Newer version of jemalloc required”
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src’
make: *** [all] Error 2

原因分析

在README 有这个一段话。

Allocator
———

Selecting a non-default memory allocator when building Redis is done by setting
the `MALLOC` environment variable. Redis is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

说关于分配器allocator, 如果有MALLOC 这个 环境变量, 会有用这个环境变量的 去建立Redis。

而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。

但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数。

解决办法

make MALLOC=libc

关于wordpress的升级

一直觉得wordpress升级比较恶心,为毛非得搞个ftp呢..

今天抽空研究了下,ftp多半跟跟权限有关

在 wp-config.php 添加如下配置

define(“FS_METHOD”, “direct”);
define(“FS_CHMOD_DIR”, 0777);
define(“FS_CHMOD_FILE”, 0777);

还不妥… 在查下  目录权限不对

[备忘]Beyond Compare 4 最新中文版 注册码 key

Current Version:  4.0.3, build 19420, released Jan. 6, 2015

简体中文官方版本下载地址(截止到2015-03 这个地址已经被官方更新,请大家自行搜索其他地方进行下载,版本号为 4.0.2.19186。 谢谢@最后的智慧)

WIN: http://xiazai.beyondcompare.cc/wm/Beyond_Compare-Trial-WM.exe
MAC: http://xiazai.beyondcompare.cc/wm/Beyond_Compare-Mac-Trial.zip

注册码

===请购买正版===

更新日志

Beyond Compare 4 Change Log

4.0.3.19420 - JANUARY 6, 2015
Notable Changes
OS X: Fixed code signature failure on OS X 10.9 and 10.10.
Bug fixes and polish.
Archives
Linux: Added support for symlinks in .rpm archives.
Linux: Fixed support for .rpm archives containing files with spaces in their names.
Linux: Improved error message when rpm isn't installed.
OS X/Linux: Fixed support for archive files on smb:// servers.
Windows: Improved error message when unable to load a 7-zip provided archive format.
Windows: Tweaked descriptions of some 7-zip provided archive formats.
Windows: Fixed support for uncompressed Shockwave Flash files (.swf) and added support for zlib compressed ones.
File Views
OS X/Linux: Fixed editing files on SMB servers using the smb:// path syntax.
Added accelerators to popup menu commands.
Fixed File Info panel text clipping.
Folder Compare
Improved speed when opening Compare Contents results dialog.
Actions menu is no longer hidden while in "Align with..." mode.
Folder Sync
Fixed swapping overridden sync actions.
FTP
Fixed support for connecting to FTP servers that disconnect in response to a HOST command.
Hex Compare
Fixed "Go to next difference in files after copying to other side".
Home View
Added "Edit Defaults" button when the session editing panel is hidden and a new session type is selected in the treeview.
Improved visibility handling of the session edit panel.
HTTP
Fixed support for HTTP comparisons of SOAP services that don't accept HEAD requests.
Misc
OS X: Fixed code signature failure on OS X 10.9 and 10.10.
OS X: Fixed failure to write log file when set to continuously do so.
OS X: Fixed some files in the Beyond Compare.app bundle being stored as duplicates rather than symbolic links.
Improved position and sizing of floating in-line edits in folder compare and table compare.
Session Settings dialog's "Scope" combobox is now aligned vertically with the Ok/Cancel buttons.
Options
Fixed File Views Gutter Font swatch clipping.
Picture Compare
Increased max zoom to 2000%.
Tweaked drawing of selected pixel in the details grid.
Settings
Installing BC4 into a BC3 portable folder now moves BC3 settings into a subfolder and offers to import them.
Fixed importing settings from some older releases.
Subversion
Windows: SSL connections will now trust self-signed and expired certificates instead of being unable to connect.
Text Compare
Edit menu is no longer hidden while in "Align with..." mode.
Fixed Text Replacement handling of right-sided difference.
Crashes
Fixed crash when performing a Quick Compare with an External Format.
Fixed crash when using the FTP Quick Connect "Connect & Browse" button when the "Host" edit is empty.
Fixed Text Merge crash when changing "Merge to" changes detected file format.
OS X: Fixed crash when showing Hex Compare find frame.

关于iptables

最近在加访问策略,新问题老问题一起来了,顺便整理一下iptables

只允许指定的ip访问本机的指定端口6379(redis):

切换到root用户

1、在tcp协议中,禁止所有的ip访问本机的6379端口。(是 – -drop 哦)

iptables -I INPUT -p tcp –dport 6379 -j DROP

2、允许本机访问本机的6379端口

iptables -I INPUT -s 127.0.0.1 -p tcp –dport 6379 -j ACCEPT

3、 保存

service iptables save / 没有配service 的 执行 iptables-save

4、重启防火墙(没有配service的忽略吧)

service iptables restart

好了,上述步骤很简单,但有台服务器/etc/init.d/iptables 居然是文件夹

关于gitlab升级

gitlab,基于git的版本管理工具,优势在于集成了方便强大的web界面,可以清晰明了的查看版本代码,方便管理。

gitlab基于ruby on rails,代码开源,nginx和unicron 的无缝配合使得我们可以很放心的使用。需要的扩展包比较多,又用了rails的sidkiq队列,使得这货十分吃内存,我买了2G的阿里云做服务器,经常被吃掉1.7~1.8G。由于用gitlab框架开发了无数款web应用,对源码比较熟悉,里面的数据库依赖关系和sidkiq的worker的异步队列就是罪魁祸首,为了保证系统的稳定性,没有对源码进行修改,只是写了个python脚本,一个小时重启一次gitlab,当然,你也可以增加一个crontab,一条指令就搞定了:

sudo gitlab-ctl restart

好了,回到主题,今天的主题是升级,本人之前装的是7.3版本的gitlab,眼下都7.10了,咱也得赶赶时髦的侧边栏嘛。。百度搜索了一下,各种五花八门的升级好蛋疼,算了,还是老老实实看官方文档吧。

其实gitlab经过多年的迭代,已经封装的很好了,升级也很方便,步骤是这样的

1. 备份数据库(防止升级中的意外)

sudo gitlab-rake gitlab:backup:create

2.  停止gitlab服务

sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx
# 当然你也可以
sudo gitlab-ctl stop

3. 下载新版本的安装包

https://packages.gitlab.com/gitlab/gitlab-ce

4.  安装新版本

# Ubuntu/Debian:
sudo dpkg -i gitlab_x.x.x-omnibus.xxx.deb

# CentOS:
sudo rpm -Uvh gitlab-x.x.x_xxx.rpm

5. 启动 gitlab

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

6. 检查是否正常启动

sudo gitlab-ctl status
sudo gitlab-rake gitlab:check SANITIZE=true

搞定,是不是有种 so easy的感觉?

对了,这里顺便提下,如果重启发现版本丢失,可先去 /etc/gitlab/gitlab.rb 查看下你的数据备份到哪了,然后执行

sudo gitlab-rake gitlab:backup:restore BACKUP=12345 # where 12345 is your backup timestamp

恢复数据库即可。


 

 

补充下直接从7.11升级到8.20的那些坑….

gitlab更新速度是如此之快啊如此之快… 闲不下来的我手贱又开始升级了, 对, 就是手贱。

按照上述步骤升级, 开始怎么也下不下来版本, 没办法, 阿里云就是这个得行。最后无奈本地下载,scp

传到aliyun。

按照正常步骤安装,结束后发现怎么也起不来服务器。

首先看看nginx error.log

2015/11/25 17:08:15 [error] 3793#0: *619 connect() failed (111: Connection refused) while connecting to upstream, client: 14.17.22.52, server: git.olightgrain.com, request: "GET / HTTP/1.1", upstream: "http://115.28.15.213:9090/", host: "git.olightgrain.com"

正常的返回500, 好, 接着看看rails的错误log。

gitlab默认使用的是 unicorn

/opt/gitlab/embedded/service/gitlab-rails/config/initializers/session_store.rb:19:in `<top (required)>': undefined method `*' for nil:NilClass (NoMethodError)
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:241:in `load'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:241:in `block in load'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:232:in `load_dependency'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:241:in `load'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/engine.rb:648:in `block in load_config_initializer'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/activesupport-4.1.12/lib/active_support/notifications.rb:161:in `instrument'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/engine.rb:647:in `load_config_initializer'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/engine.rb:611:in `each'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/engine.rb:611:in `block in <class:Engine>'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:30:in `instance_exec'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:30:in `run'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:55:in `block in run_initializers'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:44:in `each'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:44:in `tsort_each_child'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:411:in `call'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:345:in `each'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:345:in `call'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
 from /opt/gitlab/embedded/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:54:in `run_initializers'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/application.rb:300:in `initialize!'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/railtie.rb:194:in `public_send'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/railties-4.1.12/lib/rails/railtie.rb:194:in `method_missing'
 from /opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:5:in `<top (required)>'
 from /opt/gitlab/embedded/service/gitlab-rails/config.ru:16:in `require'
 from /opt/gitlab/embedded/service/gitlab-rails/config.ru:16:in `block in <main>'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
 from /opt/gitlab/embedded/service/gitlab-rails/config.ru:1:in `new'

好 抓到你了, 接下来看看  /opt/gitlab/embedded/service/gitlab-rails/config/initializers/session_store.rb 里面是什么鬼….

1

尼玛完全没有兼容嘛 旧版本没有session_expire_delay, 看来gitlab兼容性由此可见。搜了半天没发现先关案例,gitlab也没有对这个问题进行改进?难道就我一个踩坑的?!

好吧 既然这样 我们只能改了他了

加上兼容吧..

2

改之,重启,又可以愉快的gitlab了。

对了 发现一件事,哥是4G内存的阿里云啊,尼玛gitlab新版越来越过分,居然吃掉了3G!

小内存的朋友们还是放弃体验新版吧。有空必须狠心优化下,看看到底是什么在耗内存,到时候再回来更新。