Deploy redis in linux and redis in linux

Source: Internet
Author: User
Tags redis server

Deploy redis in linux and redis in linux
Basic knowledge:

1. Redis data type:
String, lists, sets, sorts sets, and hashs)
2. What is unique between Redis and memcache:
(1) redis can be used for storage (storge), while memcache is used for cache ). This feature is mainly because of its "persistence" function.
(2) the stored data has a "structure". For memcache, there is only one type of stored data-"string ", redis can store strings, linked lists, sets, ordered sets, and Ha-order structures.
3. Two Methods of Persistence:
Redis stores data in memory or is configured to use virtual memory.
Two ways to achieve Data Persistence: (1) using the method to constantly write data in the memory to the disk (high performance, but may cause a certain degree of data loss)
(2) log every update using a method similar to mysql
4. Redis master-slave synchronization: It is very beneficial to improve reading performance
5. The default port of the Redis server is 6379.

Download and install

If linux can be connected to the network, you can download it online. Enter the code directly:
Wget http://download.redis.io/releases/redis-3.0.2.tar.gz
Address: https://redis.io/download

Unzip and install:
Tar xf redis-4.0.2.tar.gz

1. Go to the directory and run the make command.

If you need to better observe the installation process, execute nohup make and view it in the nohup. out file.

The installation is successful.

The following is the test phase.

2. Execute the command: make test

The following error occurs during installation.

Error 1:
You need tcl 8.5 or newer in order to run the Redis test
Solution:
# Yum install tcl

Error 2:
Killing still running Redis server 4966
Killing still running Redis server 4971
Killing still running Redis server 4976
Killing still running Redis server 4978
Killing still running Redis server 4980
Killing still running Redis server 4983
Killing still running Redis server 4990
Killing still running Redis server 4991
Killing still running Redis server 4998
Killing still running Redis server 5001
Killing still running Redis server 5014
Killing still running Redis server 5134
Killing still running Redis server 5187
Killing still running Redis server 5208
Killing still running Redis server 5224
Killing still running Redis server 5253
Killing still running Redis server 5265
Make [1]: *** [test] Error 1
Make [1]: Leaving directory '/opt/redis/redis-4.0.2/src'
Make: *** [test] Error 2

Solution:
Vim tests/integration/replication-2.tcl

-After 1000:
+ After10000

3. make install PREFIX =/usr/local/redis

Hint: It's a good idea to run 'make test ';)

INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install


4. Move the configuration file to the redis directory.

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

5. Configure environment variables (you do not need to enter the redis bin to start the service in the future)
# Vim/etc/profile # Add PATH =/usr/local/redis/bin: $ PATH # source/etc/profile before export PATH # take effect immediately
6. Start the redis service.

7. By default, Redis is not running in the background and needs to be run in the background.

# Change vim/usr/local/redis/etc/redis. conf // to yes

8. Client Connection

9. Stop a redis instance


Redis-cli shutdown
Or
Pkill redis-server

10. Enable redis to start automatically
Vim/etc/rc. local add redis-server/usr/local/redis/etc/redis-conf

  

11. Next let's take a look at the files in the/usr/local/redis/bin directory.


Redis-benchmark: redis Performance Testing Tool
Redis-check-aof: A Tool for checking aof logs
Redis-check-dump: a tool used to check rdb logs
Redis-cli: client used for connection
Redis-server: redis service process

12. Redis Configuration
Daemonize: If you need to run in the background, change the value of this item to yes pdifile: Put the pid file in/var/run/redis. pid, which can be configured to another address bind: Specify redis to only receive requests from this IP address. If this parameter is not set, all requests will be processed. It is best to set this port in the production process: listening port. The default value is 6379 timeout. Set the timeout time for client connection. The unit is second loglevel: Level 4, debug, revbose, notice, and warning. Notice logfile is usually enabled in the production environment: configure the log file address. By default, standard output is used, that is, printed on the port of the command line terminal. database: set the number of databases, the default database is 0 save: set the frequency of redis database mirroring rdbcompression: whether to compress dbfilename: the file name of the backup file dir: slaveof: the path where the database image backup files are stored: set this database to the slave database masterauth of other databases: when the master database connection requires password verification, set requirepass here: set the password maxclients to be used before other clients are specified after Client Connection: Limit the number of clients connected at the same time maxmemory: set the maximum memory appendonly available for redis: After the appendonly mode is enabled, redis will append each received write operation to appendonly. in the aof file, when redis is restarted, it will be restored from the file to the previous state appendfsync: Set appendonly. aof file synchronization frequency vm_enabled: whether to enable virtual memory support vm_swap_file: set the path of the swap file for Virtual Memory vm_max_momery: After enabling the virtual memory, redis will use the maximum physical memory size. The default value is 0 vm_page_size: Set the virtual memory page size vm_pages: Set the total number of pages in the swap file vm_max_thrrads: set the number of threads simultaneously used by vm IO

  













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.