zoukankan      html  css  js  c++  java
  • How to install redis server on CentOS 7 / RHEL 7

    在本教程中,我们将学习如何在CentOS 7 / RHEL 7上安装Redis服务器。 redis的缩写是REmote DIctionary Server。

    它是最流行的开源,高级键值缓存和存储之一。

    reids的官方网站地址: http://redis.io/

    如果你的服务器没有安装wget下载程序的话,需要先安装wget,

    Install wget command:

    yum install wget

    Install redis server

    Now use yum command to install redis server

    yum install redis

    Two important redis server configuration file’s path
    1. /etc/redis.conf
    2. /etc/redis-sentinel.conf

    Now start the redis server after this.

    systemctl start redis.service

    Check the running status of redis server

    systemctl status redis.service

    To test the installation of Redis, use below given command

    If the response output is PONG, it means installation is completed successfully.

    [root@localhost ~]# redis-cli ping
    PONG
    [root@localhost ~]#

    Start/Stop/Restart/Status and Enable redis server

    To start redis server

    systemctl start redis.service

    To stop redis server

    systemctl stop redis.service

    To restart redis server

    systemctl restart redis.service

    To get running status of redis server

    systemctl status redis.service

    To enable redis server at system’s booting time.

    systemctl enable redis.service

    To disable redis server at system’s booting time.

    systemctl disable redis.service

    查看redis是否启动:

    reids-server

    打开redis终端:

    redis-cli

    首次在php中使用redis时,我遇到了class 'Redis' not found的错误,

    $redis = new Redis();

    最后再网上发现需要再Redis前面加上\,

    $redis = new Redis();

    访问远程Redis服务。Connect to Remote Redis Server

    使用客户端远程连接redis

    通常来说,生产环境下的Redis服务器只设置为仅本机访问(Redis默认也只允许本机访问)。有时候我们也许需要使Redi能被远程访问。

    配置

    修改Redis配置文件/etc/redis/redis.conf,找到bind那行配置:

    # bind 127.0.0.1

    去掉#注释并改为:

    bind 0.0.0.0

    指定配置文件然后重启Redis服务即可:

    sudo redis-server /etc/redis/redis.conf

    关于bind配置的含义,配置文件里的注释是这样说的:

    # By default Redis listens for connections from all the network interfaces
    # available on the server. It is possible to listen to just one or multiple
    # interfaces using the "bind" configuration directive, followed by one or
    # more IP addresses.
    #
    # Examples:
    #
    # bind 192.168.1.100 10.0.0.1
    # bind 127.0.0.1

    远程连接

    配置好Redis服务并重启服务后。就可以使用客户端远程连接Redis服务了。命令格式如下:

    $ redis-cli -h {redis_host} -p {redis_port}

    其中{redis_host}就是远程的Redis服务所在服务器地址,{redis_port}就是Redis服务端口(Redis默认端口是6379)。例如:

    $ redis-cli -h 120.120.10.10 -p 6379
    redis>ping
    PONG

  • 相关阅读:
    easyui combobox 的取值问题
    关于Java中集合的讲解~
    面试中经常会被问到的70个问题
    80端口被NT kernel & System 占用pid 4
    java中try{}catch{}和finally{}的执行顺序问题
    Java中基本数据类型的存储方式和相关内存的处理方式(java程序员必读经典)
    String,StringBuffer和StringBuilder三者的讲解
    String是基本的数据类型吗?
    jdk中那些常见的类不能被继承的
    关于java中getClass()和getSuperClass()的讲解
  • 原文地址:https://www.cnblogs.com/ryanzheng/p/9055788.html
Copyright © 2011-2022 走看看