源码编译装redis

源码编译装redis

1、下载包

在这里插入图片描述
进入官网找到redis-5.0.9

[root@ZZQVM1 ~]# cd /usr/src
[root@ZZQVM1src]#wget http://download.redis.io/releases/redis-5.0.9.tar.gz?_ga=2.234283038.1022079843.1602419660-2097223004.1602165290
[root@ZZQVM1 src]# mv redis-5.0.9.tar.gz\?_ga\=2.234283038.1022079843.1602419660-2097223004.1602165290  redis-5.0.9.tar.gz

2、解压

[root@ZZQVM1 src]# tar xf redis-stable.tar.gz 

3、安装(无需编译-已经有Makefile文件)

[root@ZZQVM1 src]# cd redis-5.0.9
[root@ZZQVM1 redis-5.0.9]# ls
00-RELEASENOTES  deps       README.md        runtest-moduleapi  tests
BUGS             INSTALL    redis.conf       runtest-sentinel   utils
CONTRIBUTING     Makefile   runtest          sentinel.conf
COPYING          MANIFESTO  runtest-cluster  src

(1) 更改文件安装目录

[root@ZZQVM1 redis-5.0.9]# vim src/Makefile		

(2)修改以下加粗内容:
PREFIX?=/usr/local/redis
(3)安装

[root@ZZQVM1 redis-5.0.9]# make && make install
[root@ZZQVM1 redis-5.0.9]# cp redis.conf /usr/local/redis/redi.conf	

4、完成安装启动:

[root@ZZQVM1 redis-5.0.9]# /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf

                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 14681
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

14681:M 10 Oct 2020 13:37:49.221 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
14681:M 10 Oct 2020 13:37:49.221 # Server initialized
14681:M 10 Oct 2020 13:37:49.221 # 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.
14681:M 10 Oct 2020 13:37:49.221 # 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.
# 默认前台运行 Ctrl+D退出修改配置文件
[root@ZZQVM1 redis-5.0.9]# vim /usr/local/redis/redis.conf
# 修改下面内容,进入后台运行
daemonize yes
# 先杀掉进程再启动:
[root@ZZQVM1 redis-5.0.9]# pkill redis-server
[root@ZZQVM1 redis-5.0.9]# /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf

(1)让redis自己管理内存

[root@ZZQVM1 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled

(2)启动麻烦:进去源码安装目录,初始化启动脚本

[root@ZZQVM1 redis-5.0.9]# ls utils/
build-static-symbols.tcl  hashtable          redis_init_script.tpl
cluster_fail_time.tcl     hyperloglog        redis-sha1.rb
corrupt_rdb.c             install_server.sh  releasetools
create-cluster            lru                speed-regression.tcl
generate-command-help.rb  redis-copy.rb      whatisdoing.sh
graphs                    redis_init_script
[root@ZZQVM1 redis-5.0.9]#  ./utils/install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379										
#用6379.conf为以后做多实例做准备(以后可能配多个redis),按错Ctrl+Backspace
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis/6379.conf
# 选择redis的日志文件(自己指定名字自己定)
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/6379.log 
# 指定redis的数据目录(内存的数据库-可以做持久化)
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/6379
# 选择可执行文件的目录
Please select the redis executable path [] /usr/local/redis/bin/redis-server          
Selected config:
Port           : 6379
Config file    : /usr/local/redis/6379.conf
Log file       : /usr/local/redis/6379.log
Data dir       : /usr/local/redis/6379
Executable     : /usr/local/redis/bin/redis-server
Cli Executable : /usr/local/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
/var/run/redis_6379.pid exists, process is already running or crashed
Installation successful
# 先杀掉进程再启动:
[root@ZZQVM1 redis-5.0.9]# pkill redis-server
[root@ZZQVM1 redis-5.0.9]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State 
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp6       0      0 :::111                  :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
# 用脚本启动
[root@ZZQVM1 redis-5.0.9]# /etc/init.d/redis_6379 start
Starting Redis server...
[root@ZZQVM1 redis-5.0.9]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      1449/mysqld         
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      14894/redis-server  
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      858/rpcbind         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1139/sshd           
tcp6       0      0 :::111                  :::*                    LISTEN      858/rpcbind         
tcp6       0      0 :::22                   :::*                    LISTEN      1139/sshd           

5、恭喜已完成redis源码编译安装

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值