惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
博客园 - 叶小钗
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
博客园_首页
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)
Help Net Security
Help Net Security
Cloudbric
Cloudbric
AI
AI
N
News | PayPal Newsroom
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
Forbes - Security
Forbes - Security
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
SecWiki News
SecWiki News
H
Heimdal Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
V
V2EX
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
S
Security Affairs
L
LangChain Blog
The Hacker News
The Hacker News
F
Full Disclosure
aimingoo的专栏
aimingoo的专栏
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
Webroot Blog
Webroot Blog
A
About on SuperTechFans
H
Hacker News: Front Page
Cyberwarzone
Cyberwarzone
WordPress大学
WordPress大学
L
LINUX DO - 热门话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Attack and Defense Labs
Attack and Defense Labs
M
MIT News - Artificial intelligence

博客园 - herobeast

hadoop 2.7.1 高可用安装部署 MySql篇 Tomcat篇 JDK篇 web一次下载多个附件 Implementing a Custom Security Manager(翻译) 腾达路由器设置 正则表达式 jQuery Resizable笔记 OSGi规范 OSGi bundle 与 fragment OSGi bundle之间互相通信的方法 Apache CXF 分布式OSGi部署HelloWorld 五米测试 Spring.DM web 开发环境搭建 Spring.DM版HelloWorld 腾讯资深产品经理谈敏捷开发于游戏 js矢量图类库:Raphaël—JavaScript Library 关于生成id的问题
Redis篇
herobeast · 2015-09-23 · via 博客园 - herobeast

一:下载redis

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

    如果系统没有安装make,请查看mysql篇

  1. wget http://download.redis.io/redis-stable.tar.gz
  2. tar xzf redis-stable.tar.gz
  3. cd redis-stable
  4. make MALLOC=libc
  5. make install

Redis默认支持16个数据库,不同的应用应该使用不同的Redis实例存储数据。由于Redis非常轻量级,一个空Redis实例占用的内存只有1MB左右,所以不用担心多个Redis实例会占用很多内存。

二、测试是否安装成功

注意:redis服务默认端口号是6379,请设置防火墙保持该端口可以访问,设置好后可以在客户端使用telnet命令测试

  1. telnet 172.19.32.xx 6379

启动redis服务

  1. redis-server

也可以使用下面的

  1. redis-server redis.conf

关闭服务

  1. redis-cli SHUTDOWN

(//停止Redis,Redis收到SHUTDOWN命令后,会先断开所有客户端连接,然后根据配置执行持久化,最后完成退出,“kill Redis进程PID”也可以正常结束)

使用客户端测试

  1. redis-cli -h 127.0.0.1 -p 6379

或者使用下面的命令测试

  1. redis-cli PING

如果接收到PONG说明一切正常,客户端请求收到服务端的响应。

参考:

http://blog.csdn.net/rachel_luo/article/details/8858250

首先拷贝一份redis.conf,到/etc下,做为服务启动配置

  1. cp redis.conf /etc

配置启动init脚本(install的时候,redis的命令会被拷贝到/usr/local/bin下面)

  1. # chkconfig: 2345 90 10
  2. # description: Redis is a persistent key-value database
  3. PATH=/usr/local/bin:/sbin:/usr/bin:/bin
  4. REDISPORT=6379
  5. EXEC=/usr/local/bin/redis-server
  6. REDIS_CLI=/usr/local/bin/redis-cli
  7. PIDFILE=/var/run/redis.pid
  8. CONF="/etc/redis.conf"
  9. case "$1" in
  10. start)
  11. if [ -f $PIDFILE ]
  12. then
  13. echo "$PIDFILE exists, process is already running or crashed"
  14. else
  15. echo "Starting Redis server..."
  16. $EXEC $CONF
  17. fi
  18. if [ "$?"="0" ]
  19. then
  20. echo "Redis is running..."
  21. fi
  22. ;;
  23. stop)
  24. if [ ! -f $PIDFILE ]
  25. then
  26. echo "$PIDFILE does not exist, process is not running"
  27. else
  28. PID=$(cat $PIDFILE)
  29. echo "Stopping ..."
  30. $REDIS_CLI -p $REDISPORT SHUTDOWN
  31. while [ -x ${PIDFILE} ]
  32. do
  33. echo "Waiting for Redis to shutdown ..."
  34. sleep 1
  35. done
  36. echo "Redis stopped"
  37. fi
  38. ;;
  39. restart|force-reload)
  40. ${0} stop
  41. ${0} start
  42. ;;
  43. *)
  44. echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
  45. exit 1
  46. esac
  47. ##############################

把上述代码存为redis,放到/etc/init.d/下面

可以使用下面的命令

  1. vi /etc/init.d/redis

然后把上面的代码拷贝上去,然后保存就可以了,然后设置文件的权限

  1. chmod +x /etc/init.d/redis

设置为开机启动(注意:redis文件中前两行注释代码是必须的,否则下面的命令会报:redis 服务不支持 chkconfig,错误

  1. chkconfig redis on

启动停止服务

  1. service redis start #或者 /etc/init.d/redis start
  2. service redis stop #或者 /etc/init.d/redis stop

测试服务

  1. redis-cli
  2. redis 127.0.0.1:6379> set foo 123
  3. OK
  4. redis 127.0.0.1:6379> get foo
  5. "123"
  6. redis 127.0.0.1:6379> exit