Ubuntu安装redis

http://blog.51yip.com/nosql/1725.html

  1. apt-get install ruby
    gem install redis
  2. 安装需要的包 gcc tcl
    sudo apt-get install gcc
    sudo apt-get install tcl
  3. 下载redis-3.0.3
    wget http://download.redis.io/releases/redis-3.0.3.tar.gz
    tar -zxvf redis-3.0.3.tar.gz
    cd redis-3.0.2
    apt-get install make
    make && make install
    cd src/
    cp redis-trib.rb /usr/local/bin
  4. 配置redis
    [root@slave2 redis-3.0.0]# vim redis.conf //解压的根目录,有redis.conf,做以下修改
port 6379  
pidfile /var/run/redis-6379.pid  
dbfilename dump-6379.rdb  
appendfilename "appendonly-6379.aof"  
cluster-config-file nodes-6379.conf  
cluster-enabled yes  
cluster-node-timeout 5000  
appendonly yes  

cp redis.conf /etc/redis/redis-6379.conf
# cp redis.conf /etc/redis/redis-6380.conf
# cp redis.conf /etc/redis/redis-6381.conf
# sed -i "s/6379/6380/g" /etc/redis/redis-6380.conf
# sed -i "s/6379/6381/g" /etc/redis/redis-6381.conf
cat redis-6380.conf |awk '{if($0 !~ /^$/ && $0 !~ /#/) {print $0}}' |grep 6380
5. 启动redis
./redis-server /etc/redis/redis-6379.conf > /var/log/redis/redis-6379.log 2>&1 &
# redis-server /etc/redis/redis-6380.conf > /var/log/redis/redis-6380.log 2>&1 &
# redis-server /etc/redis/redis-6381.conf > /var/log/redis/redis-6381.log 2>&1 &
6. 查看是否运行
netstat -tpnl |grep redis
ps -ef|grep redis
7. 创建redis集群
./redis-trib.rb create 192.168.121.128:6379 192.168.121.128:6380 192.168.121.128:6381

        +    create,表示创建一个新的集群。
        +    选项 --replicas 1 表示为集群中的每个主节点创建一个从节点。
        + 其余参数则是新建集群中实例的地址列表。

8. 查看redis集群状态
redis-trib.rb check 192.168.10.219:6379
redis-cli -c -p 6379 -h 192.168.10.219
./redis-cli -p 9014 cluster nodes

你可能感兴趣的:(Ubuntu安装redis)