Home> Database> Redis> body text

How to build a single-machine Redis environment

藏色散人
Release: 2020-09-05 09:30:55
forward
2215 people have browsed it

The following columnRedis Tutorialwill introduce to you how to build a single-machine Redis environment. I hope it will be helpful to friends in need!

How to build a single-machine Redis environment

Preface

In the actual development project process, if you want to use cache, then the first thing that comes to mind must be Redis, but why choose Redis? Most people don’t understand or think about it. They only know that it can be used as a cache and is a little faster than a database. It happens that I am also such a person; so, when I want to write an article When I was introduced to Redis, I had no way of talking about it; this is also the reason why I am not familiar with Redis and mainstream in-memory databases; however, in the days to come, I will definitely increase my thinking and in-depth about the framework, so that I can follow the technical road ahead. I have accumulated some experience in this article, and I hope that when someone asks me to give a brief introduction to Redis in the future, I will not be at a loss to start; this may be the purpose of writing a series of Redis blogs!

1. Redis environment Build

Download the redis stable version

curl -o redis.tar.gz http://download.redis.io/releases/redis-stable.tar.gz
Copy after login

Extract the redis package

tar -zxvf redis-stable.tar.gz -C ./ // This command means decompression tar.gz package to the current directory

Compile and install redis

Enter the directory of the decompressed Redis, use the following command to compile and install Redis

sudo make && make install PREFIX=/usr/local/redis
Copy after login

Edit and configure the Redis configuration file

sudo cp redis.conf /usr/local/redis/conf/
Copy after login

Start the Redis service

./redis-server ../conf/redis.conf & //启动的时候后台运行
Copy after login

Start the output log:

45894:C 02 Nov 2018 22:11:19.922 # Redis version=5.0.0, bits=64, commit=00000000, modified=0, pid=45894, just started 45894:C 02 Nov 2018 22:11:19.922 # Configuration loaded 45894:M 02 Nov 2018 22:11:19.924 * Increased maximum number of open files to 10032 (it was originally set to 256). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.0 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 45894 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 45894:M 02 Nov 2018 22:11:19.933 # Server initialized 45894:M 02 Nov 2018 22:11:19.933 * Ready to accept connections
Copy after login

Verify the Redis service

Use the network tool telnet to verify

terrydeMacBook-Air:bin terrylmay$ telnet 127.0.0.1 6379 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'.
Copy after login

Use the system Process ps verification

terrydeMacBook-Air:bin terrylmay$ ps -ef | grep redis 501 45894 44430 0 10:11下午 ttys000 0:00.04 ./redis-server 127.0.0.1:6379 //一个是Redis服务 501 45897 44430 0 10:11下午 ttys000 0:00.00 grep redis //ps查询进程自己
Copy after login

At this point, a stand-alone version of the Redis service is completed!

2. Use Redis to store data

Redis CLI Connecting to the Redis service

terrydeMacBook-Air:bin terrylmay$ ./redis-cli 127.0.0.1:6379> 127.0.0.1:6379> set name terrylmay OK 127.0.0.1:6379> get name "terrylmay" 127.0.0.1:6379>
Copy after login

At this point, we can use the Redis system to store data string data.

The above is the detailed content of How to build a single-machine Redis environment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!