寻觅生命中的那一片浅草......

每月存档 九月, 2015

Time Machine Backup频繁创建新备份的问题

Time Machine Backup用起来比较方便,每个小时进行备份,文档、代码,再也不用频繁地提交到仓库。

但从使用至今,一直困扰我的是每隔一个月就要来一次新备份,说句实话,200G+的东西,完整备份要6-7个小时,真心伤不起,本来以为是为了安全,每月创建一个新备份,也就忍了,但最近更却每周就要来一次全新备份,实在无法忍受,前几天搜索到一篇文章,今天又要遇到这个问题,警告提示:

Time Machine 已完成备份验证。要提高可靠性,Time Machine 必须为您创建新的备份。

总结下来,所有的指令如下,所有指令都是用普通用户运行,10.10.5测试通过:

chflags -R nouchg /Volumes/{name of your network share}/{name of}.sparsebundle
hdiutil attach -nomount -noverify -noautofsck /Volumes/{name of your network share/{name of}.sparsebundle

上面的指令输入如下,我们需要Apple_HFSX前面的分区号,需要修改diskxs2中的x为对应的数字:

/dev/diskx Apple_partition_scheme
/dev/diskxs1 Apple_partition_map
/dev/diskxs2 Apple_HFSX

开始修复,这里大概需要1个小时

fsck_hfs -drfy /dev/diskxs2

卸载备份

hdiutil detach /dev/diskxs2     

最后,告诉TMB,备份已经修复了

vi /Volumes/{name of your network share/{name of}.sparsebundle/com.apple.TimeMachine.MachineID.plist

删除

<key>RecoveryBackupDeclinedDate</key>
<date>{whatever-the-date}</date>

修改

# 将
<key>VerificationState</key>
<integer>2</integer>
# 修改为
<key>VerificationState</key>
<integer>0</integer>

对了,我用的是穷人家的备份服务器:Western Digital Cloud,可能频繁要重新备份,是这个引起

参考文章:Fix Time Machine Sparsebundle NAS Based Backup Errors

通过浏览器管理多台Android设备

相关介绍

软件安装

基础环境

zypper -n in make gcc gcc-c++ protobuf-devel ncurses-devel \
           jemalloc-devel boost-devel tar wget m4 which \
           openssl-devel libcurl-devel automake autoconf \
           libtool libicu-devel git libsodium-devel

node-v4.1.0-linux-x64

直接下载二进制文件

# 安装
tar xf /dist/dist/stf/node-v4.1.0-linux-x64.tar.gz
mv node-v4.1.0 node
ln -s /usr/local/node/bin/* /usr/bin/

android-sdk_r24.3.4-linux

现在的sdk包已经不包含adb这个命令,需要额外安装

# 下载链接
wget http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz
# 软件包解压缩到/usr/local
# 列出所有sdk
./android list sdk --all
# 安装指定版本的sdk,其中2,3位上面指令输出的sdk编码
./android update sdk -u -a -t 2,3

protobuf_v2.5.0

先git下来,再切换到tags为v2.5.0的版本, 这里好像会依赖于gtest,这文件在墙外,如果不具备翻墙环境,会比较麻烦

git clone https://github.com/google/protobuf.git
cd protobuf
git checkout v2.5.0
./configure && make && make install

rethinkdb-2.1.4

tar xf rethinkdb-2.1.4.tgz
cd rethinkdb-2.1.4
./configure -dymanic jemalloc —prefix=/usr/local/rethinkdb
make && make install
mkdir -p /etc/rethinkdb/instances.d/
/bin/cp packaging/assets/config/default.conf.sample /etc/rethinkdb/
/bin/cp packaging/assets/config/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
sed -i 's/# bind=127.0.0.1/bind=127.0.0.1/' /etc/rethinkdb/instances.d/instance1.conf
chown -R rethinkdb.rethinkdb /var/run/rethinkdb
ln -s /usr/local/rethinkdb/bin/rethinkdb /usr/bin/

GraphicsMagick-1.3.21

tar xf GraphicsMagick-1.3.21.tar.gz
cd GraphicsMagick-1.3.21
./configure && make && make install

zeromq-4.1.3

tar xf zeromq-4.1.3.tar.gz
cd zeromq-4.1.3
./configure && make && make install

stf安装

看起来很简单,但好像会依赖大量第三方包,而我们的墙。。。

npm install -g stf

其他辅助

/etc/init.d/rethinkdb

见链接

rethinkdb

进程管理:supervisor

安装

pip install supervisor

/etc/init.d/supervisord

见链接

opensuse-garymonson

supervisord.conf

[unix_http_server]
file=/tmp/supervisor.sock

[supervisord]
logfile=/data/logs/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=info                ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=65535                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[program:stf]
command = /usr/bin/stf local --public-ip 192.168.xx.xx 
numprocs = 1
autostart = true
autorestart = true
redirect_stderr = true
stdout_logfile=/data/logs/stf.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=5
stdout_capture_maxbytes=10MB
stderr_logfile=/data/logs/stf_error.log
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=5
stderr_capture_maxbytes=10MB

CentOS:当双网卡遇上双网段

如题,这种情况,通常是作为网关,但本例并不是作为网关,而是局域网中的 一台机器,需要连接2个网段,CentOS上的默认设置只能有一个网段通讯,解决办法是设置rp_filter这个内核参数,对于排查这种问题比较有用的内核参数是log_martians,具体方法请参考下面的地址:

Linux rp_filter 配置

在实际设置过程中,把rp_filter从2设置为1时,需要等一段时间后,eth1才会显示不通,比较奇怪

BTW,rp_filter这个参数是在《深度实践KVM》中看到的,很赞的一本书。

WordPress更新设置

今天更新,老提示输入ftp连接信息,实在不想开ftp,于是搜索了些资料,记录如下

一、确保Nginx和PHP-FPM用同一个用户运行
本例中是nginx用户

grep user /etc/nginx/nginx.conf
egrep 'user|group' /etc/php-fpm.d/www.conf

二、设置WordPress为nginx用户所有

chown -R nginx.nginx /data/web/wp

三、修改WordPress配置

vi wp-config.php
define('FS_METHOD', 'direct');

现在去后台更新,就不会提示输入ftp信息了。

Using flock() in Bash without invoking a subshell

我们目前利用了flock来限制并发,通常是用一个小括号把需要执行的代码包含起来,这样就会产生一个子shell,带来的问题是父shell无法获得子shell的返回值,昨天刚好Google到这个文章,在这里贴下。

#!/bin/bash

(
flock -s 200

# … commands executed under lock …

) 200>/var/lock/mylockfile
Unfortunately, this invokes a subshell which has the following drawbacks:

You cannot pass values to variables from the subshell in the main shell script.
There is a performance penalty.
The syntax coloring in “vim” does not work properly. :)
This motivated my colleague zImage to come up with a usage form which does not invoke a subshell in Bash:

#!/bin/bash

exec 200>/var/lock/mylockfile || exit 1
flock -n 200 || { echo “ERROR: flock() failed.” >&2; exit 1; }

# … commands executed under lock …

flock -u 200

原文见:Using flock() in Bash without invoking a subshell

2015年九月
« 8月   10月 »
 123456
78910111213
14151617181920
21222324252627
282930