CentOS 7.6 deployment Redis database

Summary:

redis is a key-value storage system. And Memcached Similarly, it supports relatively more stored value type, comprising a string (string), List (list), SET (set), zset (sorted set - ordered set) and hash (hash type). These data types are supported push / pop, add / remove and on the intersection and union, and difference richer operation, and these operations are atomic. On this basis, redis support a variety of different ways of sorting. Like with memcached, in order to ensure efficiency, the data is cached in memory. Redis difference is periodically updated in the data written to disk or to modify the operation of writing additional log file, and on this basis realize the master-slave (master and slave) synchronization.

redis usage scenarios

Login session storage: Store in redis compared with memcached, data is not lost.
Top version / counter: for example, some of the show class project, there is often some former anchor ranked number names. There are some articles to read the amount of technology, or Sina microblogging number of points such as praise.
As the message queue: redis such as celery is used as an intermediary.
Online Now: still show the previous example, the current system will show how much the number of online.
Some commonly used data cache: Such as our BBS forum, the plate does not change often, but each visit must be obtained from the Home mysql can be cached in the redis, not every request database.
The first 200 articles or reviews cache cache: general users visit the website, only the front part of the article or view a comment, you can put in front of 200 articles and corresponding comments cached. Users access to over, access the database, and after more than 200 articles, put the article before deleting.
Friends relationship: friendship redis use microblogging to achieve.
Publish and subscribe functions: can be used to make chat software.

Compare memcached and redis

CentOS 7.6 deployment Redis database

installation steps:

1. Get redis resources

cd /usr/local
wget http://download.redis.io/releases/redis-4.0.8.tar.gz

2. Extract

takes xzvf redis-4.0.8.tar.gz

3. Compile install

cd redis-4.0.8
make
cd src
make install PREFIX=/usr/local/redis

4. Move to the installation configuration file directory

cd ../
mkdir /usr/local/redis/etc
mv redis.conf /usr/local/redis/etc

5. Configure redis to start background

vim /usr/local/redis/etc/redis.conf
will daemonize no change daemonize yes

6. redis added to the boot

vim /etc/rc.local // contents added at the end:
/ usr / local / redis / bin / redis-Server /usr/local/redis/etc/redis.conf # turn calls this turn redis command

7. Turn redis

/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

8. Set password

1. The first embodiment (this method of the current configuration redis linux is a temporary password, the password after the restart will fail if redis)

(1) First enter redis, if not open redis you need to enable:

[root@test bin]# redis-cli -p 6379
127.0.0.1:6379>

(2) view the current redis there is no password:

127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""

(3) no password is shown above explanation, it is now to set the password:

127.0.0.1:6379> config set requirepass abcdefg
OK

(4) again to view the current redis prompted for a password:

127.0.0.1:6379> config get requirepass
(error) NOAUTH Authentication required.

2. The second method (permanent way)

Review redis.conf configuration:
Vim /usr/local/redis/etc/redis.conf member  
requirepass P @ ss # 12 - * - Set Password

Note: Online Server password must be as complex or very easy virus (himself encountered), to remind! ! !

After saving reboot redis

Common Commands  

redis-server /usr/local/redis/etc/redis.conf // start redis
pkill // stop redis redis

Reference article:

1. https://www.cnblogs.com/lauhp/p/8487029.html
2. https://www.cnblogs.com/renshaoqi/p/10617238.html

Guess you like

Origin blog.51cto.com/13760351/2466154