zoukankan      html  css  js  c++  java
  • Linux安装redis数据库及添加环境变量

    1.下载安装包

    [root@localhost opt]# yum install wget
    [root@localhost opt]# wget http://download.redis.io/releases/redis-4.0.13.tar.gz
    

    2.解压安装包

    [root@localhost opt]# tar xzf redis-4.0.13.tar.gz
    [root@localhost opt]# ls
    

    3.切换到安装目录

    [root@localhost opt]# cd redis-4.0.13
    [root@localhost redis-4.0.13]# ls
    

    4.编译安装

    [root@localhost redis-4.0.13]# make
    

    5.启动redis服务

    [root@localhost redis-5.0.3]# src/redis-server redis.conf
    

    6.添加环境变量

    [root@localhost src]# vi ~/.bash_profile
    
    # .bash_profile
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    	. ~/.bashrc
    fi
    
    # User specific environment and startup programs
    export REDIS_HOME=/opt/redis-5.0.3/
    export PATH=$PATH:$REDIS_HOME/src
    
    #PATH=$PATH:$HOME/bin
    #export PATH
    

    7.使环境变量生效

    source ~/.bash_profile
    

    8.测试,在任何位置登录redis

    [root@localhost ~]# redis-server
    [root@localhost ~]# redis-cli
    127.0.0.1:6379> ping
    PONG
    127.0.0.1:6379> set name apollo
    OK
    127.0.0.1:6379> get name
    "apollo"
    

    9.启动redis客户端

    #1.登录本机redis
    [root@localhost redis-5.0.3]# src/redis-cli
    #2.指定服务器ip(不指定时,默认本机)
    [root@localhost redis-5.0.3]# src/redis-cli -h 127.0.0.1
    #3.指定端口(不指定时,默认6379)
    redis-cli -h 127.0.0.1 -p 6378
    

    10. 安装过程遇到问题

    1.若出现如下提示,则说明未安装gcc,使用命令安装yum -y install gcc gcc-c++ libstdc++-devel

    [root@localhost redis-4.0.11]# make
    cd src && make all
    make[1]: Entering directory `/root/redis-4.0.11
    
    /src‘ CC adlist.o /bin/sh: cc: command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory `/root/redis-2.8.17/src‘ make: *** [all] Error 2
    

    2.若出现如下提示,则将make改为make MALLOC=libc,推测是因为编译库的问题。

    [root@localhost redis-4.0.11]# make
    cd src && make all
    make[1]: Entering directory `/root/redis-2.8.17/src‘
        CC adlist.o
    In file included from adlist.c:34:
    zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
    zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
    make[1]: *** [adlist.o] Error 1
    make[1]: Leaving directory `/root/redis-2.8.17/src‘
    make: *** [all] Error 2
    
  • 相关阅读:
    动手动脑(类与对象作业再次提交)
    论团队(类与对象邮箱作业再次提交)
    流于形式的沟通
    加密
    string类中一些方法的使用
    StringEquals的用法
    命令行接收数字求和
    计算机思维
    SpringBoot之Callable处理异步请求
    MySQL8.0 zip版本 安装
  • 原文地址:https://www.cnblogs.com/apollo1616/p/10422578.html
Copyright © 2011-2022 走看看