redis centos8 yum 安装 支持systemctl 启动

一、记录相关命令

1.    ps aux | grep redis     #查看redis是否运行

      ps -ef | grep redis      #查看redis是否运行

2.    whereis redis-cli    #查看 是否安装 redis-cli

       whereis redis-server  # 查看是否安装 redis-server

3.     redis-server &                #启动redis ,加上`&`号使redis以后台程序方式运行

4.     netstat -lntp | grep 6379   #查看redis 端口是否监听

5.     redis-cli     # 使用cli命令行进行登录

6.      redis-cli shutdown #关闭redis

7.      redis-server --version   #查看redis版本

         redis-server -v     #查看redis版本

二、安装

(1)以yum方式安装  环境centos8
1. yum install redis   #安装
2. systemctl start redis  #启动
3. systemctl enable redis  #开机自启动
4.  systemctl status redis  #查看状态

三、通过指定配置文件启动

1.  whereis redis.cnf   #查看redis.cnf配置文件路径
2.  vim  /etc/redis.conf  #vim 进行编辑
    
    port 1234  #指定端口
    daemonize yes #修改daemonize为yes,即默认以后台程序方式运行
    logfile /home/log/redis/redis.log    #修改日志文件路径
    dir /home/data/redis                  #修改持久化文件存放路径
    requirepass abcd123                   #修改redis登录密码
    supervised systemd # 可以跟systemd进程进行交互

3.  redis-server /etc/redis.conf   #通过指定配置文件进行启动
    > auth "asdddsds"   #输入密码进行登录(如果配置密码的话,没有请忽略)

四、创建redis服务以systemctl 形式进行启动

1.    vi /lib/systemd/system/redis.service  #编辑
2.原有文件备份
[Unit]
Description=Redis persistent key-value database
After=network.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
ExecStop=/usr/libexec/redis-shutdown
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
3.  vi /lib/systemd/system/redis.service  #编辑
###########修改如下。如需要复制粘贴,此行省略;注意 ExecStart路径配置成自己的
[Unit]
Description=Redis persistent key-value database
After=network.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Type=forking
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
4.   systemctl daemon-reload   #重新加载service文件
5.  systemctl  start redis     #启动
6.  systemctl status redis     #查看状态
7.  systemctl enable redis.service  # 配置自启动


      

五、注意

1.NOAUTH Authentication required

   答: 需要密码进行登录 。  命令:auth  "密码";

2.启动警告

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

解决: echo 511 >/proc/sys/net/core/somaxconn

            echo "net.core.somaxconn = 551" > /etc/sysctl.conf

3.启动警告

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.

解决:    echo never > /sys/kernel/mm/transparent_hugepage/enabled

vi /ect/rc.local
##################添加以下内容###################
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defragfi

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值