zoukankan      html  css  js  c++  java
  • 阿里云安装Redis教程与相关问题

    Redis

    Redis 安装

    • 本文基于阿里云服务器 centos7 系统

    1.gcc 安装

    -- 执行如下命令
    1. yum install cpp  
    2. yum install binutils
    3. yum install glibc-kernheaders
    4. yum install glibc-common
    5. yum install glibc-devel
    6. yum install gcc
    7. yum install make
    
    -- 备注
    安装成功的话会提示:Complete
    原先已安装完成的会提示:Nothing todo
    

    2.tcl 安装

    Step01.

    在 /usr/local/ 目录下创建自己的文件夹
    cd usr/local/ 
    mkdir matrix/  -- 目录名自定义
    cd matrix/
    

    Step02.

    1.下载 tcl
    wget http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz
    
    2.解压文件
    tar -zxvf tcl8.6.3-src.tar.gz
    
    3.修改文件夹名称
    mv tcl8.6.3 tcl
    
    4.进入tcl目录
    cd tcl/
    

    Step03.

    按以下顺序执行命令
    cd unix/
    ./configure
    make
    make install
    

    3.redis 安装

    # 回到 /usr/local/matrix/ 目录下
    1.下载资源
    wget http://download.redis.io/releases/redis-6.0.3.tar.gz
    
    2.解压
    tar xzf redis-6.0.3.tar.gz
    
    3.切换Redis目录
    cd redis-6.0.3
    
    4.安装
    4.1 make
    make 成功会显示如下信息
    Hint: It's a good idea to run 'make test' ;)
    
    4.2 make test
    make test 成功显示如下信息
    o/ All tests passed without errors!
    
    Cleanup: may take some time... OK
    
    4.3 make install
    redis 安装成功
    Hint: It's a good idea to run 'make test' ;)
    
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install
    
    5.检测是否安装成功
    5.1启动 redis
    (1)src/redis-server &  -- &:表示使redis以后台程序方式运行
    (2)redis-server /usr/local/kencery/redis/redis.conf 
    
    5.2 检测redis默认端口是否在使用中,如在使用则安装程。
    netstat -ntlp grep 6379
    
    5.3 测试
    src/redis-cli
    -- 进行key设值读值检测
    
    5.4 关闭 redis
    src/redis-cli shutdown
    
    6. 修改redis.conf配置
    vi redis.conf
    
    -- 添加密码,找到 requirepass 
    requirepass ****(添加自己的密码)
    
    -- 设置后台开启
    daemonize yes
    
    -- 外部访问
    bind 0.0.0.0
    
    7.修改配置 重启Redis验证
    auth pwd -- 密码访问redis
    exit -- 退出 redis-cli
    

    4.防火墙设置

    由于centos需自行设置,所以redis其他配置完成后还无法访问的话,check 一下防火墙端口设置。

    有的同学可能发现 阿里云服务器安全配置和redis.conf 文件都已配置好了,但是发现还是无法连接Redis,此时检查下服务器的端口是否开放

    -- 查看端口列表
    firewall-cmd --list-port
    
    -- 添加所需开放的redis端口 6479
    firewall-cmd --zone=public --add-port=6379/tcp --permanent
    

    5.遇到的问题

    问题一:

    You need tcl 8.5 or newer in order to run the Redis test make.............
    

    解决办法:

    wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz  
    sudo tar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/  
    cd  /usr/local/tcl8.6.1/unix/  
    sudo ./configure  
    sudo make  
    sudo make install 
    

    问题二:

    ...............
    
    server.c:5170:15: error: ‘struct redisServer’ has no member named ‘maxmemory’
    if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
              ^
    server.c:5170:39: error: ‘struct redisServer’ has no member named ‘maxmemory’
    if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
                                      ^
    server.c:5171:176: error: ‘struct redisServer’ has no member named ‘maxmemory’
        serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory);
                                                                                                                                                                               ^
    server.c:5174:31: error: ‘struct redisServer’ has no member named ‘server_cpulist’
    redisSetCpuAffinity(server.server_cpulist);
                              ^
    server.c: In function ‘hasActiveChildProcess’:
    server.c:1476:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    server.c: In function ‘allPersistenceDisabled’:
    server.c:1482:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    server.c: In function ‘writeCommandsDeniedByDiskError’:
    server.c:3789:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    server.c: In function ‘iAmMaster’:
    server.c:4966:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    make[1]: *** [server.o] Error 1
    make[1]: Leaving directory `/usr/local/redis-6.0.3/src'
    make: *** [all] Error 2
    

    解决办法:

    # 查看gcc版本是否在5.3以上,centos7.6默认安装4.8.5
    gcc -v
    # 升级gcc到5.3及以上,如下:
    升级到gcc 9.3:
    yum -y install centos-release-scl
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
    scl enable devtoolset-9 bash
    需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。
    如果要长期使用gcc 9.3的话:
     
    echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
    这样退出shell重新打开就是新版的gcc了
    以下其他版本同理,修改devtoolset版本号即可。
    

    6.Redis 卸载

    1.删除目录
    rm -rf /usr/local/matrix/redis
    
    2.删除redis相关的命令脚本
    rm -rf /usr/bin/redis-*
    

    7.阿里云配置安全规则

    因需要外部访问服务器上的 Redis 服务,当作开发测试使用,需进行配置

    添加Redis配置规则

    Step01.

    实例

    Step02.

    配置规则

    Step03. (我这里已经配置好了)

    1

    Step04. 选择Redis 保存即可

    Redis 安全规则

    Step05. 完成以上设置后使用 telnet 命令测试访问是否已通

    telent ip port
    
  • 相关阅读:
    [Javascript] Drawing Paths
    [Javascript] Drawing Paths
    [Whole Web] [AngularJS + Grunt] Using ng-html2js to Convert Templates into JavaScript
    [TypeScript] 1. Catching JavaScript Mistakes with TypeScript
    [TypeScript] 0.First Example
    [AngularJS] Introduction to angular-formly
    Runoob-Java:Java String 类
    Runoob-Java:Java Number & Math 类
    Runoob-Java:Java switch case
    Runoob-Java:Java 条件语句
  • 原文地址:https://www.cnblogs.com/blackBlog/p/12924891.html
Copyright © 2011-2022 走看看