Redis Installation Deployment Maintenance

Source: Internet
Author: User

Redis is a high-performance Key-value database whose key has a rich data structure: String,hash,list set and sorted set. As a nosql, not only the key data structure is rich, but also has the persistent function, and can support the master-slave replication, it is convenient to build the cluster. Redis high performance is largely due to its memory-based database, its high performance in: Set operation 11w/s,get Operation 8.1W/S, and other types of database performance differences, you can refer to: http://timyang.net/data/mcdb-tt-redis/. To further deepen my understanding of redis, I intend to write a Redis series blog. Here we mainly talk about Redis installation and operation maintenance.

1. Download and install

[Plain] view plaincopy

    1. [Email protected] tool]# wget-c http://redis.googlecode.com/files/redis-2.4.17.tar.gz #下载

    2. [Email protected] tool]# TAR-ZXVF redis-2.4.17.tar.gz #解压

    3. [Email protected] tool]# CD redis-2.4.17

    4. [email protected] redis-2.4.17]# make #编译

    5. [[email protected] redis-2.4.17]# make install #安装

The usual tools are automatically copied to the/user/loca/bin directory when the installation is complete. As a server, we often also need to set up Redis to boot, the source package has a very useful script, follow the footsteps of the prompt input can be.

[Plain] view plaincopy

  1. [Email protected] redis-2.4.17]# CD utils/

  2. [Email protected] utils]#./install_server.sh

  3. Welcome to the Redis service installer

  4. This script would help you easily set up a running Redis server

  5. Please select the Redis port for this instance: [6379]

  6. Selecting default:6379

  7. Please select the redis config file name [/etc/redis/6379.conf]

  8. Selected Default-/etc/redis/6379.conf

  9. Please select the Redis log file name [/var/log/redis_6379.log]

  10. Selected Default-/var/log/redis_6379.log

  11. Please select the data directory for this instance [/var/lib/redis/6379]

  12. Selected Default-/var/lib/redis/6379

  13. Please select the Redis executable path [/usr/local/bin/redis-server]

  14. copied/tmp/6379.conf =/etc/init.d/redis_6379

  15. Installing service ...

  16. Successfully added to chkconfig!

  17. Successfully added to Runlevels 345!

  18. Starting Redis Server ...

  19. Installation successful!


Note that the execution of install_server.sh, you need to enter the Utils directory, or the script will be error, prompted to find the corresponding file. After the service is installed, Redis starts automatically and can be viewed with the PS command:

[Plain] view plaincopy

    1. [Email protected] utils]# Ps-ef | grep Redis

    2. Root 4554 1 0 10:55? 00:00:02/usr/local/bin/redis-server/etc/redis/6379.conf

    3. Root 4564 2808 0 10:59 pts/0 00:00:00 grep redis


2, manually start the shutdown service

[Plain] view plaincopy

    1. [Email protected] utils]#/etc/init.d/redis_6379 stop #关闭

    2. [Email protected] utils]#/etc/init.d/redis_6379 start #启动

You can also start the Shutdown Redis Service directly with a command similar to the following:

[Plain] view plaincopy

    1. /usr/local/bin/redis-server/etc/redis/redis.conf #指定配置文件 start up

    2. /usr/local/bin/redis-cli-p 6379 shutdown # Off, if the default port 6379 can be directly/usr/local/bin/redis-cli shutdown

3. Connect Redis service via client command line tool to view Redis related information

A) connection

[Plain] view plaincopy

    1. [Email protected] utils]# REDIS-CLI

    2. Redis 127.0.0.1:6379>


b) Other Directives

[Plain] view plaincopy

  1. Redis 127.0.0.1:6379> Info #查看server版本内存使用连接等信息

  2. Redis 127.0.0.1:6379> Client List #获取客户连接列表

  3. Redis 127.0.0.1:6379> client Kill 127.0.0.1:33441 #终止某个客户端连接

  4. Redis 127.0.0.1:6379> dbsize #当前保存key的数量

  5. Redis 127.0.0.1:6379> Save #立即保存数据到硬盘

  6. Redis 127.0.0.1:6379> Bgsave #异步保存数据到硬盘

  7. Redis 127.0.0.1:6379> flushdb #当前库中移除所有key

  8. Redis 127.0.0.1:6379> Flushall #移除所有key从所有库中

  9. Redis 127.0.0.1:6379> Lastsave #获取上次成功保存到硬盘的unix时间戳

  10. Redis 127.0.0.1:6379> Monitor #实时监测服务器接收到的请求

  11. Redis 127.0.0.1:6379> Slowlog Len #查询慢查询日志条数

  12. (integer) 3

  13. Redis 127.0.0.1:6379> Slowlog Get #返回所有的慢查询日志, maximum depends on Slowlog-max-len configuration

  14. Redis 127.0.0.1:6379> Slowlog get 2 #打印两条慢查询日志

  15. Redis 127.0.0.1:6379> slowlog Reset #清空慢查询日志信息


Through the above operation, a single server basically ran up, but the back of the road is very long ....


Reference article:

Http://redis.io/topics/introduction

http://timyang.net/data/mcdb-tt-redis/

Http://redis.io/commands#server

http://code.google.com/p/redis/



Redis Installation Deployment Maintenance

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.