虚拟机Ubuntu安装redis并链接的使用记录

Redis安装记录
  1. 进入官网:https://redis.io/download/

  2. 下载安装包redis-7.2.4.tar.gz,并解压,进入解压后的目录

    
    wget http://download.redis.io/releases/redis-7.2.4.tar.gz
    tar xzf redis-7.2.4.tar.gz
    cd redis-5.0.2
    make
    cd src
    make install PREFIX=/opt/redis
    make test
    redis-server
    
  3. 虚拟机里部署2个环境,

    1. Ubuntu :ubuntu-22.04.4-desktop-amd64.iso 版本,
    2. Linux :CentOS-7-x86_64-Everything-2009.iso版本
遇到的问题
  • 执行make提示’make’ 不是内部或外部命令,也不是可运行的程序
    或批处理文件。

    • 原因:redis是C++编写,依赖gcc
    • 解决办法:安装gcc。执行yum命令
  • 执行yum命令提示’yum’ 不是内部或外部命令,也不是可运行的程序

    • 原因:yum命令,是一个在Linux发行版上用于包管理的工具

    • 办法:Linux安装gcc办法

    • 结果:安装gcc之后还是无法执行make。需要继续执行sudo apt install make。成功后执行make解决

  • 执行make install PREFIX=/opt/redis提示pkg-config: not found 无法创建目录 “/opt/redis”权限不够

    • 原因: '‘pkg-config: not found’'是因为pkg包分配错误的原因
    • 办法:执行 ”sudo apt-get install pkg-config“
    • 结果:执行之后,选择Y提示"无法下载…,文件尺寸不符的问题。您使用的镜像正在同步?" 提示我有几个软件包无法下载,然后我执行“sudo apt-get update" 然后继续执行”sudo apt-get install pkg-config“,就成功了!
  • 执行“make test" 提示 couldn’t open “home/mwq/{乱码*}/redis-7.0.15/tests/tmp/server.3572.7/appendonlydir/appendonly.aof.maifest”:no suchfile or directory while executing

    • 原因:似乎是安装路径包含中文导致

    • 办法:一开始我按照网上办法执行“sudo make distclean” ,然后继续“make test",还是提示失败

      然后我自己分析可能是中文路径导致,我马上新建了英文路径转移了redis-7.0.15。继续执行“make test",这次执行了很长时间,过了短时间,我单独开终端执行“redis-server"是提示成功的

    • 结果:过了10分钟,还是提示错误,但是redis服务应该是正常开启了???这是啥情况谁能告诉我。

  • Redis难以在windows上面安装

    • 原因:大部分Redis安装在Linux上面,windows上面要特殊版本
    • 办法:
  • Redis查看服务是否成功。

    • 办法:找到“redis-cli”所在目录,执行“./redis-cli"查看服务是否成功。执行exit可退出
  • 关闭Redis

    • 办法:redis-cli shutdown 或者 redis-cli -h 127.0.0.1 -p 6379 shutdown
  • 指定配置文件启动redis

    • 办法:sudo redis-server /etc/redis/redis.conf
  • 查看redis服务器进程

  • 办法: ps -ef | grep ps 、 aux | grep redis 注意空格

  • 启动redis

    • 办法:redis-server、 redis-cli 、 redis-cli -h ip地址 、 redis-cli -p 端口号
  • Redis基础命令集详解

  • 链接虚拟机里部署的Redis失败,执行“telnet 192.168.239.128 6379",提示

    -DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
    
    • 办法:找到配置文件 redis.conf。修改 protected-mode yes 改成protected-mode no,保护模式关闭。然后找到“bind 127.0.0.1" 改成”# bing 127.0.0.1" 把这个Ip绑定注释掉。然后重启redis服务,注意要按照配置文件重启”./redis-server …/redis.conf“。这个时候就能链接了
  • 9
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值