在本教程中,我们将学习如何在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. ios 各种锁的使用性能比较

    iOS开发中常用的锁有如下几种 来比较一下遇到加锁的情况: 1. @synchronized 关键字加锁 2. NSLock 对象锁 3. NSCondition  4. NSConditionLoc ...

  2. Linux环境下mysql的root密码忘记解决方法(2种)

    方法一: 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以 ...

  3. 洛谷 P2868 [USACO07DEC]观光奶牛Sightseeing Cows

    题目描述 Farmer John has decided to reward his cows for their hard work by taking them on a tour of the ...

  4. XML(可拓展标记语言)

      XML 是可扩展标记语言(Extensible Markup Language)的缩写,其中的 标记(markup)是关键部分.您可以创建内容,然后使用限定标记标记它,从而使每个单词.短语或块成为 ...

  5. linux yum安装指定版本mysql

    1.下载mysql rpm包 cd /usr/local/src wget https://dev.mysql.com/get/mysql80-community-release-el7-.noarc ...

  6. [视觉] 基于YoloV3的实时摄像头记牌器

    基于YoloV3的实时摄像头记牌器 github:https://github.com/aoru45/cards_recognition_recorder_pytorch 最终效果 数据准备 数据获取 ...

  7. [学习总结] python语言学习总结 (二)

    1.python中的拆包 之前就只写了*可以是未知数量的参数,**可以传入未知数量命名参数.这次详细记下拆包. def f1(a, *l): print(a) # 不拆包 print(l) # 拆包 ...

  8. javascript报错:ReferenceError: $ is not defined解决办法

    原因很简单,要么是未导入jquery包,要么是导入的顺序不对. 例如,我在制作Chrome扩展程序时,其中的一块代码如下: 然后运行时报上述错误. 解决方法:我们不难发现script位置有问题,因为$ ...

  9. jQuery如何获取选中单选按钮radio的值

    使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项: 1. ...

  10. 数据类型-------JavaScript

    之前只是简单的学过JavaScript和JQuery,虽然一般的要求都能完成,但并没有深入,这次是看了一个网站,很详细的教学,想重新认识一下JavaScript和JQuery. 本文摘要:http:/ ...