In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Introduction of redis
Redis is a key-value storage system. Similar to Memcached, it supports relatively more value types to be stored, including string (string), list (linked list), set (collection), and zset (ordered collection). These data types support push/pop, add/remove, and take intersection union and difference sets, and richer operations, and these operations are atomic. On this basis, redis supports a variety of different sorting methods. Like memcached, data is cached in memory for efficiency. The difference is that redis will periodically write updated data to disk or modify operations to additional record files, and on this basis to achieve master-slave (master-slave) synchronization. Redis is a high-performance key-value database. The emergence of redis makes up for the deficiency of keyvalue storage such as memcached to a great extent, and can play a good complementary role to relational databases in some cases.
II. Redis installation and simple configuration
1. Installation environment
This experiment is completed in the virtual machine environment, VMware virtual machine. Two centos6.6 machines, the ip is
Master:192.168.233.129
Slave:192.168.233.128
Get the 2.redis installation package.
It can be downloaded from redis's official website, http://www.redis.io/download. You can also download the rpm package: http://rpm.pbone.net/
I'm using redis-2.6.11-37.1.x86_64.rpm here.
3. Installation and configuration
Upload to the 192.168.233.129 machine using the ftp tool.
Execute the command: rpm-ivh redis-2.6.11-37.1.x86_64.rpm
a. See which files are generated by the redis package:
b. Configuration
Execute the command cp / etc/redis/default.conf.example / etc/redis/redis.conf
Then compile the configuration file redis.conf
I have only modified the following two items:
Daemonize yes # redis will run as a daemon. By default, no will temporarily use your terminal.
Timeout 300 # closes the connection when the client has been idle for how long. If specified as 0, the function is disabled.
c. Create process startup and shutdown scripts.
Vim / EtcUnip init.dAccord redispatch description Redis is an open source binAccording # redis Startup script for Redis Server## chkconfig:-801 cycles Advanced key-value store.## processname: redis-server# config: / etc/redis.conf# pidfile: / var/run/redis.pidsource / etc/init.d/functionsBIN= "/ usr/sbin" CONFIG= "/ etc/redis/redis.conf" PIDFILE= "/ var/run/redis.pid" # Read configuration [- r "$SYSCONFIG"] & & source "$SYSCONFIG" RETVAL=0prog= "redis-server" desc= "Redis Server" start () {if [- e $PIDFILE] Then echo "$desc already running...." Exit 1 fi echo-n $"Starting $desc:" daemon $BIN/$prog $CONFIG RETVAL=$? Echo [$RETVAL-eq 0] & & touch / var/lock/subsys/$prog return $RETVAL} stop () {echo-n $"Stop $desc:" killproc $prog RETVAL=$? Echo [$RETVAL-eq 0] & & rm-f / var/lock/subsys/$prog $PIDFILE return $RETVAL} restart () {stop start} case "$1" in start) start;; stop) stop;; restart) restart;; condrestart) [- e / var/lock/subsys/$prog] & & restart RETVAL=$? Status) status $prog RETVAL=$?;; *) echo $"Usage: $0 {start | stop | restart | condrestart | status}" RETVAL=1esacexit $RETVAL
d. Start and shut down
Service redis start
Service redis stop
View process information
View port information
4. test
Third, Redis master-slave configuration
Redis master-slave replication is similar to most master-slave replication, a master can have multiple slave, supports chained replication, and master synchronizes data to the slave in a non-blocking manner. After starting a slave, slave will send a synchronization command to the master, requesting to synchronize the data on the main database. Master will start a background sub-process to save the data snapshot to the data file, send the data file to slave,slave, save the data file locally, load it into memory after rebuilding the database locally, and complete the synchronization.
The characteristics of the master and slave of redis:
A. Redis uses asynchronous replication, and the slave server reports the progress of the replication stream to the master server at a frequency of once per second.
B. a master server can have multiple slave servers, and a slave server can have its own slave server (cascading replication)
C. the replication function does not block the master server, and the master server can continue to process command requests even if one or more slave servers are synchronizing for the first time
D. Replication can be used for data redundancy, or scalability can be improved by having multiple slave servers handle read-only command requests.
E and Redis slave nodes are read-only by default and do not need to be configured manually. The master-slave cluster of redis can achieve the effect of sharing pressure, but it cannot achieve high availability. If master goes down, the service will not be available, so you can use sentinel of redis to achieve the function of HA.
1. Install redis on slave (192.168.233.128) in the same way as above
two。 Modify the redis.conf files of the two machines and change the bind parameter to be equal to your own IP
3. Modify the redis.conf on the slave machine to set the slaveof value:
Slaveof 192.168.233.129 6379
4. After configuration, start the Redis service of slave, OK, and the master-slave configuration is complete.
4. Test 1. Execute the info command on master and slave respectively to view
Master:
Slave:
two。 Set a value on master and view it on get on slave.
Master:
Slave:
At this point, the construction is complete.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.