从官方网站下载安装包
wget http://download.redis.io/releases/redis-3.2.6.tar.gz
解压、进入目录编译
运行 install_server.sh
的时候会提示你配置redis端口号、配置文件路径等输入项。这里假设端口号为6666,配置文件为/etc/redis/6666.conf
。
最终在生成启动文件/etc/init.d/redis_6666
。
通过/etc/init.d/redis_6666 start
可以读取配置文件启动redis,直接运行redis-server
也是可以启动的,只不过这个时候是使用默认配置,而不是读取配置文件。
如果你直接运行redis-server
的话,就有可能爆出一堆警告。
22325:C 20 Feb 17:08:02.790 # Warning: no config file specified,using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf
22325:M 20 Feb 17:08:02.792 * 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: 22325
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
22325:M 20 Feb 17:08:02.792 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
22325:M 20 Feb 17:08:02.792 # Server started,Redis version 3.2.8
22325:M 20 Feb 17:08:02.792 # 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.
22325:M 20 Feb 17:08:02.792 # 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.
22325:M 20 Feb 17:08:02.792 * The server is now ready to accept connections on port 6379
按照他的提示一点点修改一下。最后将其添加到开机启动项,在/etc/rc.local添加如下配置:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
/etc/init.d/redis_6879 start
原文链接:https://www.f2er.com/note/421014.html