【NOSQL ]】 redis 安装
安装redis,使用一种你熟悉的高级语言(例如ruby,python等)在redis里创建数据并成功访问作为测试
=======================================================================================================
1.安装
[root@ractdg3 download]# ll
-rw-r--r-- 1 root root 1048914 01-15 14:36 redis-2.8.4.tar.gz
[root@ractdg3 download]# tar xzf redis-2.8.4.tar.gz
[root@ractdg3 download]# ll
drwxrwxr-x 6 root root 4096 01-14 00:09 redis-2.8.4
-rw-r--r-- 1 root root 1048914 01-15 14:36 redis-2.8.4.tar.gz
[root@ractdg3 download]# cd redis-2.8.4
[root@ractdg3 redis-2.8.4]# ls
00-RELEASENOTES CONTRIBUTING deps Makefile README runtest src utils
BUGS COPYING INSTALL MANIFESTO redis.conf sentinel.conf tests
[root@ractdg3 redis-2.8.4]# ll
总计 108
-rw-rw-r-- 1 root root 9549 01-14 00:09 00-RELEASENOTES
-rw-rw-r-- 1 root root 52 01-14 00:09 BUGS
-rw-rw-r-- 1 root root 1439 01-14 00:09 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 01-14 00:09 COPYING
drwxrwxr-x 6 root root 4096 01-14 00:09 deps
-rw-rw-r-- 1 root root 11 01-14 00:09 INSTALL
-rw-rw-r-- 1 root root 151 01-14 00:09 Makefile
-rw-rw-r-- 1 root root 4223 01-14 00:09 MANIFESTO
-rw-rw-r-- 1 root root 4401 01-14 00:09 README
-rw-rw-r-- 1 root root 30113 01-14 00:09 redis.conf
-rwxrwxr-x 1 root root 271 01-14 00:09 runtest
-rw-rw-r-- 1 root root 5662 01-14 00:09 sentinel.conf
drwxrwxr-x 2 root root 4096 01-14 00:09 src
drwxrwxr-x 8 root root 4096 01-14 00:09 tests
drwxrwxr-x 2 root root 4096 01-14 00:09 utils
[root@ractdg3 redis-2.8.4]# make
zmalloc.o: In function `zmalloc_used_memory':
/var/lib/tcommsvr/redis-2.8.0-rc4/src/zmalloc.c:223: undefined reference to `__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/var/lib/tcommsvr/redis-2.8.0-rc4/src'
make: *** [all] Error 2
产生原因:
linux为32位版本。
查看方式:getconf LONG_BIT
解决办法:
执行make命令时加参数:make CFLAGS="-march=i686"
make CFLAGS="-march=i686"
2.启动:
[root@ractdg3 src]# ./redis-server --port 9999
[15894] 15 Jan 16:20:23.114 * Max number of open files set to 10032
[15894] 15 Jan 16:20:23.117 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
...
3.测试连接
[root@ractdg3 redis-2.8.4]# telnet localhost 9999
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
get a^H
$-1
set a
-ERR wrong number of arguments for 'set' command
set hpp 4
+OK
set hoge 4
+OK
abcd
-ERR unknown command 'abcd'
set hoge 4
+OK
get hoge
$1
4
setex foo 5 3
+OK
get foo
$-1
get foo
$-1
setex foo 5 10
+OK
4.安装Python
4.1.下载源代码
http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tar.bz2
4.2. 安装 Python
$ tar –jxvf Python-2.7.6.tgz
$ cd Python-2.7.6
./configure
make
make install
4.3 测试打开python
[root@ractdg3 redis-2.7.2]# python
Python 2.7.6 (default, Jan 16 2014, 17:54:06)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import redis
>>> r= redis.StrictRedis(host='localhost',port=6379,db=0)
>>> r.set('foo','bar')
4.4 启动redis
[root@ractdg3 /]# cd /download/redis-2.8.4/
[root@ractdg3 redis-2.8.4]# vi redis.conf
[root@ractdg3 redis-2.8.4]# src/redis-server redis.conf
[28781] 17 Jan 09:50:40.200 * Max number of open files set to 10032
[28781] 17 Jan 09:50:40.203 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.4 (00000000/0) 32 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 28781
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[28781] 17 Jan 09:50:40.205 # Server started, Redis version 2.8.4
[28781] 17 Jan 09:50:40.205 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[28781] 17 Jan 09:50:40.206 * The server is now ready to accept connections on port 6379
4.5 使用python 连接redis
[root@ractdg3 opt]# python
Python 2.7.6 (default, Jan 16 2014, 17:54:06)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import redis
>>> redisClient=redis.StrictRedis(host='127.0.0.1',port=6379,db=0)
>>> redisClient.set('test_redis','Hello Python')
True
>>> value=redisClient.get('test_redis')
>>> print value
Hello Python
>>> redisClient.delete('test_redis')
True
>>> value=redisClient.get('test_redis')
>>> print value
None
>>>
4.6 4.测试实例:
4.6 4.1.把文本数据导入到redis
[root@ractdg3 backup]# cat test_data.txt
wolys # wolysopen111 # wolys@21cn.com
coralshanshan # 601601601 # zss1984@126.com
pengfeihuchao # woaidami # 294522652@qq.com
simulategirl # @#$9608125 # simulateboy@163.com
daisypp # 12345678 # zhoushigang_123@163.com
sirenxing424 # tfiloveyou # sirenxing424@126.com
raininglxy # 1901061139 # lixinyu23@qq.com
leochenlei # leichenlei # chenlei1201@gmail.com
z370433835 # lkp145566 # 370433835@qq.com
4.6 4.2.创建命令脚本
[root@ractdg3 backup]# vi imp_redis.py
[root@ractdg3 backup]# cat imp_redis.py
import redis
import re
pool = redis.ConnectionPool(host='127.0.0.1', port=6379)
r = redis.Redis(connection_pool=pool)
pipe = r.pipeline()
p=re.compile(r'(.*)\s#\s(.*)\s#\s(.*)');
pipe = r.pipeline()
f = open("/opt/backup/test_data.txt")
matchs=p.findall(f.read())
for user in matchs:
key='users_%s' %user[0].strip()
pipe.hset(key,'pwd',user[1].strip()).hset(key,'email',user[2].strip())
pipe.execute()
f.close()
4.6 4.3.执行脚本
[root@ractdg3 backup]# python imp_redis.py
4.6 4.4.查看导入数据
[root@ractdg3 src]# redis-cli
-bash: redis-cli: command not found
[root@ractdg3 src]# ./redis-cli
127.0.0.1:6379> keys *
1) "users_simulategirl"
2) "users_wolys"
3) "users_raininglxy"
4) "users_daisypp"
5) "users_coralshanshan"
6) "users_pengfeihuchao"
7) "users_leochenlei"
8) "hoge"
9) "users_sirenxing424"
10) "users_z370433835"
127.0.0.1:6379>
[root@ractdg3 src]#
【NOSQL ]】 redis 安装相关推荐
- NoSQL概述-Redis安装-常用五大数据类型-概述Bitmaps,HyperLogLog,Geospatial和redis.conf 基本解析
NoSQL 概述 NoSQL(NoSQL=Not Only SQL),意即"不仅仅是SQL",泛指 非关系型的数据库. NoSQL不依赖业务逻辑方式存储,而以简单的key-valu ...
- 非关系型数据库-NoSQL(Redis)
文章目录 一.什么是 NoSQL? 二.NoSQL 的特性? 三.什么是 Redis? 四.Redis 安装部署 4.1 下载安装包 4.2 编译安装 4.3 修改配置文件 4.4 启动服务 4.5 ...
- Redis安装部署配置说明
1. redis简介 Redis是个高性能的key-value数据库,它的key具有丰富的数据结构:string,hash,list set和sorted set.作为NOSQL,比 ...
- redis安装_Redis安装
redis安装 本文是我们学院课程的一部分,标题为Redis NoSQL键值存储 . 这是Redis的速成课程. 您将学习如何安装Redis和启动服务器. 此外,您还会在Redis命令行上乱七八糟. ...
- 【学习记录】macOS的Redis安装及基本使用
[学习记录]macOS的Redis安装及基本使用 一. Redis的安装与启动 二. 简单使用 ① 尝试插入第一个key-value ② Redis的数据类型与基本使用 字符串 列表 字典(哈希表) ...
- Spring Boot——Redis安装配置与应用整合
引言 Spring Boot默认以ConcurrentHashMap作为缓存容器,但默认的缓存容器在简单的场景使用还是可以的,而作为NoSQL的代表,Redis可以做内存数据库.消息中间件都是不错的, ...
- Redis入门之Redis安装、配置及常用指令
Redis入门 NoSQL 引言 为什么使用 NoSQL? NoSQL 的四大分类(键值.列存储.文档.图形) NoSQL 应用场景 Redis 介绍 Redis 安装 与 配置 Redis 启动服务 ...
- NoSQL Redis
21.3 Redis介绍 什么是Redis Redis和Memcached类似,也是NoSQL的一种,是一个基于内存的高性能key-value(k-v)数据库. Redis支持string.list. ...
- 非关系型数据库之Redis【redis安装】
这里写目录标题 写在前面 什么是 NoSql ? NoSql 的分类 键值 (Key-Value) 存储数据库 列存储数据库 文档型数据库 图形 (Graph) 数据库 1. Redis 1.1 什么 ...
- 操作系统篇之Linux命令操作和redis安装以及基本使用
电脑操作系统 : windows7,8,10,xp,win98操作系统 : linux ax unix以后开发项目是部署在服务器上,服务器一般采用linux.linux的优点:系统稳定,操作速度快,系 ...
最新文章
- Tomcat性能调优-让小猫飞奔[转]
- OpenCV学习资料收集
- OBS集成WebRTC
- 同IP不同端口Session冲突问题
- atmega8 例程:USART串口通信
- 烘烤店LOGO在线设计制作教程
- Spring : Spring 切入点(Pointcut)
- 忍者X2简介+安装包+安装环境说明 [复制链接]
- cas-client配置
- Tomcat详解(十一)——Tomcat管理
- 关于投资收益和风险的例题(线性规划)
- STC 51单片机仿真总结
- react在线编辑器
- 数据库系统概论:判别一个分解的无损连接性
- DevEco Studio JS sdk下载问题
- (转自zzmseo,只为学习方便)1.1 什么是SEO
- ASp.net动态加载js和css文件
- QPainter 绘制阴影边界
- 为数据科学和机器学习选择合适的笔记本电脑,完成数据科学和机器学习任务的完美笔记本电脑的 20 个必要条件
- 智能家居APP开发模板介绍
热门文章
- 为您的软件系统设计选择最佳的工具
- swift - xcode10 - 点击事件交互BUG - (手势和button的addTarget方法)
- Tornado-Lesson05-模版继承、函数和类导入、ui_methods和ui_modules
- 基于EasyNVR二次开发实现业务需求:直接集成EasyNVR播放页面到自身项目
- 网络基本功系列:细说网络那些事儿
- sql 2008 R2添加对MySql的远程服务器链接
- 傻瓜突破linux--rootpassword
- 由《我也能做CTO》引起的作者与读者的交流
- 连接oracle10g数据库免安装oracle客户端解决办法 (转载)
- 利用深度学习方法进行情感分析以及在海航舆情云平台的实践