Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Redis

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to install Redis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to install Redis" this article.

1. Redis Overview of what Redis is

Redis is an open source (BSD licensed), in-memory data structure storage system that can be used as database, cache, and messaging middleware. It supports many types of data structures, including: string (strings), hash (hashes), list (lists), set (sets), ordered collection (sorted sets). Redis has built-in replication (replication), LUA script (Lua scripting), LRU driven event (LRU eviction), transaction (transactions) and different levels of disk persistence (persistence), and provides high availability (high availability) through Sentinel and automatic partitioning (Cluster).

To put it simply, Redis is an open source (C language implementation) in-memory database based on key-value pairs (data structures).

Characteristics of Redis

High speed: C language implementation, all data are loaded in memory, data read speed of 110000 / s, write data 81000amp s.

Rich data structures: Redis supports multiple data structures: lists, collections, ordered collections, hash data types. Is a typical data structure server.

Operation atomicity: all Redis operations are atomic, which ensures that the Redis server accessed by two clients at the same time will get the updated value.

Master-slave replication (master-slaver): master-slave replication allows multiple slave server to have the same database replica as master server. Master server is dedicated to writing data, slave server is used to read data, and one write is excessive.

Sharding: the Redis cluster is realized by sharding.

Persistence: Redis provides some strategies for data storage.

Support for multiple development languages: Redis supports multiple languages, such as Ruby,Python, Twisted Python, PHP, Erlang, Tcl, Perl, Lua, Java, Scala, Clojure, etc.

two。 Install Redis

I installed Redis under the Linux system, version 3.0.5, because it is an intranet, I can't use the # wget command directly. I deployed Redis on a server with an IP of 10.27.180.75.

The first step is to download the latest version of Reids at http://redis.io/download

Step 2, log in to 10.27.180.75, extract and compile and install Redis

[root@fcpreapp05 ~] # tar-xzvf redis-3.0.5.tar.gz [root@fcpreapp05 ~] # cd redis-3.0.5 [root@fcpreapp05 redis-3.0.5] # ls 00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests BUGS INSTALL README runtest sentinel.conf utils CONTRIBUTING MANIFESTO deps runtest-cluster src [root@fcpreapp05 redis-3.0.5] # make

Step 3: start the redis server

[root@fcpreapp05 redis-3.0.5] # cd src/ [root@fcpreapp05 src] # redis-server

In the fourth step, another machine is used as the client to connect to the server, and the connection is determined by the ping PONG command.

[root@fcpreapp05] # redis-cli-h 10.27.180.75-p 6379 10.27.180.75 ping PONG "PONG"

In addition, we can download RedisClient,RedisClient is a Redis client GUI tool, written in Java swt and jedis. It presents redis data to the user in the interface style of windows Explorer.

Question: in what ways can we access the Redis server? 3. Parameter description of redis-server and redis-cli

Redis-server

The redis-server command is used to start the Redis server, and its parameters are as follows:

Usage:. / redis-server [/ path/to/redis.conf] [options] / / launch and install the specified configuration file (optional). / redis-server-(read config from stdin) / / use standard input to read the configuration as startup parameters. / redis-server-v or-- version / / View version number. / redis-server-h or-- help. / redis-server-- test-memory / / Test Try whether redis can run normally under specified memory size: Examples:. / redis-server (run the server with default conf). / redis-server / etc/redis/6379.conf. / redis-server-- port 7777. / redis-server-- port 7777-- slaveof 127.0.0.1 8888. / redis-server / etc/myredis.conf-- loglevel verbose redis-cli

The redis-server command is used to start the Redis client connection server, and its parameters are described as follows:

Usage: redis-cli [OPTIONS] [cmd [arg [arg...]-h / / hostname (default local: 127.0.0.1). -p / / port number (default: 6379). -s / / Server socket (overrides hostname and port). -a / / Password to use when connecting to the server. -r / / repeat execution-I / / if you repeat-r, the interval between each execution is-n / / database number. -x / / reads the last parameter from the standard input. -d-c / / enable reidis cluster mode-- raw / / Chinese output settings-- no-raw-- csv / / Output in CSV format. -- stat-- latency--latency-history-- latency-dist-- lru-test-- slave / / simulates the commands-- rdb / / received by slave from master, gets the rdb file of the specified redis instance, and saves it locally-- pipe / /, which is a very useful parameter. Send the original redis protocl format data to the server for execution-- pipe-timeout-- bigkeys / / A pair of key in redis is sampled to find a larger keys-- scan-- pattern-- intrinsic-latency-- eval / / that executes the specified lua script-- help-- version

There are many parameters in redis-cli. Here are some examples of common operations:

(1)-h-p@fcpreapp05 ~] # redis-cli-h 10.27.180.75-p 6379 10.27.180.75 6379 >

one

two

(2)-r-i@fcpreapp05 ~] # redis-cli-r 100-I 1 info stats | grep

one

(3)-eval@fcpreapp05 ~] # redis-cli-- eval myscript.lua key1 key2, arg1 arg2 arg3

one

two

(4) close Redis

[root@fcpreapp05 ~] # redis-cli shutdown 4. Redis basic operation

Here are some basic operations of Redis.

Operation description: ping test whether there is a connection quit exit connection info server basic information monitor real-time dump received request config get get server parameters configuration dbsize current database number of key flushdb empty current database expire set key expiration time persist lv remove current key expiration time set setting key-value,SET key valueget returns the string value associated with key, GET keydel deletes multiple key,DEL key [key …] Exist checks whether a given key exists, and EXISTS keyecho prints the key value 127.0.0.1 EXISTS keyecho 6379 > set name "redis" OK 127.0.0.1 EXISTS keyecho 6379 > set type "key-value" OK 127.0.0.1 EXISTS keyecho 6379 > exists type (integer) 1 127.0.0.1redis 6379 > get type "key-value" 127.0.0.1 integer 6379 > del name type (integer) 2 is all the contents of this article "how to install Redis". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report