在CentOS上装Redis
$ wget http://download.redis.io/releases/redis-3.2.5.tar.gz
$ tar xzf redis-3.2..tar.gz
$ cd redis-3.2.
$ make
执行第一行命令就出错了
-bash: wget: 未找到命令
原因是CentOS最小化安装没有装wget,使用下面命令安装即可:
yum -y install wget
然后往下执行,在make的时候又报错了:
cd src && make all
make[]: 进入目录“/usr/soft/redis-3.2./src”
CC adlist.o
/bin/sh: cc: 未找到命令
make[]: *** [adlist.o] 错误
make[]: 离开目录“/usr/soft/redis-3.2./src”
make: *** [all] 错误
原因是虚拟机系统中缺少gcc,安装一下gcc:
yum -y install gcc automake autoconf libtool make
重新make redis ,发现又报错了:
cd src && make all
make[]: 进入目录“/usr/soft/redis-3.2./src”
CC adlist.o
In file included from adlist.c:::
zmalloc.h::: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录
#include <jemalloc/jemalloc.h>
^
编译中断。
make[]: *** [adlist.o] 错误
make[]: 离开目录“/usr/soft/redis-3.2./src”
make: *** [all] 错误
解决方法:
make MALLOC=libc
这样就顺利安装了,接下来运行:
src/redis-server
设置防火墙(没开启防火墙的可以跳过):
firewall-cmd --zone=public --add-port=/tcp --permanent
firewall-cmd --reload
接下来就可以测试了,结果在windows中测试的时候发现连接不上,原来是redis默认绑定监听:
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1
注释掉,还有这里:
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes
把yes改成no,再次运行
src/redis-server
从Windows测试,测试代码如下:
string redisIP = ConfigurationManager.AppSettings["redisIP"];
try
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(redisIP);
IDatabase db = redis.GetDatabase();
string value = "abcdefg";
db.StringSet("mykey", value);
string value1 = db.StringGet("mykey");
Console.WriteLine(value1);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
这里用的是StackExchange.Redis,用包管理器就可以安装:
Install-Package StackExchange.Redis
运行程序,发现还是连接不上,什么问题呢?再仔细看下redis的提示:
:C Nov ::54.682 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
也就是说我们上面修改的配置redis没有使用,接下来改下命令
src/redis-server redis.conf
这样就可以使用我们自己的配置了,再次连接,OK了。
在CentOS上装Redis的更多相关文章
- centos安装redis及php-redis扩展
centos安装redis及php-redis扩展 Linux, WEB 七162012 今天公司同事要求在测试机上安装redis,并且要求让php安装上redis的扩展,redis是一个key-v ...
- CentOS下redis集群安装
环境: 一台CentOS虚拟机上部署六个节点,创建3个master,3个slave节点 1.下载并解压 cd /root wget http://download.redis.io/releases/ ...
- mac与centos下redis的安装与配置
前言 最近在用redis,下面简单写一下mac和centos下redis的安装与配置方法. 安装 mac下面 安装命令:brew intall redis 运行命令:brew services sta ...
- CentOS下Redis的安装(转)
目录 CentOS下Redis的安装 前言 下载安装包 解压安装包并安装 启动和停止Redis 启动Redis 停止Redis 参考资料 CentOS下Redis的安装 前言 安装Redis需要知道自 ...
- 转载:centos安装redis
转载自:https://www.cnblogs.com/renzhicai/p/7773080.html CentOS下Redis的安装 [TOC] 前言 安装Redis需要知道自己需要哪个版本,有针 ...
- Centos下Redis集群的搭建实现读写分离
Centos下Redis一主多从架构搭建 搭建目标:因为自己笔记本电脑配置较低的原因,模拟两台机器之间搭建一主一从的架构,主节点Redis主要用来写数据,数据写入到主节点的Redis,然后从节点就可以 ...
- CentOS 下 redis 安装与配置
CentOS 下 redis 安装与配置 1.到官网上找到合适版本下载解压安装 [root@java src]# wget -c http://redis.googlecode.com/files ...
- CentOS下Redis服务器安装配置
说明: 操作系统:CentOS 1.安装编译工具 yum install wget make gcc gcc-c++ zlib-devel openssl openssl-devel pcre-de ...
- Linux下centos系统安装redis和php-redis
源地址:http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm //此为centos 6版本 安装输入 ...
随机推荐
- 【转】Android贪吃蛇源代码
/*TileView:tile有瓦片的意思,用一个个tile拼接起来的就是地图.TileView就是用来呈现地图的类*/ public class TileView extends View { /* ...
- 洛谷P3066 [USACO12DEC]逃跑的Barn (线段树合并)
题目描述It's milking time at Farmer John's farm, but the cows have all run away! Farmer John needs to ro ...
- [mobile]移动端页面没有重新请求时,刷新页面代码
<input type="hidden" value="yes" id="id_if_reload" /> <script ...
- WPF 最简单的TextBox水印
最简单的TextBox加水印的方法,但是不具有很强的通用性. 如果你只是使用一次,或者用的不多,偷偷懒可以使用. 因为此方法只需要修改TextBox的Template,而不用重写何任代码. 注意: 1 ...
- [翻译]NUnit---SetUp and SetUpFixture and Suite Attributes(十九)
SetUpAttribute (NUnit 2.0 / 2.5) 本特性用于TestFixture提供一个公共的功能集合,在呼叫每个测试方法之前执行.同时也用在SetUpFixture中,SetUpF ...
- 隐式等待-----Selenium快速入门(九)
有时候,网页未加载完成,或加载失败,但是我们后续的代码就已经开始查找页面上的元素了,这通常将导致查找元素失败.在本系列Selenium窗口切换-----Selenium快速入门(六)中,我们就已经出现 ...
- 【mysql】使用Navicat连接数据库
1 连接数据库 点击左下角测试一下 提示 输入 select host,user,plugin,authentication_string from mysql.user; 查看用户信息 注意这里我们 ...
- 徒手画个disk不容易啊。。。
static const GLfloat disk_vertex_buffer_data[] = { // quarter 1 0.0f, 0.0f, -1.0f, 0.707f, 0.0f, -0. ...
- Python 获取主机名
import socket print socket.gethostname()
- 638. Shopping Offers
In LeetCode Store, there are some kinds of items to sell. Each item has a price. However, there are ...