百度百科
redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、 zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作, 而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。 区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。 Redis 是一个高性能的key-value数据库。 redis的出现,很大程度补偿了memcached这类key/value存储的不足, 在部 分场合可以对关系数据库起到很好的补充作用。它提供了Java,C/C++,C#,PHP,JavaScript,Perl,Object-C, Python,Ruby,Erlang等客户端,使用很方便。 Redis支持主从同步。数据可以从主服务器向任意数量的从服务器上同步,从服务器可以是关联其他从服务器的主服务器。 这使得Redis可执行单层树复制。从盘可以有意无意的对数据进行写操作。由于完全实现了发布/订阅机制, 使得从数据库在任何地方同步树时,可订阅一个频道并接收主服务器完整的消息发布记录。 同步对读取操作的可扩展性和数据冗余很有帮助。
从官网下载redis源码包,上传
tar xzvf redis-2.8.3.tar.gz vi INSTALL vi README
[email protected]:/shared/redis-2.8.3# vi README Where to find complete Redis documentation? ------------------------------------------- This README is just a fast "quick start" document. You can find more detailed documentation at http://redis.io Building Redis -------------- Redis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD. We support big endian and little endian architectures. It may compile on Solaris derived systems (for instance SmartOS) but our support for this platform is "best effort" and Redis is not guaranteed to work as well as in Linux, OSX, and *BSD there. It is as simple as: % make You can run a 32 bit Redis binary using: % make 32bit After building Redis is a good idea to test it, using: % make test Fixing problems building 32 bit binaries ---------
mv redis-2.8.3 /opt/ cd opt/ cd redis-2.8.3/ ## apt-get install make apt-get install gcc make MALLOC=libc src/redis-server redis.conf
[email protected]:/opt/redis-2.8.3# src/redis-server redis.conf [6703] 20 Nov 21:34:04.012 * Max number of open files set to 10032 [6703] 20 Nov 21:34:04.025 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with ‘noeviction‘ policy now. _._ _.-``__ ‘‘-._ _.-`` `. `_. ‘‘-._ Redis 2.8.3 (00000000/0) 32 bit .-`` .-```. ```\/ _.,_ ‘‘-._ ( ‘ , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6379 | `-._ `._ / _.-‘ | PID: 6703 `-._ `-._ `-./ _.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | http://redis.io `-._ `-._`-.__.-‘_.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | `-._ `-._`-.__.-‘_.-‘ _.-‘ `-._ `-.__.-‘ _.-‘ `-._ _.-‘ `-.__.-‘ [6703] 20 Nov 21:34:04.032 # Server started, Redis version 2.8.3 [6703] 20 Nov 21:34:04.033 # 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. [6703] 20 Nov 21:34:04.033 * The server is now ready to accept connections on port 6379
--------------
测试
[email protected]:/opt/redis-2.8.3# src/redis-cli 127.0.0.1:6379> info # Server redis_version:2.8.3 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:74dd87ed5ecd9860 redis_mode:standalone os:Linux 3.16.0-23-generic i686 arch_bits:32 multiplexing_api:epoll gcc_version:4.9.1 process_id:6735 run_id:8eaf0afc191f05084739f973eaba5129cd0b3fce tcp_port:6379 uptime_in_seconds:111 uptime_in_days:0 hz:10 lru_clock:1139965 config_file:/opt/redis-2.8.3/redis.conf # Clients connected_clients:1 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Memory used_memory:618048 used_memory_human:603.56K used_memory_rss:3252224 used_memory_peak:617180 used_memory_peak_human:602.71K used_memory_lua:22528 mem_fragmentation_ratio:5.26 mem_allocator:libc # Persistence loading:0 rdb_changes_since_last_save:0 rdb_bgsave_in_progress:0 rdb_last_save_time:1416491387 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:-1 rdb_current_bgsave_time_sec:-1 aof_enabled:0 aof_rewrite_in_progress:0 aof_rewrite_scheduled:0 aof_last_rewrite_time_sec:-1 aof_current_rewrite_time_sec:-1 aof_last_bgrewrite_status:ok # Stats total_connections_received:2 total_commands_processed:2 instantaneous_ops_per_sec:0 rejected_connections:0 sync_full:0 sync_partial_ok:0 sync_partial_err:0 expired_keys:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:0 # Replication role:master connected_slaves:0 master_repl_offset:0 repl_backlog_active:0 repl_backlog_size:1048576 repl_backlog_first_byte_offset:0 repl_backlog_histlen:0 # CPU used_cpu_sys:0.18 used_cpu_user:0.00 used_cpu_sys_children:0.00 used_cpu_user_children:0.00 # Keyspace 127.0.0.1:6379> 127.0.0.1:6379> keys *(empty list or set)127.0.0.1:6379>
OK.
时间: 2024-11-01 04:30:17