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 and configure redis

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to install and configure redis. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

To put it simply, redis is a database, but unlike traditional databases, the data of redis is stored in memory, so the read and write speed is very fast, so redis is widely used in the cache direction.

Installation

Download, extract, compile:

$wget http://download.redis.io/releases/redis-4.0.10.tar.gz$ tar xzf redis-4.0.10.tar.gz$ mv redis-4.0.10 / usr/local/redis$ cd / usr/local/redis$ make

The binaries are compiled in the src directory

$ll-a src | grep redis-rw-rw-r-- 1 root root 2.4K Jun 13 19:02 redisassert.h-rwxr-xr-x 1 root root 2.6M Sep 14 12:05 redis-benchmark-rw-rw-r-- 1 root root 29K Jun 13 19:02 redis-benchmark.c-rw-r--r-- 1 root root 129K Sep 14 12:05 redis-benchmark.o-rwxr-xr-x 1 root root 6.0m Sep 14 12:05 redis-check-aof-rw- Rw-r-- 1 root root 7.0K Jun 13 19:02 redis-check-aof.c-rw-r--r-- 1 root root 38K Sep 14 12:05 redis-check-aof.o-rwxr-xr-x 1 root root 6.0M Sep 14 12:05 redis-check-rdb-rw-rw-r-- 1 root root 14K Jun 13 19:02 redis-check-rdb.c-rw-r--r-- 1 root root 68K Sep 14 12:04 redis-check-rdb.o- Rwxr-xr-x 1 root root 2.8M Sep 14 12:05 redis-cli-rw-rw-r-- 1 root root 99K Jun 13 19:02 redis-cli.c-rw-r--r-- 1 root root 450K Sep 14 12:05 redis-cli.o-rw-rw-r-- 1 root root 22K Jun 13 19:02 redismodule.h-rwxr-xr-x 1 root root 6.0M Sep 14 12:05 redis-sentinel-rwxr-xr-x 1 root root 6.0M Sep 14 12: 05 redis-server-rwxrwxr-x 1 root root 65K Jun 13 19:02 redis-trib

Redis-server is the server program and redis-cli is the client program.

Create a service

After the binary file is compiled, in the src directory, start the Redis service with the following command:

$ln-s / usr/local/redis/src/redis-cli / usr/bin/redis$ ln-s / usr/local/redis/src/redis-server / usr/bin/redisd output version $redis--versionredis-cli 4.0.10$ redisd-- versionRedis server vault 4.0.10 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=e53a76b77e60d5b0

At this point, your redis has been installed.

Configuration

Why should the configuration list a separate title?

This is because Redis does not maximize the optimization of security aspects, but tries to optimize high performance and ease of use as much as possible.

Redis opens port 6379 by default, which can cause any user to perform unauthorized access operations if authentication is not enabled. So we need to do some security configuration here.

New users

Never start Redis with a user with higher privileges. If your Reidis is not secure, then your highly privileged users will become a breakthrough, causing your server to be attacked.

So we need to create a redis account, start the redis service through this account, and configure the account to disable login.

$adduser redis$ vim / etc/passwdredis:x:1001:1001:,:/home/redis:/usr/sbin/nologin$ chown-R redis:redis / usr/local/redis modify configuration file

You are required to have a basic operation on vim.

Line 92 of vim redis.conf# modifies port port 737 log file line 171 set snapshot file directory around line 263, do not set a directory where redis users do not have permission, dir / usr/local/redis/# line 500 set password requirepass YOUR_PASSWORD$ mkdir / var/log/redis$ chown-R redis:redis / var/log/redis/ configure a startup program

Redis-server doesn't start with a daemon by default, so we need to configure a launcher for it.

$vim / usr/bin/goredisdnohup / usr/bin/redisd / usr/local/redis/redis.conf > > / var/log/redis/goredisd.log 2 > & 1 & $goredisd$ ps-axu | grep redisredis 19498 0.00.1 145304 2580 pts/0 Sl 10:49 0:09 / usr/bin/redisd *: 7379 Thank you for reading! This is the end of the article on "how to install and configure redis". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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

Development

Wechat

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

12
Report