码迷,mamicode.com
首页 > 其他好文 > 详细

如何在liunx部署redis

时间:2017-09-15 02:06:37      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:目录   cin   退出   str   boot   测试   pts   ice   cells   

下载

    所有版本的下载地址:http://download.redis.io/releases/

先安装下载工具:wget

yum  install –y wget

wget http://download.redis.io/releases/redis-3.2.7.tar.gz

解压缩

tar –zxvf  redis-3.2.7.tar.gz

编译

前提条件:需要gcc编译器

yum  install –y gcc-c++

make

如果报错,加参数再执行make

make MALLOC=libc

安装

可以指定安装的路径:

make install  PREFIX=/usr/local/redis

启动服务

执行这个文件就可以!

 

./redis-server

 

退出:ctrl+c

 

指定配置文件启动服务

举例:以守护进程方式启动

需要指定一个配置文件

可以复制解压缩文件里的redis.conf文件(/root/redis-3.2.9/redis.conf)

 

创建一个目录保存配置文件

mkdir /usr/local/redis/conf

 

复制到创建的目录下

cp /root/redis-3.2.9/redis.conf /usr/local/redis/conf/

 

进入该目录:

cd /usr/local/redis/conf/

 

修改redis.conf文件

vi redis.conf

 

启动服务为守护进程

   ./redis-server  ../conf/redis.conf

        

   查看进程:

        

[root@redis bin]# ps aux | grep redis

root      4284  0.1  0.1  30000  1868 ?        Ssl  10:51   0:00 ./redis-server 127.0.0.1:6379   

root      4288  0.0  0.0   4360   764 pts/0    S+   10:53   0:00 grep redis

使用自带的客户端连接服务

./redis-cli

 

     退出客户端:

         quit

        

关闭服务:

[root@redis bin]# ./redis-cli shutdown

 

开机自启动

         vi /etc/rc.local

         添加一行:

         /usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf

 

         可以重启系统: reboot测试是否能开机自启动!!

 

 

Redis客户端

Redis-cli                    命令行

Redis-desktop-manage    图形化

官网:https://redisdesktop.com/

下载页面:https://redisdesktop.com/download

安装就是下一步即可!!

打开软件:配置需要连接的服务器 (But 但是连接不上 是不是,需要开起防火墙)

 

连接失败的原因:为在服务器开启端口

1,         开启服务器的防火墙vi /etc/sysconfig/iptables

2,        开起端口号 6379

3,         重启防火墙:[root@redis bin]# service iptables restart

4,         Redis的配置文件里需要绑定实际的ip地址

5,    重启redis服务器:

[root@redis bin]# ./redis-cli shutdown

[root@redis bin]# ./redis-server redis.conf

 

连接成功

如何在liunx部署redis

标签:目录   cin   退出   str   boot   测试   pts   ice   cells   

原文地址:http://www.cnblogs.com/weiyuanquyu/p/7523752.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!