Redis (1): Getting Started

Source: Internet
Author: User
Tags install redis

to install Redis under Linux:
wget http://download.redis.io/redis-stable.tar.gz
Tax Xzf redis-stable.tar.gz
CD redis-stable
Make
After the installation is complete, you can see that there are many Redis-initiated files under/usr/local/bin, which are the Redis commands

To start Redis:
Redis-server [--port 6380] is followed by the option to specify the port to start

How to configure Redis to boot with the system:
1. In the Redis/redis-stable/utils folder, there is a Redis_init_script initialization script file that copies the file to the/etc/init.d folder. and change the file name to the Redis_ port number, and then modify the contents of the initialization script file,
Replace All ${redisport} with the port number just
2. Create two folders/etc/redis/var/redis/port number
3. Copy the redis.conf file in the Redis/redis-stable folder to the/etc/redis directory, and modify the file name to the port number. conf. and modify the following parameters:
Daemonize Yes
Pidfile/var/run/redis_ port number. PID
Port Port number
dir/var/redis/Port number
Now it's time to start Reids with the/etc/init.d/redis_ port number start.
4. Finally set up boot by the following command
sudo update-rc.d redis_ port number Defaults


Tips: Change the file belongs to user with sudo chown zyq redis.conf, rename directly with MV Redis.conf 6379.conf

To start the client:
REDIS-CLI [-H 127.0.0.1-p 6379] where you can omit the specified host address and port number
Of course, the client can also use the REDIS-CLI ping command to test if the host receives a response, and if the host is healthy, it returns a Pang

Tips:linux to see which program is consuming the port:
lsof-i[:p ORT]---if you omit the port number, it will all be listed.
If you want to find the corresponding thread by name, you can use
ps-a | grep "Redis"

tips: Completely remove threads based on thread ID:
Kill-9 PID

Tips:tar Command:
In general, compression is used TAR-ZCVF
The decompression was TAR-ZXVF.
Parameters:
-C: Create a compressed file parameter directive (the meaning of Create);
-x: Unlock the parameter instructions for a compressed file!
-T: View the files inside the Tarfile!
In particular, in the release of the parameters, c/x/t can only exist one! Cannot exist at the same time!
Because it is not possible to compress and decompress simultaneously.
-Z: Do you have the properties of gzip at the same time? i.e. do I need gzip compression?
-j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2?
-V: Files are displayed during compression! This is commonly used, but is not recommended for use in the background execution process!
-F: Use the file name, please note, after F to immediately answer the file name Oh! Don't add any more arguments!
For example, using "TAR-ZCVFP tfile sfile" is the wrong way to write

Redis Configuration:
Redis-server Startup In addition to specifying the port number at startup, you can also pass in the configuration file as a parameter:
Redis-server/path/to/redis.conf
The configuration parameters in the configuration file are overwritten by passing in a configuration entry with the same name through a startup parameter:
redis-server/path/to/redis.conf--loglevel Warning
Of course, Redis also supports the modification of some configuration items dynamically through the Config set command at run time:
Config set loglevel warning
The value of the corresponding configuration item can be obtained by Config get at this time

Multiple databases:
Redis is a dictionary-structured storage server, and in fact Redis provides multiple data dictionaries, each of which can be viewed as a separate database:
Each database is named after a 0-based increment, and Redis supports 16 databases by default, which can be modified by configuring parameter databases, which automatically selects the database after the client has established a connection with the server.
However, you can switch the database by using the Select command (0-15 by default with the No. 0 database), and the Flushall command clears the data for all databases an empty Redis instance consumes only about 1 m of memory and is very small

Redis (1): Getting Started

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.