首页 > 系统 > Linux >

Linux下Redis的安装和使用

2017-03-06

Linux下Redis的安装和使用。 1 Redis的安装 Redis下载:http: redis io download 在页面下方Redis提供了linux下安装的指令 wget http: download redis io releases redis-2 8 7 tar gz tar xzf red

Linux下Redis的安装和使用

1.Redis的安装

Redis下载:http://redis.io/download 在页面下方Redis提供了linux下安装的指令

\

wget http://download.redis.io/releases/redis-2.8.7.tar.gz

tar xzf redis-2.8.7.tar.gz

cd redis-2.8.7

make

注意:make指令是需要linux下安装gcc的 如果没有gcc可以尝试安装

yum -y install gcc

另外可能还会遇到其它的一些问题

可以参考

比如32位Linux安装redis的解决 http://www.linuxidc.com/Linux/2014-05/101980.htm 与 http://www.linuxidc.com/Linux/2014-05/101981.htm

由于自己对Linux也不太熟悉,当时make的时候不成功,就试了网上的各种方法,最主要的原因是make需要gcc

2.Redis的使用

在Redis目录下 开启Redis 这个窗口就不能继续操作了

scr/redis-server

另开启一个命令行窗口 进入Redis目录 可以进行测试

src/redis-cli

[root@localhost src]# ./redis-cli
127.0.0.1:6379> set abc abcvalues
OK
127.0.0.1:6379> get abc
"abcvalues"
127.0.0.1:6379>


quit可以退出当前client

3.Redis的关闭

src/redis-cli shutdown

127.0.0.1:6379> quit
[root@localhost src]# ./redis-cli shutdown
[root@localhost src]#

4.补充 Ctrl+z

[root@localhost src]# ./redis-server
10721:C 05 Mar 15:20:33.790 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
10721:M 05 Mar 15:20:33.791 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.8 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 10721
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'


10721:M 05 Mar 15:20:33.810 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10721:M 05 Mar 15:20:33.810 # Server started, Redis version 3.2.8
10721:M 05 Mar 15:20:33.811 # 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.
10721:M 05 Mar 15:20:33.811 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
10721:M 05 Mar 15:20:33.811 * The server is now ready to accept connections on port 6379
[10721:M 05 Mar 15:41:22.610 # User requested shutdown...
10721:M 05 Mar 15:41:22.610 * Saving the final RDB snapshot before exiting.
10721:M 05 Mar 15:41:22.799 * DB saved on disk
10721:M 05 Mar 15:41:22.799 # Redis is now ready to exit, bye bye...
[root@localhost src]#

src/redis-server 开启服务后 这个窗口是不能运行命令的 这个窗口可以关闭 服务不会关闭

如果在这个页面ctrl+z会把redis服务暂时挂起 可以通过 bg fg唤醒。

相关文章
最新文章
热点推荐