您的位置:首页 > 数据库 > Redis

【环境准备】centos 6.5 安装redis 源码安装

2017-08-02 21:51 260 查看
CentOS6.5下redis安装部署配置 

1、Redis的安装目录创建进入

[root@localhost /]# mkdir redisServer && cd redisServer

1.2、redis下载

[root@localhost redisServer]# wget http://download.redis.io/releases/redis-3.0.5.tar.gz
1.3、解压

[root@localhost redisServer]# tar xf redis-3.0.5.tar.gz

这样就在当前目录下新建了一个包含发行版源代码的目录,必须cd进入这个目录以继续服务器的编译。

1.4、编译及安装

进入redis解压目录,执行如下命令编译Redis:

[root@localhost

redis-3.0.5]# cd redis-3.0.5 

[root@localhost redis-3.0.5]# make && make install

1.5、配置 [也可以直接启动]

接着,复制redis.conf到/etc/下,修改配置文件,来配置Redis服务器。

1 [root@localhost redis-3.0.5]# cp redis.conf /etc/

1.6、参数参看

1234567891011121314 [root@localhost redis-3.0.5]# redis-server --help 

Usage: ./redis-server [/path/to/redis.conf] [options] 

  ./redis-server - (read config from stdin) 

  ./redis-server -v or --version 

  ./redis-server -h or --help 

  ./redis-server --test-memory <megabytes> 

Examples: 

  ./redis-server (run the server with default conf) 

  ./redis-server /etc/redis/6379.conf 

  ./redis-server --port 7777 

  ./redis-server --port 7777 --slaveof 127.0.0.1 8888 

  ./redis-server /etc/myredis.conf --loglevel verbose 

Sentinel mode: 

  ./redis-server /etc/sentinel.conf --sentinel

1.7、版本参看  

[root@localhost redis-3.0.5]# redis-server -v 

Redis server v=3.0.5 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=ee8d4e51452e5879

1.8、启动Redis服务器

[root@localhost redis-3.0.5]# redis-server /etc/redis.conf

注:此命令仅有一个启动参数,指定/path/to/redis.conf目录下的配置文件,不加参数执行默认配置。

[root@localhost ~]# redis-cli ping  

PONG

测试启动 redis-cli ping 返回PONG,启动成功。

[root@localhost ~]# netstat -tulnp | grep 6379 

tcp        0      0 0.0.0.0:6379                0.0.0.0:*                  LISTEN      11731/redis-server  

tcp        0      0 :::6379                    :::*                        LISTEN      11731/redis-server

 

1.9、停止Redis

关闭服务

[root@localhost ~]# redis-cli shutdown 

[root@localhost ~]# netstat -tulnp | grep 6379 

[root@localhost ~]# redis-cli ping  

Could not connect to Redis at 127.0.0.1:6379: Connection refused

注:可指定端口:redis-cli -p <port> shutdown

1.10、连接Redis

两种链接redis的方法:

方法一、

[root@localhost ~]# redis-cli      #也可以指定ip,端口号启动redis(redis-cli -h 192.168.1.2 -p 6379) 

127.0.0.1:6379>  

127.0.0.1:6379> quit

方法二、

[root@localhost ~]# telnet 192.168.1.2 6379 

Trying 192.168.1.2... 

Connected to 192.168.1.2. 

Escape character is '^]'. 

quit 

+OK 

Connection closed by foreign host
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: