search
HomeDatabaseMysql TutorialCentOS 5.9下安装配置redis

CentOS 5.9下安装配置redis

Jun 07, 2016 pm 04:32 PM
centosredisInstallConfiguration

紧接上文,那时候是大三暑假,迷茫着不知该学些什么东西,无意中看见51cto在推荐Nosql的书,有一本叫做《Nosql数据库入门》,感觉这东西好高深,就立即买了本回来研究,研究了半天也没弄明白这东西是干吗的,原来路真是一步一步走的,Mysql都搞不明白,Nosql

紧接上文,那时候是大三暑假,迷茫着不知该学些什么东西,无意中看见51cto在推荐Nosql的书,有一本叫做《Nosql数据库入门》,感觉这东西好高深,就立即买了本回来研究,研究了半天也没弄明白这东西是干吗的,原来路真是一步一步走的,Mysql都搞不明白,Nosql又怎么能理解呢?

一:安装redis

1.安装redis

wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
tar zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make PREFIX=/usr/local/redis install

二:配置redis

1 使用默认配置文件,稍作修改就可以了

a 习惯做法,配置文件放在源码安装的文件夹下,便于管理吧
mkdir /usr/local/redis/etc/
cp redis-2.6.14/redis.conf  /usr/local/redis/etc/
b 修改配置文件 /usr/local/redis/etc/redis.conf
(1)Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程
daemonize yes
(2)当客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能
timeout 300
(3)指定redis日志
logfile /var/log/redis.log
(4)指定本地数据库存放目录
dir  /data/redis/redis_db
c 启动redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

三:测试redis

1 演示一个简单的set key,get key操作...

请先安装php下redis客户端,具体安装参考(https://github.com/nicolasff/phpredis)

<?php
$redis = new Redis();
try{
    $redis->connect('127.0.0.1',6379);
}
catch (Exception $e){
    die("Cannot connect to redis server:".$e->getMessage() );
}
$redis->set('name','budong');
echo $redis->get('name');
?>
输出budong,则说明安装成功.

2 redis可玩性太多了,运维必备查看redis运行信息,如下:

[root@Cache ~]# /usr/local/redis/bin/redis-cli 
redis 127.0.0.1:6379> INFO
部分结果如下:
redis_version:2.4.7
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
gcc_version:4.1.2
process_id:26615
uptime_in_seconds:2717407
uptime_in_days:31
lru_clock:117839
used_cpu_sys:102659.58
used_cpu_user:101565.17
used_cpu_sys_children:125215.15
used_cpu_user_children:807371.44

四:是时候结束了

自言自语:

本篇博客就是自己安装redis的一个脚本的简单回顾,最近各种忙,更多精彩内容,下次继续,先挖坑,后栽树...

参考资料:

redis 官网:http://redis.io/

Redis资料汇总专题: http://blog.nosqlfan.com/html/3537.html

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool