- [root@150 Redis-4.0.14]#VIM /etc/sysctl.conf.NET.core.somaxconn = 512 vm.overcommit_memory = 1
- [root@150 Redis-4.0.14]#sysctl -p.NET.core.somaxconn = 512 vm.overcommitmemory = 1
再次重启:[root@150 Redis-4.0.14]#/apps/Redis/bin/Redis-server /apps/Redis/etc/Redis.conf
- 50607:C 27 Mar 22:07:30.778 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
- 50607:C 27 Mar 22:07:30.778 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=50607, just started..-__ ''-._ <br/>_.- ..''-. Redis 4.0.14 (00000000/0) 64 bit
- .-.-```. ```\/ _.,_ ''-._ <br/>(' , .-` | `, ) Running in standalone mode<br/>|`-._`-...-` __...-.-.|'`.-'| Port: 6379
- | -._./.-' | PID: 50607
- -._-.`-./.-'.-'
- |`-.-._-..-'.-'.-'|
- | -._-..-'.-' | http://redis.io
- `-. -._-..-'.-'.-'|-._-._ -.__.-' _.-'_.-'| <br/>|-.`-. .-'.-' |
- -._-._-.__.-'_.-' _.-'<br/>-._ -.__.-' _.-'<br/>-..-'
- -.__.-'<br/>50607:M 27 Mar 22:07:30.782 # Server initialized 此处就是一项了.<br/>7977:M 28 Mar 08:57:56.291 * DB loaded from disk: 0.000 seconds<br/>50607:M 27 Mar 22:07:30.783 # 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.<br/> 六, 开启大页内存动态分配, 需要关闭让 redis 负责内存管理:[root@150 redis-4.0.14]#echo never > /sys/kernel/mm/transparent_hugepage/enabled<br/>[root@150 redis-4.0.14]#/apps/redis/bin/redis-server /apps/redis/etc/redis.conf<br/>50689:C 27 Mar 22:14:54.060 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo<br/>50689:C 27 Mar 22:14:54.060 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=50689, just started<br/>50689:C 27 Mar 22:14:54.060 # Configuration loaded<br/>50689:M 27 Mar 22:14:54.062 * Increased maximum number of open files to 10032 (it was originally set to 1024).<br/>_._ <br/>_.-``__''-._ <br/>_.-``. _. ''-._ Redis 4.0.14 (00000000/0) 64 bit<br/>.-`` .-```. ```\/ _.,_''-._ <br/>( ', .- | , ) Running in standalone mode<br/>|-._-...- ...-.`-._|' .-'| Port: 6379
- | `-. ._ / _.-'| PID: 50689<br/>-.`-. -./ _.-' _.-'<br/>|-.`-. -.__.-' _.-'_.-'| <br/>|-.`-. .-'.-' | http://redis.io
- -._-._-.__.-'_.-' _.-'<br/>|-.`-. -.__.-' _.-'_.-'| <br/>|-.`-. .-'.-' |
- -._-._-.__.-'_.-' _.-'<br/>-._ `-..-' .-'`-. _.-'
- -.__.-'<br/>50689:M 27 Mar 22:14:54.066 # Server initialized<br/>50689:M 27 Mar 22:14:54.066 # 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.<br/>50689:M 27 Mar 22:14:54.066 * DB loaded from disk: 0.000 seconds<br/>50689:M 27 Mar 22:14:54.066 * Ready to accept connections. 此时表明启动已完成.<br/> 七,[root@150 redis-4.0.14]#vim /etc/rc.d/rc.local echo never > /sys/kernel/mm/transparent_hugepage/enabled<br/>[root@150 redis-4.0.14]#chmod a+x /etc/rc.d/rc.local 给该文件要加上 x 权限.<br/> 八,[root@150 redis-4.0.14]#reboot 重启使其生效.<br/> 九,[root@centos7 ~]#/apps/redis/bin/redis-server /apps/redis/etc/redis.conf<br/>7977:C 28 Mar 08:57:56.284 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo<br/>7977:C 28 Mar 08:57:56.284 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=7977, just started<br/>7977:C 28 Mar 08:57:56.284 # Configuration loaded<br/>7977:M 28 Mar 08:57:56.286 * Increased maximum number of open files to 10032 (it was originally set to 1024).<br/>_._ <br/>_.-``__''-._ <br/>_.-``. _. ''-._ Redis 4.0.14 (00000000/0) 64 bit<br/>.-`` .-```. ```\/ _.,_''-._ <br/>( ', .- | , ) Running in standalone mode<br/>|-._-...- ...-.`-._|' .-'| Port: 6379
- | `-. ._ / _.-'| PID: 7977<br/>-.`-. -./ _.-' _.-'<br/>|-.`-. -.__.-' _.-'_.-'| <br/>|-.`-. .-'.-' | http://redis.io
- -._-._-.__.-'_.-' _.-'<br/>|-.`-. -.__.-' _.-'_.-'| <br/>|-.`-. .-'.-' |
- -._-._-.__.-'_.-' _.-'<br/>-._ `-..-' .-'`-. _.-'
- -.__.-'<br/>7977:M 28 Mar 08:57:56.291 # Server initialized<br/>7977:M 28 Mar 08:57:56.291 * DB loaded from disk: 0.000 seconds<br/>7977:M 28 Mar 08:57:56.291 * Ready to accept connections<br/> 十,[root@centos7 ~]#scp /etc/sysctl.conf 172.18.9.100/200/110:/etc/<br/>[root@centos7 ~]#scp /etc/rc.d/rc.local 172.18.9.100/200/110:/etc/rc.d/<br/>[root@centos7 ~]#chmod a+x /etc/rc.d/rc.local (100\110\200\150)<br/> 十一,[root@centos7 ~]#mkdir /apps/redis/{logs,data,run} -pv<br/>mkdir: created directory'/apps/Redis/logs'<br/>mkdir: created directory'/apps/Redis/data'<br/>mkdir: created directory'/apps/Redis/run'<br/> 十二,[root@centos7 ~]#groupadd -g 1001 redis && useradd -u 1001 -g 1001 redis -s <br/>[root@centos7 ~]#id redis uid=1001(redis) gid=1001(redis) groups=1001(redis)<br/>[root@centos7 ~]#chown redis.redis /apps/redis/ -R 这一步务必完成.<br/> 十三,[root@centos7 ~]#su redis<br/>[redis@centos7 root]$ll /apps/ total 0 drwxr-xr-x. 7 redis redis 63 Mar 28 09:20 redis<br/>[redis@centos7 root]$cd /apps/redis/ 此时, 我们是以普通用户身份登录的 redis.<br/>[redis@centos7 redis]$ll<br/>total 0<br/>drwxr-xr-x. 2 redis redis 134 Mar 27 21:42 bin<br/>drwxr-xr-x. 2 redis redis 6 Mar 28 09:20 data<br/>drwxr-xr-x. 2 redis redis 24 Mar 27 22:07 etc<br/>drwxr-xr-x. 2 redis redis 6 Mar 28 09:20 logs<br/>drwxr-xr-x. 2 redis redis 6 Mar 28 09:20 run<br/> 十四, 我们用普通用户身份启动 redis, 会有 6379 的端口开启, 系系统默认行为.<br/>[redis@centos7 redis]$/apps/redis/bin/redis-server /apps/redis/etc/redis.conf<br/>8676:C 28 Mar 09:41:42.609 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo<br/>8676:C 28 Mar 09:41:42.609 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=8676, just started<br/>8676:C 28 Mar 09:41:42.609 # Configuration loaded<br/>8676:M 28 Mar 09:41:42.612 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.<br/>8676:M 28 Mar 09:41:42.613 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.<br/>8676:M 28 Mar 09:41:42.613 # 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'.<br/>_._ <br/>_.-``__ ''-._ <br/>_.-``. _.''-._ Redis 4.0.14 (00000000/0) 64 bit<br/>.-`` .-```. ```\/ _.,_ ''-._ <br/>(' , .- | , ) Running in standalone mode<br/>|-._-...- ...-.`-._|'.-'| Port: 6379
- | `-. ._ / _.-'| PID: 8676<br/>-.`-. -./ _.-' _.-'<br/>|-.`-. -.__.-' _.-'_.-'| <br/>|-.`-. .-'.-' | http://redis.io
- -._-._-.__.-'_.-' _.-'<br/>|-.`-. -.__.-' _.-'_.-'| <br/>|-.`-. .-'.-' |
- -._-._-.__.-'_.-' _.-'<br/>-._ `-..-' .-'`-. _.-'
- `-.__.-'
- 8676:M 28 Mar 09:41:42.619 # Server initialized
- 8676:M 28 Mar 09:41:42.620 DB loaded from disk: 0.000 seconds
- 8676:M 28 Mar 09:41:42.620 Ready to accept connections
- [root@centos7 ~]#ss -ntl
- State Recv-Q Send-Q Local Address:Port Peer Address:Port
- LISTEN 0 511 127.0.0.1:6379 :
十五, 设置软连接, 这样我们就可以全局执行 Redis 命令了:
- [root@centos7 ~]#ln -sv /apps/Redis/bin//usr/bin/
- '/usr/bin/redis-benchmark' -> '/apps/redis/bin/redis-benchmark'
- '/usr/bin/redis-check-aof' -> '/apps/redis/bin/redis-check-aof'
- '/usr/bin/redis-check-rdb' -> '/apps/redis/bin/redis-check-rdb'
- '/usr/bin/redis-cli' -> '/apps/redis/bin/redis-cli'
- '/usr/bin/redis-sentinel' -> '/apps/redis/bin/redis-sentinel'
- '/usr/bin/redis-server' -> '/apps/redis/bin/redis-server'
十六,[Redis@centos7 Redis]$ VIM etc/Redis.conf bind 0.0.0.0
[Redis@centos7 Redis]$ /apps/Redis/bin/Redis-server /apps/Redis/etc/Redis.conf 重启.
- [root@centos7 ~]#ss -ntl 6379 的端口就会指向任意 IP.
- State Recv-Q Send-Q Local Address:Port Peer Address:Port
- LISTEN 0 511:6379 :
十七,[Redis@centos7 Redis]$ VIM etc/Redis.conf
one:logfile "/apps/redis/logs/redis-6379.log" 日志路径 two:stop-writes-on-bgsave-error no #快照出错时是否禁止 Redis 写入操作
/apps/Redis/bin/Redis-server /apps/Redis/etc/Redis.conf 重启服务
十八, VIM /apps/Redis/etc/Redis.conf
one:dbfilename redis_6379.rdb two:dir /apps/Redis/data 这两处做修改.(dump 文件是 6379 端口下的文件, 数据放 / data / 下)
十九, 重启: 查看端口:
- [root@centos7 ~]#ss -ntl
- State Recv-Q Send-Q Local Address:Port Peer Address:Port
- LISTEN 0 511 127.0.0.1:6379 :
来源: http://www.bubuko.com/infodetail-3003513.html