Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis memory issue (Kali Linux 2021.2) #118

Closed
m-1-k-3 opened this issue Jun 6, 2021 · 17 comments
Closed

Redis memory issue (Kali Linux 2021.2) #118

m-1-k-3 opened this issue Jun 6, 2021 · 17 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@m-1-k-3
Copy link
Member

m-1-k-3 commented Jun 6, 2021

New Kali Linux is available. We need to test everything on it

https://www.kali.org/get-kali/#kali-platforms

@m-1-k-3 m-1-k-3 added help wanted Extra attention is needed good first issue Good for newcomers labels Jun 6, 2021
@m-1-k-3
Copy link
Member Author

m-1-k-3 commented Jun 7, 2021

In my first installation I had some issues with the cve-database. It needs a complete drop and repopulation:

└─$ sudo ./external/cve-search/sbin/db_updater.py -f

afterwards it was running as expected. Could someone verify this?

I have included this update to our installer: 2c26077

@m-1-k-3 m-1-k-3 closed this as completed Jun 11, 2021
@Humberto-Davila
Copy link

It last just 20 minutes , after crashing multiple times.

redis-server has a maxmemory value of 0, also is not auto started.

'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled'
'To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf / reboot

supervised by systemd - you MUST set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit.

@p4cx
Copy link
Member

p4cx commented Jul 8, 2021

Thank you for your feedback and your solution. Can you please give us some information about your setup? I also had issues with Redis once and solved it by increasing the available storage for my Kali VM from 4GB to 8GB. But I don't know if it's the same problem, so I need additional information from you.

@p4cx p4cx reopened this Jul 8, 2021
@p4cx p4cx added the bug Something isn't working label Jul 8, 2021
@p4cx p4cx changed the title Test Emba on Kali Linux 2021.2 Redis memory issue (Kali Linux 2021.2) Jul 8, 2021
@Humberto-Davila
Copy link

Thank you for your feedback and your solution. Can you please give us some information about your setup? I also had issues with Redis once and solved it by increasing the available storage for my Kali VM from 4GB to 8GB. But I don't know if it's the same problem, so I need additional information from you.

The issue is that redis-server crashes all other process because of the huge memory pages, you cannot limit it because you will broke a dependency method, I tried 5, 8 , 12 GB ram and it is worst 2GB Ram is enough, just set transparent_hugepage to
'madvise' or better to 'never' , do not give permission to make a giant RAM DRIVE to redis.

last time I used transparent_hugepage was in red hat 5

image
image
image
image
Kali Rolling (2021.2) x64 2021-05-31 on WorkStation 16.x VM

Just disable permanently by creating a service.

$sudo nano /etc/systemd/system/disable-thp.service

[Unit]
Description=Disable Transparent Huge Pages (THP)

[Service]
Type=simple
ExecStart=/bin/sh -c "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled && echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag"

[Install]
WantedBy=multi-user.target

$ sudo systemctl daemon-reload
$ sudo systemctl start disable-thp
$ sudo systemctl enable disable-thp

Both Mongo and Redis has the issue with hugepages. so be sure that DBs start after disabling the pages and its defrag.

Kind Regards.

@m-1-k-3
Copy link
Member Author

m-1-k-3 commented Jul 8, 2021

As far as I can see the redis server is started during the installation process (see

/etc/init.d/redis-server start
). Additionally the update script is also able to start the redis server (see
/etc/init.d/redis-server start
). During normal operation redis server is not needed and does not need to be started:

image

@m-1-k-3
Copy link
Member Author

m-1-k-3 commented Jul 8, 2021

2GB of memory is not a lot for emba. Probably we should add a wiki section with hardware requirements.

@Humberto-Davila
Copy link

Humberto-Davila commented Jul 8, 2021 via email

@Humberto-Davila
Copy link

Humberto-Davila commented Jul 8, 2021 via email

@m-1-k-3
Copy link
Member Author

m-1-k-3 commented Jul 8, 2021

I have added a quick prerequisits section to our wiki: https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites

@Humberto-Davila
Copy link

Confirmed , after hugepage disable , it running well.
image

@m-1-k-3
Copy link
Member Author

m-1-k-3 commented Jul 8, 2021

Thank you for your feedback. I will add a link to this thread in our wiki

@m-1-k-3
Copy link
Member Author

m-1-k-3 commented Jul 8, 2021

Thank you for your feedback and your manual on getting everything up and running on less powered hosts.
I have created the following entry in our wiki: https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites
Additionally I have linked your manual in the cve installation area: https://github.com/e-m-b-a/emba/wiki/Installation#cve-search-installation-just-in-case-the-installer-fails

Thanks and keep on using and improving emba :)

@m-1-k-3 m-1-k-3 closed this as completed Jul 8, 2021
@Humberto-Davila
Copy link

Humberto-Davila commented Jul 8, 2021

Thank you for your feedback. I will add a link to this thread in our wiki

Just another parameter needs to be changed in redis-server,

save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behavior will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

save 900 1
save 300 10
save 60 10000

this is ok if you have > 8GB ram, but I suggest 100 seconds per GB / RAM 
eX:  4GB
save 400 100

with 2GB I put:
save 120 1

because just mongo and docker took 90 % of RAM

The Kali Distro just came with a 1GB swap partition, same amount of GB on RAM for swap space will help a lot .

EDIT: Added markdown tags for better readability.

@D4SH0x01
Copy link

cve-search has a problem getting the number of available cores in virtual machines, bypass needs to be set manually set to avoid crashing.

sudo env "WORKER_SIZE=1" ./sbin/db_updater.py -c
or
export WORKER_SIZE=1
or save WORKER_SIZE=1 in a file in /etc/enviroment.d/

this way the queue will be sent to all cores in sync.

Regards

@floyd-fuh
Copy link
Contributor

Just an fyi, this entire thing is still an issue. I also set stop-writes-on-bgsave-error no in /etc/redis/redis.conf to prevent some errors. After the installation fails you can do the following to clean out (maybe add to the installation page on the wiki for us redis noobs?):

# redis-cli
127.0.0.1:6379> FLUSHDB 
OK
127.0.0.1:6379> FLUSHALL 
OK
127.0.0.1:6379> exit
# /etc/init.d/redis-server restart
Restarting redis-server (via systemctl): redis-server.service.
# ./external/cve-search/sbin/db_updater.py -f

And then suddenly the installation ran smoothly.

Off-topic fyi: Your tool depends on netstat, so it is necessary to sudo apt install net-tools on a fresh Ubuntu, maybe make that a dependency

@m-1-k-3
Copy link
Member Author

m-1-k-3 commented Nov 10, 2021

Thank you for your ongoing effort and updates on this redis issue. I will add some notes to the wiki.

Regarding the net-tools: They should get installed:

print_tool_info "net-tools" 1

Could you do a quick check if your EMBA installation is up to date and if the installation of this dep is failing?

@floyd-fuh
Copy link
Contributor

I'm running in a fresh Ubuntu VM and cloned EMBA from git then ran the installer and yes, it seems to have failed to install the net-tools.

I could (untested!) imagine that the way you handle parameters with a dash (-) in it, that it somehow breaks because the dash is interpreted as a command line parameter switch. But that's just wild speculation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants