1、解压redis
[root@localhost app]# tar -zxvf redis-5.0.5.tar.gz2、进入解压好的目录,编译redis
[root@localhost app]# cd redis-5.0.5/ [root@localhost redis-5.0.5]# make MALLOC=libc3、编译安装
[root@localhost redis-5.0.5]# make install cd src && make install make[1]: Entering directory `/home/jqb/app/redis-5.0.5/src' Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]: Leaving directory `/home/jqb/app/redis-5.0.5/src'4、验证是否安装成功
[root@localhost redis-5.0.5]# cd src/ [root@localhost src]# ./redis-server 13897:C 04 Jul 2020 16:49:20.645 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 13897:C 04 Jul 2020 16:49:20.646 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=13897, just started 13897:C 04 Jul 2020 16:49:20.646 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf 13897:M 04 Jul 2020 16:49:20.646 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.5 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 13897 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 13897:M 04 Jul 2020 16:49:20.650 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 13897:M 04 Jul 2020 16:49:20.650 # Server initialized 13897:M 04 Jul 2020 16:49:20.650 # 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. 13897:M 04 Jul 2020 16:49:20.651 # 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. 13897:M 04 Jul 2020 16:49:20.651 * Ready to accept connections5、redis配置
[root@localhost redis-5.0.5]# vim redis.confa、配置后台进程方式启动
daemonize no --> daemonize yesb、设置redis默认设置允许远程连接
bind 127.0.0.1 --> bind 0.0.0.0c、设置reids连接密码
requirepass admin6、指定redis.conf文件启动redis
[root@localhost redis-5.0.5]# ./src/redis-server ./redis.conf1、在etc目录下新建redis目录
[root@localhost redis-5.0.5]# mkdir /etc/redis2、将redis.conf复制到新建目录下,命名为6379.conf
[root@localhost redis-5.0.5]# cp ./redis.conf /etc/redis/6379.conf3、将redis的启动脚本复制一份放到/etc/init.d目录下,命名为redisd
[root@localhost redis-5.0.5]# cp ./utils/redis_init_script /etc/init.d/redisd并在redisd文件里加上下面两行
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
#!/bin/sh # chkconfig: 2345 90 10 # description: Redis is persistent key-value database注释的意思是,redis服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是90,关闭的优先级是10。
1、make[3]: gcc: Command not found
相关依赖未安装
2、直接使用make,报错:zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
make MALLOC=jemalloc
说关于分配器allocator, 如果有MALLOC 这个 环境变量, 会有用这个环境变量的 去建立Redis。
而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。
但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数