redhat 下Redis安装/卸载

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安装为开机启动的服务。
相关安装提示信息如下:

[root@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

启动并检查是否运行的例子:

[root@localhost ~]# service redis_6379 start
Starting Redis server...
[root@localhost ~]#
[root@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
[root@localhost ~]# service redis_6379 stop
Stopping ...
Redis stopped
[root@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.cnblogs.com/buzzlight/p/logstash_elasticsearch_kibana_log.html

 

简单连接服务器的测试例子:

[root@localhost src]# pwd
/opt/redis-2.8.5/src
[root@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
[root@localhost src]#








redis卸载

根据redis源码包里面的README的说明

In order to install Redis binaries into /usr/local/bin just use:
    % make install
You can use "make PREFIX=/some/other/directory install" if you wish to use a
different destination.

redis会在/usr/local/bin或你指定的目录下产生下面几个文件

  1. redis-benchmark 
  2. redis-check-aof 
  3. redis-check-dump 
  4. redis-cli 
  5. redis-server
首先把redis-server停了,然后把文件删除就行了.


停止redis服务:
src/redis-cli shutdown

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值