Table of Contents
一:安装redis" >一:安装redis
二:配置redis" >二:配置redis
三:测试redis" >三:测试redis
四:是时候结束了" >四:是时候结束了
Home Database Mysql Tutorial CentOS 5.9下安装配置redis

CentOS 5.9下安装配置redis

Jun 07, 2016 pm 04:32 PM
centos redis Install Configuration

紧接上文,那时候是大三暑假,迷茫着不知该学些什么东西,无意中看见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
Copy after login

二:配置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
Copy after login

三:测试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,则说明安装成功.
Copy after login

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
Copy after login

四:是时候结束了

自言自语:

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

参考资料:

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

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

Statement of this Website
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

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

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Difference between centos and ubuntu Difference between centos and ubuntu Apr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Centos configuration IP address Centos configuration IP address Apr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Centos stops maintenance 2024 Centos stops maintenance 2024 Apr 14, 2025 pm 08:39 PM

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

How to use the Redis cache solution to efficiently realize the requirements of product ranking list? How to use the Redis cache solution to efficiently realize the requirements of product ranking list? Apr 19, 2025 pm 11:36 PM

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

How to view firewall status in centos How to view firewall status in centos Apr 14, 2025 pm 08:18 PM

The state of the CentOS firewall can be viewed through the sudo firewall-cmd --state command, returning to running or not running. For more detailed information, you can use sudo firewall-cmd --list-all to view, including configured areas, services, ports, etc. If firewall-cmd does not solve the problem, you can use sudo iptables -L -n to view iptables rules. Be sure to make a backup before modifying the firewall configuration to ensure server security.

Laravel8 optimization points Laravel8 optimization points Apr 18, 2025 pm 12:24 PM

Laravel 8 provides the following options for performance optimization: Cache configuration: Use Redis to cache drivers, cache facades, cache views, and page snippets. Database optimization: establish indexing, use query scope, and use Eloquent relationships. JavaScript and CSS optimization: Use version control, merge and shrink assets, use CDN. Code optimization: Use Composer installation package, use Laravel helper functions, and follow PSR standards. Monitoring and analysis: Use Laravel Scout, use Telescope, monitor application metrics.

See all articles