您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
Redis 客户端连接
发布时间:2021-11-21 14:41:35编辑:雪饮阅读()
maxclients 的默认值是 10000,你也可以在 redis.conf 中对这个值进行修改。
127.0.0.1:6379> config get maxclients
1) "maxclients"
2) "10000"
你比如说我这里默认是对maxclients注释的,那么我修改成100001
[root@localhost ~]# cat /usr/local/redis-6.2.5/redis.conf | grep maxclients
maxclients 100001
然后关闭之前的redis服务并以修改后的redis配置文件进行加载启动:
[root@localhost ~]# /usr/local/redis-6.2.5/src/redis-server /usr/local/redis-6.2.5/redis.conf &
[1] 46961
[root@localhost ~]# 46961:C 21 Nov 2021 01:35:52.967 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
46961:C 21 Nov 2021 01:35:52.967 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=46961, just started
46961:C 21 Nov 2021 01:35:52.967 # Configuration loaded
46961:M 21 Nov 2021 01:35:52.967 * Increased maximum number of open files to 100033 (it was originally set to 1024).
46961:M 21 Nov 2021 01:35:52.967 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.2.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 46961
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
46961:M 21 Nov 2021 01:35:52.999 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
46961:M 21 Nov 2021 01:35:52.999 # Server initialized
46961:M 21 Nov 2021 01:35:52.999 # 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.
46961:M 21 Nov 2021 01:35:53.015 * Loading RDB produced by version 6.2.5
46961:M 21 Nov 2021 01:35:53.015 * RDB age 487673 seconds
46961:M 21 Nov 2021 01:35:53.015 * RDB memory usage when created 0.84 Mb
46961:M 21 Nov 2021 01:35:53.015 * DB loaded from disk: 0.016 seconds
46961:M 21 Nov 2021 01:35:53.015 * Ready to accept connections
然后用一个客户端连接这个新开的redis服务就可以看到maxclients已经修改成功了。
[root@localhost ~]# /usr/local/redis-6.2.5/src/redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> config get maxclients
1) "maxclients"
2) "100001"
当然除了在配置文件上面能修改,其实也可以直接在redis-server启动服务时候带上--maxclients参数即可:
[root@localhost ~]# /usr/local/redis-6.2.5/src/redis-server --maxclients 220807 &
[1] 47992
[root@localhost ~]# 47992:C 21 Nov 2021 01:38:44.841 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
47992:C 21 Nov 2021 01:38:44.841 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=47992, just started
47992:C 21 Nov 2021 01:38:44.841 # Configuration loaded
47992:M 21 Nov 2021 01:38:44.842 * Increased maximum number of open files to 220839 (it was originally set to 1024).
47992:M 21 Nov 2021 01:38:44.842 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.2.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 47992
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
47992:M 21 Nov 2021 01:38:44.844 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
47992:M 21 Nov 2021 01:38:44.844 # Server initialized
47992:M 21 Nov 2021 01:38:44.844 # 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.
47992:M 21 Nov 2021 01:38:44.844 * Loading RDB produced by version 6.2.5
47992:M 21 Nov 2021 01:38:44.844 * RDB age 4 seconds
47992:M 21 Nov 2021 01:38:44.844 * RDB memory usage when created 11.40 Mb
47992:M 21 Nov 2021 01:38:44.844 * DB loaded from disk: 0.000 seconds
47992:M 21 Nov 2021 01:38:44.844 * Ready to accept connections
然后客户端同样能读取到这个--maxclients的值。
[root@localhost ~]# /usr/local/redis-6.2.5/src/redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> config get maxclients
1) "maxclients"
2) "220807"
关键字词:Redis,客户端连接
上一篇:Redis 性能测试
下一篇:redis客户端命令