$ bin/redis-server 36959:C 20 Mar 2020 13:28:02.467 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 36959:C 20 Mar 2020 13:28:02.467 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=36959, just started 36959:C 20 Mar 2020 13:28:02.467 # Warning: no config file specified, using the default config. In order to specify a config file use bin/redis-server /path/to/redis.conf 36959:M 20 Mar 2020 13:28:02.467 # You requested maxclients of 10000 requiring at least 10032 max file descriptors. 36959:M 20 Mar 2020 13:28:02.467 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted. 36959:M 20 Mar 2020 13:28:02.467 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.8 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 36959 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'
36959:M 20 Mar 2020 13:28:02.468 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 36959:M 20 Mar 2020 13:28:02.468 # Server initialized 36959:M 20 Mar 2020 13:28:02.468 # 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. 36959:M 20 Mar 2020 13:28:02.468 # 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. 36959:M 20 Mar 2020 13:28:02.468 * Ready to accept connections
通过客户端连接redis服务
1 2 3 4 5 6
$ bin/redis-cli 127.0.0.1:6379> set name key OK 127.0.0.1:6379> get name "key" 127.0.0.1:6379>
如果通过非127.0.0.1连接,会报如下错误:
1 2
$ bin/redis-cli -h 192.168.229.130 192.168.229.130:6379> get name
1
(error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.