zoukankan      html  css  js  c++  java
  • ubuntu16.04 安装redis

    安装redis

    apt-get install redis-server

    查看是否启动

    netstat -nlt|grep 6379

    修改Redis的配置

    使用redis

    默认情况下,访问Redis服务器是不需要密码的,为了增加安全性我们需要设置Redis服务器的访问密码。设置访问密码为redisredis。

    用vi打开Redis服务器的配置文件redis.conf

    sudo vi /etc/redis/redis.conf
    #取消注释requirepass
    requirepass redisredis
    
    
    sudo gedit /etc/redis/redis.conf
    #注释bind
    #bind 127.0.0.1

    修改后,重启Redis服务器。

     
    sudo /etc/init.d/redis-server restart
    Stopping redis-server: redis-server
    Starting redis-server: redis-server.

    未使用密码登陆Redis服务器,发现可以登陆,但无法执行命令了。

    redis-cli
    
    redis 127.0.0.1:6379> keys *
    (error) ERR operation not permitted

    登陆Redis服务器,输入密码

    redis-cli -a redisredis
    
    redis 127.0.0.1:6379> keys *
    1) "key2"
    2) "key3"
    3) "key4"

    检查Redis服务器占用端口

    netstat -nlt|grep 6379
    tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN

    我们看到网络监听从之前的 127.0.0.1:3306 变成 0 0.0.0.0:3306,表示Redis已经允许远程登陆访问。

    我们在远程的另一台Linux访问Redis服务器

    redis-cli -a redisredis -h 192.168.1.199
    
    redis 192.168.1.199:6379> keys *
    1) "key2"
    2) "key3"
    3) "key4"
    作者:xyyhqq

    -------------------------------------------

    Never Stop !

  • 相关阅读:
    MapReduce Shuffle 和 Spark Shuffle 原理概述
    Kafka生产消费API JAVA实现
    Kylin引入Spark引擎
    CentOS 下安装 Cmake 步骤
    TP5 使用验证码功能
    连接树莓派中的MySQL服务器
    用 PHP 函数变量数组改变代码结构
    表的优化
    Wamp 下运行 CGI 笔记
    PHP 中的关于 trait 的简单
  • 原文地址:https://www.cnblogs.com/xyyhcn/p/10278650.html
Copyright © 2011-2022 走看看