首页 > 代码库 > ubuntu-server 安装redis

ubuntu-server 安装redis

 

百度百科

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.gzvi INSTALL vi README 
root@ubuntu:/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 detaileddocumentation at http://redis.ioBuilding 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 oursupport for this platform is "best effort" and Redis is not guaranteed towork as well as in Linux, OSX, and *BSD there.It is as simple as:    % makeYou can run a 32 bit Redis binary using:    % make 32bitAfter building Redis is a good idea to test it, using:    % make testFixing problems building 32 bit binaries---------

 

 mv redis-2.8.3 /opt/cd opt/cd redis-2.8.3/##apt-get install makeapt-get install gccmake MALLOC=libcsrc/redis-server redis.conf
root@ubuntu:/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

 

--------------

测试

root@ubuntu:/opt/redis-2.8.3# src/redis-cli 127.0.0.1:6379> info# Serverredis_version:2.8.3redis_git_sha1:00000000redis_git_dirty:0redis_build_id:74dd87ed5ecd9860redis_mode:standaloneos:Linux 3.16.0-23-generic i686arch_bits:32multiplexing_api:epollgcc_version:4.9.1process_id:6735run_id:8eaf0afc191f05084739f973eaba5129cd0b3fcetcp_port:6379uptime_in_seconds:111uptime_in_days:0hz:10lru_clock:1139965config_file:/opt/redis-2.8.3/redis.conf# Clientsconnected_clients:1client_longest_output_list:0client_biggest_input_buf:0blocked_clients:0# Memoryused_memory:618048used_memory_human:603.56Kused_memory_rss:3252224used_memory_peak:617180used_memory_peak_human:602.71Kused_memory_lua:22528mem_fragmentation_ratio:5.26mem_allocator:libc# Persistenceloading:0rdb_changes_since_last_save:0rdb_bgsave_in_progress:0rdb_last_save_time:1416491387rdb_last_bgsave_status:okrdb_last_bgsave_time_sec:-1rdb_current_bgsave_time_sec:-1aof_enabled:0aof_rewrite_in_progress:0aof_rewrite_scheduled:0aof_last_rewrite_time_sec:-1aof_current_rewrite_time_sec:-1aof_last_bgrewrite_status:ok# Statstotal_connections_received:2total_commands_processed:2instantaneous_ops_per_sec:0rejected_connections:0sync_full:0sync_partial_ok:0sync_partial_err:0expired_keys:0evicted_keys:0keyspace_hits:0keyspace_misses:0pubsub_channels:0pubsub_patterns:0latest_fork_usec:0# Replicationrole:masterconnected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0# CPUused_cpu_sys:0.18used_cpu_user:0.00used_cpu_sys_children:0.00used_cpu_user_children:0.00# Keyspace127.0.0.1:6379> 
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379>


OK.

 

ubuntu-server 安装redis