设为首页 收藏本站
查看: 833|回复: 0

[经验分享] redhat 下Redis安装

[复制链接]

尚未签到

发表于 2015-7-21 13:11:33 | 显示全部楼层 |阅读模式
  Redis 官网:http://redis.io/  下载地址: http://redis.io/download
  安装方法:
  
cd opt
wget http://download.redis.io/releases/redis-2.8.5.tar.gz
tar -zxf redis-2.8.5.tar.gz
cd redis-2.8.5
make
sudo make install

  make 完成后,Src目录下的redis-server和redis-cli两个命名就是redis服务端和客户端的应用程序,这两个命令可以直接调用。
  可以通过redis源代码里utils/install_server下的脚本简化配置工作

cd utils
sudo ./install_server.sh

  install_server.sh在问你几个问题后会把redis安装为开机启动的服务。
相关安装提示信息如下:
  [iyunv@localhost utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server
  Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
s#^port [0-9]{4}$#port 6379#;s#^logfile .+$#logfile /var/log/redis_6379.log#;s#^dir .+$#dir /var/lib/redis/6379#;s#^pidfile .+$#pidfile /var/run/redis_6379.pid#;s#^daemonize no$#daemonize yes#;
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
./install_server.sh: line 178: update-rc.d: command not found
exists, process is already running or crashed
Installation successful!
  
  我们对/etc/init.d/redis_6379进行修改,只有要“\n”删除并且输入回车,修改完毕后,保存。
  主要是修改下面部分:
  #/bin/sh
#Configurations injected by install_server below....
  EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF="/etc/redis/6379.conf"
  REDISPORT="6379"
  ###############
  
  启动服务:
  service redis_6379 start
  启动并检查是否运行的例子:
  [iyunv@localhost ~]# service redis_6379 start
Starting Redis server...
[iyunv@localhost ~]#
[iyunv@localhost ~]# ps -ef | grep 6379
root      4817     1  0 19:38 ?        00:00:00 /usr/local/bin/redis-server *:6379
root      4821  4744  0 19:38 pts/1    00:00:00 grep 6379
[iyunv@localhost ~]# service redis_6379 stop
Stopping ...
Redis stopped
[iyunv@localhost ~]# ps -ef | grep 6379
root      4837  4744  0 19:39 pts/1    00:00:00 grep 6379
  
  参考:
  http://www.dzend.com/forum.php?mod=viewthread&tid=19
  
  这里install_server.sh这个脚本, 但是执行的过程中提示“update-rc.d” command not found。
  是因为 这个update-rc.d跟redhat系里面的chkconfig作用一样, 把/etc/init.d目录下的某个服务起停脚本加到系统的runlevel中去。
  http://blog.chinaunix.net/uid-20788470-id-3086885.html
  
  当然也可以通过下面的命令行来启动/停止服务

sudo /etc/init.d/redis_ start/end

  启动redis客户端来验证安装

redis-cli
> keys *
  参考:
  http://www.iyunv.com/buzzlight/p/logstash_elasticsearch_kibana_log.html
  
  简单连接服务器的测试例子:
  [iyunv@localhost src]# pwd
/opt/redis-2.8.5/src
[iyunv@localhost src]# ./redis-cli
127.0.0.1:6379> set ghj 234
OK
127.0.0.1:6379> get ghj
"234"
127.0.0.1:6379> del ghj
(integer) 1
127.0.0.1:6379> get ghj
(nil)
127.0.0.1:6379> exit
[iyunv@localhost src]#

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-89105-1-1.html 上篇帖子: Redis实战之征服 Redis + Jedis + Spring (二) 下篇帖子: Spring 整合Redis 出现 afterPropertiesSet signature: ()V) Incompatible argument to fu
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表