"Installing Redis Single-instance combat"
Yum-y Install gcc gcc-c++ #安装编译工具
Cd/opt
Wget-c http://download.redis.io/releases/redis-3.0.5.tar.gz #下载包
Tar XF redis-3.0.5.tar.gz #解压
CD redis-3.0.5
Make MALLOC=LIBC #编译
Make Prefix=/usr/local/redis Install #安装
Echo ' Path=/usr/local/redis/bin: $PATH ' >>/etc/profile #配置环境变量
Source/etc/profile #或. /etc/profile
Mkdir/usr/local/redis/conf #创建目录
cp/opt/redis-3.0.5/redis.conf/usr/local/redis/conf/#拷贝配置文件
Sed-i "46s#/var/run/redis.pid#/usr/local/redis/conf/redis.pid#"/usr/local/redis/conf/redis.conf
Sed-i "192s#./#/usr/local/redis/conf/#"/usr/local/redis/conf/redis.conf
Sed-i 509s/no/yes//usr/local/redis/conf/redis.conf
Nohup redis-server/usr/local/redis/conf/redis.conf &>/dev/null &
echo vm.overcommit_memory = 1 >>/etc/sysctl.conf
Sysctl-p
lsof-i:6379 #查看端口有没有起来
#redis-CLI shutdown
"Redis Multi-instance combat"
Mkdir-p/usr/local/redis/6380/conf
cp/usr/local/redis/conf/redis.conf/usr/local/redis/6380/conf/
Sed-i 50s/6379/6380//usr/local/redis/6380/conf/redis.conf
Sed-i "46s#/var/run/redis.pid#/usr/local/redis/6380/conf/redis.pid#"/usr/local/redis/6380/conf/redis.conf
Sed-i "192s#./#/usr/local/redis/6380/conf/#"/usr/local/redis/6380/conf/redis.conf
Sed-i 509s/no/yes//usr/local/redis/6380/conf/redis.conf
Redis-server/usr/local/redis/6380/conf/redis.conf &
Mkdir-p/usr/local/redis/6381/conf
cp/usr/local/redis/conf/redis.conf/usr/local/redis/6381/conf/
Sed-i 50s/6379/6381//usr/local/redis/6381/conf/redis.conf
Sed-i "46s#/var/run/redis.pid#/usr/local/redis/6381/conf/redis.pid#"/usr/local/redis/6381/conf/redis.conf
Sed-i "192s#./#/usr/local/redis/6381/conf/#"/usr/local/redis/6381/conf/redis.conf #更改rdb文件存放目录
Sed-i 509s/no/yes//usr/local/redis/6381/conf/redis.conf #开启aof日志文件
Redis-server/usr/local/redis/6380/conf/redis.conf &
# redis-cli-p 6381
> Set a B
> Save
> Quit
# ls/usr/local/redis/6381/conf #查看生成的dump. rdb file
# redis-cli-p 6381 shutdown #关闭服务
"Master-Slave Synchronous Combat" (the main follow can be on the same server, with the server must have at least two instances)
Master: 6379 from: 6380-"Same server, different instances
1) from modifying the configuration file
Sed-i "210a slaveof 192.168.1.103 6379"/usr/local/redis/6380/conf/redis.conf #此处不写主的IP写主的域名也可以
Sed-i "217a masterauth wsyht"/usr/local/redis/6380/conf/redis.conf #master没密码可以不做这一步
Redis-cli-p 6380 shutdown
Redis-server/usr/local/redis/6380/conf/redis.conf &
2) Build Library verification view, main operation
[Email protected] conf]# redis-cli-p 6379-a wsyht
127.0.0.1:6379> Set name Wsyht
Ok
127.0.0.1:6379> Get Name
"Wsyht"
127.0.0.1:6379> Select 1
Ok
127.0.0.1:6379[1]> Set name Peter
Ok
127.0.0.1:6379[1]>info #查看所有信息包括同步
127.0.0.1:6380>info Replication #只查看他的同步信息
3) from view library and status information, monitor monitors every 10 seconds to spell
[Email protected] ~]# redis-cli-p 6380
127.0.0.1:6380> Monitor
Ok
1446980247.929617 [0 192.168.1.103:6379] "PING"
1446980257.981266 [0 192.168.1.103:6379] "PING"
1446980268.034426 [0 192.168.1.103:6379] "PING"
1446980273.602672 [0 192.168.1.103:6379] "select" "0"
1446980273.602687 [0 192.168.1.103:6379] "set" "Name" "Wsyht"
1446980278.089068 [0 192.168.1.103:6379] "PING"
1446980288.140236 [0 192.168.1.103:6379] "PING"
1446980294.722701 [0 192.168.1.103:6379] "select" "1"
1446980294.722721 [1 192.168.1.103:6379] "set" "Name" "Peter"
1446980298.190898 [1 192.168.1.103:6379] "PING"
^c
[Email protected] ~]# redis-cli-p 6380
127.0.0.1:6380> Get name #查看同步过来的库
"Wsyht"
127.0.0.1:6380>info #查看所有信息包括同步
127.0.0.1:6380>info Replication #只查看他的同步信息
Hope to communicate with the technology can be contacted by the following ways to me:
My OPS group: 517751492
My qq:1934844044.
This article is from the "Technology sharing" blog, so be sure to keep this source http://wsyht2015.blog.51cto.com/9014030/1715782
Redis Single instance, multi-instance, master-slave synchronous combat