CentOS6.5下安装了redis,想连接redis客户端查看redis的数据列表,输入命令:redis-cli,直接报错如下:
[root@xxxx]# redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
查了很多资料,各种百度,都没有相关问题的解决方案,回家突然想起来redis服务不确定是不是启动,于是乎启动redist服务
[root@xxxx]# redis-server
13841:C 09 Aug 21:13:34.763 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 13841
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
13841:M 09 Aug 21:13:34.766 # Server started, Redis version 3.0.3
13841:M 09 Aug 21:13:34.767 # 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.
13841:M 09 Aug 21:13:34.767 # 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.
13841:M 09 Aug 21:13:34.767 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
但是,直接执行redis server,我不能在这个命令行界面再输入其他的命令,使用Ctrl+C退出,则redis服务也就停了,提示如下:
13841:signal-handler (1470748417) Received SIGINT scheduling shutdown...
13841:M 09 Aug 21:13:37.070 # User requested shutdown...
13841:M 09 Aug 21:13:37.070 * Saving the final RDB snapshot before exiting.
13841:M 09 Aug 21:13:37.074 * DB saved on disk
13841:M 09 Aug 21:13:37.075 # Redis is now ready to exit, bye bye...
楼主又想起同事之前教过的,可以忽略输入输出执行命令,于是nohup redis-server &,然后再执行redis-cli,搞定!!!
[root@xxxx]# nohup redis-server &
[1] 6191
[root@xxxx]# nohup: ignoring input and appending output to `nohup.out'
[root@xxxx]# redis-cli
127.0.0.1:6379>