centos快速安装redis部署

星期二, 2015-06-16 | Author: Lee | linux, webgame | 3,365 views

每次部署环境的时候都要去安装下,写下文章记录下:
官方快速引导地址:http://redis.io/topics/quickstart

这里只是安装单实例版本,默认是6379的端口版本,预留配置文件等做多实例部署

1.安装redis最新的3.0.2版本

$ wget http://download.redis.io/releases/redis-3.0.2.tar.gz
$ tar xvzf redis-3.0.2.tar.gz
$ cd redis-3.0.2
$ make

2.复制执行文件到bin下(或者执行make install),若执行make test 请先yum install tcl

$ cp src/redis-server /usr/local/bin/
$ cp src/redis-cli /usr/local/bin/

3.配置对应的启动参数

$ sudo mkdir /etc/redis
$ sudo mkdir /var/redis
$ sudo cp utils/redis_init_script /etc/init.d/redis_6379
$ sudo vi /etc/init.d/redis_6379
 可以修改对应端口,若不修改直接跳过
$ sudo cp redis.conf /etc/redis/6379.conf
$ sudo mkdir /var/redis/6379
$ sudo vi /etc/redis/6379.conf
修改daemonize no改成yes (变成服务启动)

4.启动服务

/etc/init.d/redis_6379 start

5.配置防火墙打开对应的端口:

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT
 重启防火墙
 
service iptables restart

6.使用redis-cli登录测试

$ redis-cli 
127.0.0.1:6379> set key 100
OK 
127.0.0.1:6379> get key 
"100" 
127.0.0.1:6379> exists key 
(integer) 1

7.对应参数简要说明 为/etc/redis/6379.conf
Edit the configuration file, making sure to perform the following changes:
Set daemonize to yes (by default it is set to no).
Set the pidfile to /var/run/redis_6379.pid (modify the port if needed).
Change the port accordingly. In our example it is not needed as the default port is already 6379.
Set your preferred loglevel.
Set the logfile to /var/log/redis_6379.log
Set the dir to /var/redis/6379 (very important step!)

Tags: , , ,

文章作者: Lee

本文地址: https://www.pomelolee.com/1471.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta