无法在Centos 7上启动redis服务器

ryhaxcpt  于 2022-11-07  发布在  Redis
关注(0)|答案(3)|浏览(402)

我尝试安装OpenVas,但在CentOS上启动Redis服务器时遇到问题。我该怎么做才能解决问题?
我通过运行来安装openvas(这会安装redis和所有其他依赖项):


# yum install openvas

我试着运行以下命令来启动它:


# systemctl enable redis && systemctl restart redis

我通过运行以下命令来检查systemctl状态日志中是否有redis:


# systemctl status redis -l

显示连接被拒绝,无法启动:

Mar 19 12:37:13 hostname.local systemd[1]: Started Redis persistent key-value database.
Mar 19 12:37:13 hostname.local systemd[1]: Starting Redis persistent key-value database...
Mar 19 12:37:14 hostname.local systemd[1]: redis.service: main process exited, code=exited, status=1/FAILURE
Mar 19 12:37:14 hostname.local redis-shutdown[19127]: Could not connect to Redis at 127.0.0.1:6379: Connection refused
Mar 19 12:37:14 hostname.local systemd[1]: redis.service: control process exited, code=exited status=1
Mar 19 12:37:14 hostname.local systemd[1]: Unit redis.service entered failed state.
Mar 19 12:37:14 hostname.local systemd[1]: redis.service failed.
nhjlsmyf

nhjlsmyf1#

首先,查看/var/log/redis/redis. log
我尝试设置与此职位https://forums.atomicorp.com/viewtopic.php?f=31&t=8047

1) Disable SELINUX.
Edit /etc/selinux/config, save and reboot
2) Add required packages
yum install wget bzip2 texlive net-tools alien
3) Add Atomicorp repo
wget -q -O - http://www.atomicorp.com/installers/atomic | sh
4) Install OpenVAS 
yum install openvas
5) edit /etc/redis.conf. Add/uncomment the following
unixsocket /tmp/redis.sock
unixsocketperm 700
6) Restart Redis
systemctl enable redis && systemctl restart redis

redis ip启动并运行

[root@localhost ~]# cat /var/log/redis/redis.log
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 3.2.3 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 29645
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

29645:M 21 Mar 14:55:00.551 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
29645:M 21 Mar 14:55:00.551 # Server started, Redis version 3.2.3
29645:M 21 Mar 14:55:00.551 # 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.
29645:M 21 Mar 14:55:00.551 # 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.
29645:M 21 Mar 14:55:00.551 * The server is now ready to accept connections on port 6379
bjg7j2ky

bjg7j2ky2#

SELinux是否已启用?您可以使用以下命令进行检查:

$ getenforce

如果是“强制执行”,则可能是SELinux策略阻止了redis,您是否也可以检查/etc/redis.conf?找到以“unixsocket”开头的行,如果是/tmp/redis.sock,请尝试将其更改为“/var/run/redis/redis. sock”:

unixsocket /var/run/redis/redis.sock

然后重新启动redis服务器,检查服务器状态,OpenVAS设置需要redis监听unix套接字。

wwodge7n

wwodge7n3#

CentOs 8配置专用网络
1.更新防火墙服务以允许来自专用网络的传入连接:
sudo firewall-cmd --永久--区域=受信任--更改接口= ens 7
2.创建一个systemd服务来延迟Redis的启动,直到私有接口启动并分配了IP地址

sudo nano /etc/systemd/system/redis.service.d/wait-for-ips.conf

1.将以下文本粘贴到文件中,然后保存并关闭该文件:
[单位]之后=网络联机.目标想要=网络联机.目标
1.重载服务
sudo systemctl守护程序-重新加载
1.重新启动服务
sudo systemctl重新启动redis服务
感谢您发送编修。

相关问题