rsync服务的安装和使用

服务器端配置:
# yum -y install xinetd

# vi /etc/xinetd.d/rsync
将如下代码

service rsync
{
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = –daemon
log_on_failure += USERID
}
中的 disable = yes 改成 disable = no

然后启动 xinetd
# /etc/init.d/xinetd start 或 service xinetd restart
注意:如果服务器上装有防火墙记得要打开端口,默认端口是873

# vi /etc/rsyncd.conf
[download]
path=/data/download
read only=yes
uid=nobody
gid=nobody
hosts allow=*

rsync同步发送给目标服务:

rsync -vzrtopg –progress –delete /test/aaa rsync://192.168.1.1:873/data/test

其中 data 是 目标机器 rsync 服务的模块

其他不想关的命令:

查看分隔符文件指定列的值(列编号从1开始):

awk -F ^A ‘{if ($2!=0 && $3==81065 && $5==207817) print }’ xxxx.log.20140828* | wc -l

其中的 ^A 是 unicode \u0001 ,可使用 ctrl + v + a 打出来。

tcp 抓包:

tcpdump -Avvnns 0 -i any ‘host xxx.com and (((ip[2:2] – ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)’

命令返回和域名 xxx.com 交互的 tcp 数据包

redis安装和sentinel集群模式

install:

mkdir /data/download -p
cd /data/download

///You need tcl 8.5 or newer in order to run the Redis test

wget http://sourceforge.net/projects/tcl/files/Tcl/8.5.15/tcl8.5.15-src.tar.gz/download
tar xzvf tcl8.5.15-src.tar.gz -C tcl8.5.15-src
cd tcl8.5.15-src/unix/
./configure –prefix=/data/lib/tcl8.5.15
make
make install
ln -s tcl8.5.15 tcl

export PATH=/data/lib/tcl/bin:$PATH
#export LD_LIBRARY_PATH=/data/lib/tcl/lib:$LD_LIBRARY_PATH

wget wget http://download.redis.io/releases/redis-2.8.13.tar.gz
tar -xf redis-2.8.13.tar.gz
cd redis-2.8.13
make
#make test
#make PREFIX=/data/lib/redis install

make PREFIX=/data/lib/bin/redis-2.8.13 install

cd /data/lib/redis
mkdir conf
mkdir logs
mkdir var
cp /data/lib/redis-stable/redis.conf /data/lib/redis/conf

——————————————————-
$ pwd
——————————————————-

/home/redis/app/redis

——————————————————-
$ ll bin
——————————————————-

-rwxr-xr-x 1 redis redis 4580235 Jul 28 16:16 redis-benchmark
-rwxr-xr-x 1 redis redis 22233 Jul 28 16:16 redis-check-aof
-rwxr-xr-x 1 redis redis 45467 Jul 28 16:16 redis-check-dump
-rwxr-xr-x 1 redis redis 4675985 Jul 28 16:16 redis-cli
-rwxr-xr-x 1 redis redis 6201291 Jul 28 16:17 redis-sentinel
-rwxr-xr-x 1 redis redis 6201291 Jul 28 16:16 redis-server

——————————————————-
$ ll
——————————————————-

drwxrwxr-x 2 redis redis 4096 Jul 28 16:17 bin
drwxrwxr-x 2 redis redis 4096 Jul 28 20:13 conf
drwxrwxr-x 2 redis redis 4096 Jul 30 17:55 data
drwxrwxr-x 2 redis redis 4096 Jul 28 19:44 logs
-rwxr-xr-x 1 redis redis 108 Jul 28 16:15 shutdown.sh
-rwxr-xr-x 1 redis redis 106 Jul 28 16:40 startup.sh
-rwxr-xr-x 1 redis redis 79 Jul 28 20:12 stn-shutdown.sh
-rwxr-xr-x 1 redis redis 138 Jul 28 17:03 stn-startup.sh
drwxrwxr-x 2 redis redis 4096 Jul 28 15:00 temp
drwxrwxr-x 2 redis redis 4096 Jul 28 20:19 var

——————————————————-
$ cat stn.conf
——————————————————-
port 26379
dir “/data/redis/app/redis-2.8.13/temp”
sentinel monitor mymaster 172.16.16.156 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel auth-pass mymaster password
sentinel config-epoch mymaster 1
sentinel leader-epoch mymaster 1

# Generated by CONFIG REWRITE
sentinel known-slave mymaster 172.16.16.155 6379
sentinel known-slave mymaster 172.16.16.157 6379
sentinel known-sentinel mymaster 172.16.16.156 26379 89348644a66ba88bf7dec6d67a6e210080576051
sentinel known-sentinel mymaster 172.16.16.157 26379 e4104de666d036dbbb3c47926b1b9a3177ec1549

sentinel current-epoch 1

——————————————————-
cat startup.sh
——————————————————-

# start redis in sentinel mode
export pwd=`dirname “$0″`
$pwd/bin/redis-server $pwd/conf/redis.conf

——————————————————-
cat shutdown.sh
——————————————————-

# shutdown redis
export pwd=`dirname “$0″`
$pwd/bin/redis-cli -h 127.0.0.1 -p 6379 -a password shutdown

——————————————————-
cat stn-startup.sh
——————————————————-

# start redis in sentinel mode
export pwd=`dirname “$0″`
$pwd/bin/redis-server $pwd/conf/stn.conf –sentinel >> $pwd/logs/stn.log &

——————————————————-
cat stn-shutdown.sh
——————————————————-

kill -9 `ps -ef | grep -v grep | grep redis | grep 26379 | awk ‘{print $2}’`

——————————————————-