1、安装过程中,需要修改参数
[root@localhost ~]# vi /etc/sysctl.conf [root@localhost ~]# sysctl vm.overcommit_memory=1
2、执行以下命令之后,没有在后台执行,一直会挂在那,这和Oracle、mysql不一样。
[root@localhost src]# ./redis-server [6622] 18 Jul 15:45:04.150 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf [6622] 18 Jul 15:45:04.151 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.17 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 6622 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [6622] 18 Jul 15:45:04.160 # Server started, Redis version 2.8.17 [6622] 18 Jul 15:45:04.160 # 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. [6622] 18 Jul 15:45:04.160 * The server is now ready to accept connections on port 6379 ^C[6622 | signal handler] (1563435987) Received SIGINT scheduling shutdown... [6622] 18 Jul 15:46:27.200 # User requested shutdown... [6622] 18 Jul 15:46:27.200 * Saving the final RDB snapshot before exiting.
3、使用set name 只会保存最后一次set的数据,这应该是这个库中只有一个表,这个表只有一行。
127.0.0.1:6379> set name "dayu" OK 127.0.0.1:6379> set name "dayu2" OK 127.0.0.1:6379> set name "dayu3" OK 127.0.0.1:6379> get name "dayu3" 127.0.0.1:6379>
4、用户默认进的是db 0,redis默认一共有16个,每个库中应该是只能存放一种数据类型。
127.0.0.1:6379[3]> SET runoobkey redis OK 127.0.0.1:6379[3]> get runoobkey "redis" 127.0.0.1:6379[3]> select 4 OK 127.0.0.1:6379[4]> get runoobkey (nil) 127.0.0.1:6379[4]> select 16 (error) ERR invalid DB index 127.0.0.1:6379> select 15 OK 127.0.0.1:6379[15]> get runoobkey (nil) 127.0.0.1:6379[15]> select 0 OK 127.0.0.1:6379> get runoobkey (nil) 127.0.0.1:6379> select 0 OK 127.0.0.1:6379> get runoobkey (nil)