Test environment: Virtual machine with 2 Cnetos 64-bit
Main service: 192.168.210.11 (NAT Internet mode)
From service: 192.168.210.12
Redis is a high-performance Key-value database.RedisThe emergence of a large extent to compensate for memcached such key/value storage deficiencies, in some cases can be a good complement to the relational database.
It provides a python,ruby,erlang,php client that supports replication.
Currently the latest version is:redis-2.8.9
:http://download.redis.io/releases/redis-2.8.9.tar.gz
Installation:
[Email protected] ~]#Yum install-y gcc gcc-c++ tcl//These must be installed, otherwise it will be an error!!!
[Email protected] ~]# cd/usr/local/src/
[Email protected] src]# Tar XF redis-2.8.9.tar.gz
[Email protected] src]# CD redis-2.8.9
[Email protected] redis-2.8.9]#make//Direct makes is OK, because Redis does not support configure configuration preconfigured environment, so for management convenience, manually created, Redis home directory to hold commands and configuration files.
[Email protected] redis-2.8.9]#Make test//Check if there is an error
[email protected] redis-2.8.9]# mkdir-p/usr/local/redis/bin
[Email protected] redis-2.8.9]# mkdir/usr/local/redis/conf
[Email protected] redis-2.8.9]#CD src/
[Email protected] src]#CP redis-benchmark redis-check-aof redis-check-dump redis-sentinel redis-server redis-cli/usr/local/redis/bin/ #相关命令
[Email protected] src]#CD: && CP redis.conf/usr/local/redis/conf/ #拷贝主配置文件
Modify the configuration file (main service):
[Email protected] ~]# vi/usr/local/redis/conf/redis.conf
daemonize Yes #no改为yes to start the daemon process.
Save exit and start Redis.
[Email protected] ~]# /usr/local/redis/bin/redis-server/usr/local/redis/conf/redis.conf
[Email protected] ~]# lsof-i:6379 #6379为redis默认监听端口//No lsof, just install yum ~0.0
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
Redis-ser 7324 Root 4u IPv6 22814 0t0 TCP *:6379 (LISTEN)
Redis-ser 7324 root 5u IPv4 22816 0t0 TCP *:6379 (LISTEN)
Test (main service):
Redis comes with command-line tools and can also be passed telnet to port testing.
[Email protected] ~]#/usr/local/redis/bin/redis-cli-p 6379
127.0.0.1:6379> set Test rootop
Ok
127.0.0.1:6379> Get Test
"Rootop"
127.0.0.1:6379> exit
Modify configuration file (from service): Installing Redis is the same way ~
[Email protected] ~]# vi/usr/local/redis/conf/redis.conf
daemonize Yes #no改为yes to start the daemon process.
Port 6380 #6379改成6380
Slaveof (primary ip+ Port) from the Add line
If the Lord adds a password, add a line Masterauth passwd
Save exit and start Redis.
[Email protected] ~]# /usr/local/redis/bin/redis-server/usr/local/redis/conf/redis.conf
[Email protected] ~]# lsof-i:6380 #这个地方的端口是6379还是6380我记得不清楚了, try it yourself ~
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
Redis-ser 7324 Root 4u IPv6 22814 0t0 TCP *:6380 (LISTEN)
Redis-ser 7324 root 5u IPv4 22816 0t0 TCP *:6380 (LISTEN)
test (from service):
Redis comes with command-line tools and can also be passed telnet to port testing.
[Email protected] ~]#/usr/local/redis/bin/redis-cli-p 6380
127.0.0.1:6380> get test//Because the main service there set Test Rootop, here as long as get test can get "Rootop" success ~
"Rootop"
127.0.0.1:6380> exit
* * There is also a way to run info in the master and slave Redis, to see if it is synchronous, and to determine whether or not it is built .
It's finished ~ Sprinkle flower!!!!!
http://download.redis.io/releases/redis-3.0.2.tar.gz
Http://www.jb51.net/article/56448.htm Super, Hyper-detailed Redis database Getting Started Tutorial
http://aws.amazon.com/cn/ec2/pricing/?sc_channel=ps&sc_campaign=acquisition_cn&sc_publisher=baidu& Sc_medium=ec2_b&sc_content=ec2_e&sc_detail=aws_ec2&sc_category=ec2&sc_segment=75&sc_ matchtype=exact&sc_country=cn&s_kwcid=al!4422!88!5293110009!! 17798814216&ef_id=vz9pbgaabnbvhoqg:20150710064110:s AWS EC2
Keys *REDIS-CLI shutdown
Redis Master-Slave configuration