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 and Redis startup parameters

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces how to install Redis, Redis startup parameters, the article is very detailed, has a certain reference value, interested friends must read it!

Redis is a key-value storage system. Similar to Memcached, but solves the problem of complete data loss after a power outage, and she supports more value types, including lists (linked lists), sets (collections), and zsets (ordered collections) in addition to and string. These data types support push/pop, add/remove, and take intersection union and difference sets, and richer operations, and these operations are atomic.

What is the performance of Redis?

Here are the official bench-mark figures:

The test was done with 50 simultaneous clients performing 100000 requests.

The value SET and GET is a 256 bytes string.

The Linux box is runningLinux 2.6, it'sXeon X20 2.5Ghz.

Text executed using the loopback interface (127.0.0.1).

Results:about 110000 SETs per second, about 81000 GETs per second.

How to install Redis and Redis startup parameters

1. Install Redis

The code for Redis follows ANSI-C and can be installed and run on all POSIX systems (such as Linux,*BSD, Mac OS X, Solaris, etc.). And Redis does not rely on any non-standard libraries, and there are no compilation parameters that must be added. To compile and install Redis, the only thing we need is make. The following is the installation process, using the current stable version 1.2.6, and version 2.0 is still under development.

1.1. Get the source code, extract it, and enter the source code directory:

Wget http://redis.googlecode.com/files/redis-1.2.6.tar.gz

Tar xzf redis-1.2.6.tar.gz

Cd redis-1.2.6

1.2. Compile to generate an executable file:

Since the makefile file has been written, we just need to execute the make command directly in the source directory to compile:

Make

After the make command is executed, the executable files (redis-server, redis-cli, redis-benchmark, redis-stat) will be generated in the current directory. Their functions are as follows:

Daemon launcher for redis-server:Redis server

Redis-cli:Redis command line operation tool. Of course, you can also use telnet according to its plain text protocol.

Redis-benchmark:Redis performance testing tool to test the read and write performance of Redis on your system and your configuration

Redis-stat:Redis status detection tool, which can detect the current state parameters and delay status of Redis

1. Create a Redis directory (optional)

This process is not necessary, but is just an operation to unify the management of Redis-related resources.

Execute the following command to establish the relevant directory and copy the relevant files to the directory:

Sudo-s

Mkdir-p / usr/local/redis/bin

Mkdir-p / usr/local/redis/etc

Mkdir-p / usr/local/redis/var

Cp redis-server redis-cli redis-benchmark redis-stat / usr/local/redis/bin/

Cp redis.conf / usr/local/redis/etc/

Detailed explanation of 2.Redis configuration parameters

After we successfully installed Redis, we directly executed redis-server to run Redis, which runs according to the default configuration (the default configuration is not even running in the background). If we want Redis to run according to our requirements, we need to modify the configuration file. The configuration file of Redis is the redis.conf file of our second cp operation above, which is currently copied to the / usr/local/redis/etc/ directory. Modify it to configure our server. How to modify it? The following is the meaning of the main configuration parameters of redis.conf:

Daemonize: whether to run in background daemon mode

Pidfile:pid file location

Port: the port number on which to listen

Timeout: request timeout

Loglevel:log information level

Logfile:log file location

Databases: number of databases opened

Save * *: how often the snapshot is saved. The first * indicates how long it takes, and the third * indicates how many writes are performed. The snapshot is automatically saved when a certain number of writes are performed within a certain period of time. Multiple conditions can be set.

Rdbcompression: whether to use compression

Dbfilename: data snapshot file name (file name only, not directory)

Dir: the directory where the data snapshot is saved (this is the directory)

Appendonly: whether or not to enable appendonlylog, each write operation will record a log, which will improve the anti-risk ability of the data, but affect the efficiency.

How to synchronize appendfsync:appendonlylog to disk (three options: forcing fsync to be called every time you write, enabling fsync once per second, and not calling fsync to wait for the system to synchronize itself)

The following is a slightly modified configuration file:

Daemonize yes

Pidfile / usr/local/redis/var/redis.pid

Port 69

Timeout 0

Loglevel debug

Logfile / usr/local/redis/var/redis.log

Databases 16

Save 900 1

Save 0 10

Save 60 10000

Rdbcompression yes

Dbfilename dump.rdb

Dir / usr/local/redis/var/

Appendonly no

Appendfsync always

Glueoutputbuf yes

Shareobjects no

Shareobjectspoolsize 1024

Write the above as redis.conf and save it to the / usr/local/redis/etc/ directory

Then execute on the command line:

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

You can start the redis service in the background, and then you can use the

Telnet 127.0.0.1 69

You can connect to your redis service.

The above is all the contents of the article "how to install Redis and Redis startup parameters". Thank you for reading! Hope to share the content to help you, more related 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