Linux 下编译安装 Redis
Redis还提供了丰富的客户端,以便支持现阶段流行的大多数编程语言。Redis自身使用ANSI C来编写,并且能够在不产生外部依赖(exte
Redis是一款开源的、高性能的键-值存储(key-value store)。它常被称作是一款数据结构服务器(data structure server)。Redis的键值可以包括字符串(strings)、哈希(hashes)、列表(lists)、集合(sets)和 有序集合(sorted sets)等数据类型。 对于这些数据类型,你可以执行原子操作。例如:对字符串进行附加操作(append);递增哈希中的值;向列表中增加元素;计算集合的交集、并集与差集等。
为了获得优异的性能,Redis采用了内存中(in-memory)数据集(dataset)的方式。根据使用场景的不同,你可以每隔一段时间将数据集转存到磁盘上来持久化数据,或者在日志尾部追加每一条操作命令。
Redis同样支持主从复制(master-slave replication),并且具有非常快速的非阻塞首次同步(non-blocking first synchronization)、网络断开自动重连等功能。同时Redis还具有其它一些特性,其中包括简单的check-and-set机制、 pub/sub和配置设置等,以便使得Redis能够表现得更像缓存(cache)。
Redis还提供了丰富的客户端,以便支持现阶段流行的大多数编程语言。详细的支持列表可以参看Redis官方文档: /clients。Redis自身使用ANSI C来编写,并且能够在不产生外部依赖(external dependencies)的情况下运行在大多数POSIX系统上,例如:Linux、*BSD、OS X和Solaris等。
Redis的安装
说明:Redis的安装版本选取为2.2.6,安装包为redis-2.2.6.tar.gz,系统平台为CentOS 5.5。
1. 解压安装包
使用tar -xzvf redis-2.2.6.tar.gz来解压安装包。假设Redis 解压后目录为redis-2.2.6,绝对路径使用$REDIS_HOME来表示。其目录结构如下所示:
其中,README和INSTALL中包含了编译、安装Redis的简单说明,在正式开始之前请先阅读这两个文件。
2. 编译
进入$REDIS_HOME/src目录,,使用make命令来编译Redis,该编译过程将会产生redis-server二进制文件。
3. 测试
在编译Redis完成之后,最好使用make test命令进行一下测试,但是该步不是必须的。
4. 安装
使用make install来完成Redis的安装。Redis的所有二进制文件将会被安装在/usr/local/bin目录下。
Redis的运行和测试:
假设Redis安装在/usr/local/bin目录下,并且该目录包含在$PATH环境变量的搜索目录中。那么便可以使用redis-server来 运行Redis。如果Redis安装在其他目录中,可以使用/path/to/redis-server来启动Redis,或者将Redis的安装目录添 加到$PATH的搜索目录中。
Redis自带了一个称为redis-cli的命令行客户端,该客户端会在运行make命令的时候自动编译。用户可以使用该客户端完成Redis的一些简单测试或操作。
使用redis-cli来启动该客户端,启动后命令行前缀为:redis>。用户可以在此进行后续操作,这类似于MySQL的命令行模式。
例如,使用如下命令来存储key-value对:
使用get命令来获取所存储的值:
至此,Redis的安装和简单测试便完成了。需要注意的是,在运行make test命令的时候,有时候会出现如下错误:
(cd ..; tclsh8.5 tests/test_helper.tcl --tags "" --file "")
/bin/sh: tclsh8.5: command not found
make: *** [test] Error 127
之所以会出现该错误是因为在运行make test命令时,需要Tcl 8.5的库,而CentOS 5.5自带的版本为8.4。用户可以使用如下命令来查看:
此时,你可以到Tcl的官方网站下载8.5版本,并按照Tcl的安装说明自行安装便可。安装完成后,使用ldconfig再次查看:
此时,再次运行make test命令便可。
1、从官网下载和解压源代码
wget
tar xzf redis-2.2.5.tar.gz
cd redis-2.2.5
2、编译,并使用tcmalloc加速
make USE_TCMALLOC=yes
3、启动redis
./redis-server ./redis.conf
4、验证是否在使用tcmalloc
lsof -n |grep tcmalloc
redis-ser 26689 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
redis-ser 26694 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
redis-ser 26697 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
redis-ser 26701 root mem REG 253,3 1800221 4182039 /usr/local/lib/libtcmalloc.so.0.1.0
下面关于Redis的文章您也可能喜欢,不妨参考下:
Ubuntu 14.04下Redis安装及简单测试
Redis主从复制基本配置
Redis集群明细文档
Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis
Redis系列-安装部署维护篇
CentOS 6.3安装Redis
Redis安装部署学习笔记
Redis配置文件redis.conf 详解
Redis 的详细介绍:请点这里
Redis 的下载地址:请点这里
本文永久更新链接地址:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)
