Redis学习第一篇

本文详细介绍了Redis的安装过程及配置参数调整方法,并演示了启动Redis服务的具体步骤,包括后台运行的问题解决办法。同时,文章还展示了如何进行基本的数据操作,并解释了Redis数据库切换与数据类型的限制。

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)

 

转载于:https://www.cnblogs.com/dayu-liu/p/11208514.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值