在本教程中,我们将学习如何在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
redis>ping
PONG

How to install redis server on CentOS 7 / RHEL 7的更多相关文章

  1. Install RabbitMQ server in CentOS 7

    About RabbitMQ RabbitMQ is an open source message broker software, also sometimes known as message-o ...

  2. Official online document, install svn server in centOS

    http://www.krizna.com/centos/install-svn-server-on-centos-6/

  3. Install Jetty web server on CentOS 7 / RHEL 7

    http://www.eclipse.org/jetty/download.html http://www.eclipse.org/jetty/documentation/current/startu ...

  4. Install Tomcat 6 on CentOS or RHEL --转载

    source:http://www.davidghedini.com/pg/entry/install_tomcat_6_on_centos This post will cover installa ...

  5. Install EPEL repo on CentOS 7 / RHEL 7

    On CentOS 7, we have found without downloading the epel-release RPM package(as we used to do on prev ...

  6. 虚拟机centOS中安装Redis,主机Redis Destop Manager不能访问虚拟机Redis server的解决方案

    今天在学些redis的时候碰到个问题,发现主机Redis Destop Manager不能访问虚拟机Redis server的解决方案,找了一些网上的资料,原因可能有两个,整理记录下来: 1. Red ...

  7. How to install Redis 3.2 on CentOS 6 and 7

    What is Redis? Redis is a flexible open-source, key value data store, used as a database, cache and ...

  8. Install Redis on CentOS 6.4--转

    Install Redis on CentOS 6.4 source:http://thoughts.z-dev.org/2013/05/27/install-redis-on-centos-6-4/ ...

  9. Install TightVNC Server in RHEL/CentOS and Fedora to Access Remote Desktops

    Virtual Networking Computing (VNC) is a Kind of remote sharing system that makes it possible to take ...

随机推荐

  1. C-C++字符输出时遇到字符'\n','\0'区别

    #include "iostream" #include "stdio.h" #include "stdio_ext.h" #include ...

  2. log4cxx安装使用

    log4cxx安装使用 log4cxx现在是apache的一个项目,用来记录日志.看名字就知道,是给c++使用的. 环境(在以下2个环境中进行验证测试): gcc (Ubuntu 4.8.4-2ubu ...

  3. 一键部署LNMP堆栈Web应用基础架构

    https://market.azure.cn/Vhd/Show?vhdId=9852&version=10884 产品详情 产品介绍LEMP/LNMP 是指一组通常一起使用来运行动态网站或者 ...

  4. BZOJ 1806: [Ioi2007]Miners 矿工配餐

    ime Limit: 10 Sec  Memory Limit: 64 MBSubmit: 910  Solved: 559[Submit][Status][Discuss] Description ...

  5. SAP Cloud for Customer的Account Team里的role如何配置

    Account Team标签页里点击Add按钮: 这些下拉菜单里的role在哪里配置? 在business configuration工作中心:Implementation projects-> ...

  6. .net 实现的上传下载,如果是图片就显示上传的图片

    HTML: <div> <input id="fileUpload" type="file" runat="server" ...

  7. HDU 4284 Travel (Folyd预处理+dfs暴搜)

    题意:给你一些N个点,M条边,走每条边要花费金钱,然后给出其中必须访问的点,在这些点可以打工,但是需要先拿到证书,只可以打一次,也可以选择不打工之直接经过它.一个人从1号点出发,给出初始金钱,问你能不 ...

  8. JavaScript onkeydown事件入门实例(键盘某个按键被按下)

    JavaScript onkeydown 事件 用户按下一个键盘按键时会触发 onkeydown 事件.与 onkeypress事件不同的是,onkeydown 事件是响应任意键按下的处理(包括功能键 ...

  9. python 函数内使用全局变量

    x = def change_global(): global x x = x + change_global() print(x) result: 2

  10. NIOP 膜你题

    NOIp膜你题   Day1 duliu 出题人:ZAY    1.大美江湖(mzq.cpp/c) [题目背景] 细雪飘落长街,枫叶红透又一年不只为故友流连,其实我也恋长安听门外足音慢,依稀见旧时容颜 ...