CentOS7下编译安装redis-5.0.9

CentOS7下编译安装redis-5.0.9

下载redis
#code start

wget https://download.redis.io/releases/redis-5.0.9.tar.gz

#code end
解压
#code start

tar -zxvf redis-5.0.9.tar.gz

#code end
安装
#code start

cd redis-5.0.9

make && make install

#code end

最后出现如下代码表示成功,路径根据自己的环境可能不同

#code start

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/docker_share/redis-5.0.9/src'
cd src && make install
make[1]: Entering directory `/docker_share/redis-5.0.9/src'
    CC Makefile.dep
make[1]: Leaving directory `/docker_share/redis-5.0.9/src'
make[1]: Entering directory `/docker_share/redis-5.0.9/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 `/docker_share/redis-5.0.9/src'

#code end
配置

复制配置文件到/etc/下

#code start

cp redis.conf /etc/

#code end

新建日志文件地址

#code start

cd /var/log

mkdir redis

cd redis

touch redis.log

#code end

复制redis执行文件到/usr/bin/下

#code start

cd src

cp redis-cli redis-benchmark redis-server /usr/bin

#code end

修改默认配置文件

#code start

vim /etc/redis.conf

#修改默认客户端最长连接时间。修改为30分钟
timeout 1800

#修改以守护进程的方式启动。默认为no
daemonize yes

# 设置日志文件的地址,跟上面的设置地址一样
logfile "/var/log/redis/redis.log"

#允许其他机器上的客户端连接当前redis
protected-mode no

#修改redis密码
requirepass redisPassword

#code end
设置开机启动
#code start

vim /usr/lib/systemd/system/redis.service

#启动代码
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf
ExecStop=/usr/bin/redis-cli shutdown
#Restart=always
Type=forking
#User=redis
#Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target

#code end
设置开机启动并启动redis
#code start

#开机启动
systemctl enable redis

#启动redis
systemctl start redis

#code end
启动redis
#code start

systemctl start redis

#code end
查看redis日志
#code start

cd /var/log/redis

cat redis.log

#code end

显示日志内容如下

#code start


8118:C 03 Apr 2021 04:38:52.898 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
8118:C 03 Apr 2021 04:38:52.898 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=8118, just started
8118:C 03 Apr 2021 04:38:52.898 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 8119
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

8119:M 03 Apr 2021 04:38:52.901 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
8119:M 03 Apr 2021 04:38:52.902 # Server initialized
8119:M 03 Apr 2021 04:38:52.902 # 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.
8119:M 03 Apr 2021 04:38:52.902 * Ready to accept connections

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值