Linux-based operating system installation, using Redis detailed

Source: Internet
Author: User
Tags delete key download redis redis redis download redis server

Server-side Installation

The official Redis Download station is http://redis.io/download, you can go to download the latest installer down, I write this article when the stable version is 2.6.11.

Step one: Download Redis

Go to the Software installation package storage directory: cd/var/install/software/

[Email protected] software]# wget http://redis.googlecode.com/files/redis-2.6.11.tar.gz

Step two: Compile the source program

[Email protected] software]# tar xzf redis-2.6.11.tar.gz
[Email protected] software]# CD redis-2.6.11
[[email protected] redis-2.6.11]# make

Step three: Start the Redis service

[[Email protected] redis-2.6.11]# CD src

[Email protected] src]#./redis-server
The default connection port on the Redis server is 6379. At this point you can see the port:

Netstat–atln

Step four: Randomly start redis as a Linux service

Vi/etc/rc.local, use the VI Editor to open the random startup configuration file and add the following line of code to it.

/var/install/software/redis-2.6.11/src/redis-server

Step five: Client connection verification

New open a session into the installation directory of SRC, and enter:./REDIS-CLI, if prompted below, then you can start the Redis journey.

[Email protected] src]#./redis-cli

Step Six: View Redis logs

View the server session to view or analyze the health of Redis.

Step Seven: Stop the Redis instance

The simplest method is to use Control-c to stop the instance directly in the session that has already been started.

We can also use the client to stop the service, such as the shutdown can be used to stop Redis instances, as follows:

[Email protected] src]#/REDIS-CLI shutdown



Working with the Redis database

Let's take a brief look at the database. In case the instance is turned on:

1. Inserting data

Redis 127.0.0.1:6379> Set name WWL
Ok

Set a Key-value pair.

2. Query data

Redis 127.0.0.1:6379> Get Name
"WWL"

Remove the value corresponding to the key.

3. Delete key values

Redis 127.0.0.1:6379> del name

Delete this key and the corresponding value.

4. Verify that the key is present

Redis 127.0.0.1:6379> exists name
(integer) 0

0, which means that the key does not exist; 1 stands for existence.

Configuration

Executing the redis-server in the SRC directory can start the Redis process, but it is a good idea to configure the redis.conf file first, several common parameters to note are as follows:

Daemonize Yes

Specifies that Redis runs as a daemon.

Pidfile/home/banping/redis/redis.pid

When Redis is running as a daemon, the PID is written to the specified file.

Port 6379

Specifies the listening port, which is the default port of 6379.

Bind 192.168.0.35

The host IP address of the binding.

LogFile stdout

Specifies how logs are logged, by default to standard output.

Databases 16

Set the number of databases.

Save

There are three conditions available in the Redis default configuration file:

Save 900 1

Save 300 10

Save 60 10000

900 seconds (15 minutes) with 1 changes, 300 seconds (5 minutes) with 10 changes and 60 changes in 10,000 seconds, synchronizing data to disk files.

Rdbcompression Yes

Specifies whether data is compressed when stored to a local database, by default yes.

Dbfilename Dump.rdb

Specifies the local database file name.

Dir/home/banping/redis/data

Specifies the local database to store the directory.

Requirepass foobared

Set the Redis connection password, which is turned off by default.

MaxClients 128

Set the maximum number of client connections, which is unrestricted by default.

MaxMemory

Specifies the maximum memory that Redis can use.

See the official documentation for more detailed parameter descriptions. After modifying the configuration file, we can start the Redis service with the specified configuration file:

[Email protected] src]#./redis-server/var/install/software/redis-2.6.11/redis.conf

Such a Redis service process is started and it listens on port 6379 to provide services

Linux-based operating system installation, using Redis detailed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.