zoukankan      html  css  js  c++  java
  • 【Redis学习之三】Redis单节点安装

    本文介绍两个版本:redis-2.8.18.tar.gz 和 redis-3.0.0-rc2.tar.gz,均采用源码安装方式

    一、redis3.0

    部署环境
      redis-3.0.0-rc2.tar.gz
      VM虚拟机redhat6.5-x64:192.168.1.101
      Xshell4

    安装步骤
    1、安装依赖
    gcc
    zlib
    openssl
    ruby :http://www.cnblogs.com/xuliangxing/p/7132656.html?utm_source=itdadao&utm_medium=referral
    rubygems :https://www.cnblogs.com/xuliangxing/p/7133544.html

    二、解压
    [cluster@PCS101 local]$ tar -zxvf redis-3.0.0-rc2.tar.gz -C /usr/local

    三、编译 安装

    [cluster@PCS101 local]$ cd /usr/local/redis-3.0.0 && make && make install

    四、创建配置文件、执行文件目录 拷贝文件

    [cluster@PCS101 local]$ mkdir -p /usr/local/redis/etc && mkdir -p /usr/local/redis/bin
    [cluster@PCS101 local]$ mv /usr/local/redis-3.0.0/redis.conf /usr/local/redis/etc/
    [cluster@PCS101 local]$ cd /usr/local/redis-3.0.0/src/ && mv mkreleasdhdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server /usr/local/redis/bin


    五、修改配置

    [cluster@PCS101 local]$ vim /usr/local/redis/etc/redis.conf

    daemonize属性改为yes 设置后台启动


    六、启动 关闭
    服务端启动,根据配置文件启动

    [cluster@PCS101 local]$ /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

    客户端启动:

    [cluster@PCS101 local]$ /usr/local/redis/bin/redis-cli

    客户端命令:
    关闭服务端:输入 shutdown
    退出客户端:输入 quit

    验证:ps -ef |grep redis

    参考:
    https://www.cnblogs.com/wangchunniu1314/p/6339416.html
    https://www.cnblogs.com/hello-daocaoren/p/8431902.html

    -------------------------------------------------------------------------------------------
    二、redis2.0
    环境
      虚拟机:VMware 10
      Linux版本:CentOS-6.5-x86_64
      客户端:Xshell4
      FTP:Xftp4
      jdk8
    安装步骤
    1、下载gcc,tcl 命令编译器

    [cluster@PCS101 local]$ yum -y install gcc tcl

    2、解压

    [cluster@PCS101 local]$ tar -zxvf redis-2.8.18.tar.gz -C /usr/local

    3、编译、安装

    [cluster@PCS101 local]$ cd redis-2.8.18 && make && make PREFIX=/opt/wjy/redis install

    4、配置环变:

    export REDIS_PREFIX=/opt/wjy/redis

    5、重新加载配置文件:

    [cluster@PCS101 local]$. /etc/profile 

    6、安装redis服务实例,配置端口、实例、配置文件、日志、持久化数据目录、执行路径配置

    [cluster@PCS101 local]$ /usr/local/redis-2.8.18/utils/install_server.sh

    enter执行 、ctrl+c退出

    [root@PCS101 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] 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 [/opt/wjy/redis/bin/redis-server] 
    Selected config:
    Port           : 6379
    Config file    : /etc/redis/6379.conf
    Log file       : /var/log/redis_6379.log
    Data dir       : /var/lib/redis/6379
    Executable     : /opt/wjy/redis/bin/redis-server
    Cli Executable : /opt/wjy/redis/bin/redis-cli
    Is this ok? Then press ENTER to go on or Ctrl-C to abort.
    Copied /tmp/6379.conf => /etc/init.d/redis_6379
    Installing service...
    Successfully added to chkconfig!
    Successfully added to runlevels 345!
    Starting Redis server...
    Installation successful!

    7、启动客户端:redis-cli

    [root@PCS103 ~]# redis-cli -c -h 192.168.1.101 -n 0

    -c 集群模式 

    -h 指定主机

    -p 指定端口

    -n 指定登录哪个redis库   redis总共有16个库:0-15

    8、使用帮助:
    utils目录下: redis-cli -h redis-server -h

    9、可视化客户端:RedisDesktopManager

  • 相关阅读:
    hihocoder 1049 后序遍历
    hihocoder 1310 岛屿
    Leetcode 63. Unique Paths II
    Leetcode 62. Unique Paths
    Leetcode 70. Climbing Stairs
    poj 3544 Journey with Pigs
    Leetcode 338. Counting Bits
    Leetcode 136. Single Number
    Leetcode 342. Power of Four
    Leetcode 299. Bulls and Cows
  • 原文地址:https://www.cnblogs.com/cac2020/p/9529539.html
Copyright © 2011-2022 走看看