Centos: there are many 'httpd start' process - linux

I found that my server is very slow,I used 'ps au' to show all the processes. There are a lot of /usr/local/apache/bin/httpd -k start running.
How could I fix this problem?
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 195536 10040 ? Ss 6月11 40:57 /usr/lib/systemd/systemd --switched-root --system --d
root 2 0.0 0.0 0 0 ? S 6月11 0:00 [kthreadd]
nobody 31295 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31296 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31297 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31299 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31303 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31310 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31312 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31314 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31315 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31316 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31320 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31324 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31326 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31328 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31329 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31330 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31331 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31332 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31333 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31335 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31338 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31339 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31341 0.0 0.0 97160 6208 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31346 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31364 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31370 0.0 0.0 97028 5036 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31373 0.0 0.0 97028 5040 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31374 0.0 0.0 97028 5044 ? S 11:02 0:00 /usr/local/apache/bin/httpd -k start
nobody 31416 0.0 0.0 97028 5048 ? S 11:03 0:00 /usr/local/apache/bin/httpd -k start
nobody 31418 0.0 0.0 97028 5044 ? S 11:03 0:00 /usr/local/apache/bin/httpd -k start
nobody 31422 0.0 0.0 97028 5044 ? S 11:03 0:00 /usr/local/apache/bin/httpd -k start
nobody 31423 0.0 0.0 97028 5044 ? S 11:03 0:00 /usr/local/apache/bin/httpd -k start
dovecot 31461 0.0 0.0 27940 2232 ? S 11:04 0:00 dovecot/auth
root 31525 0.0 0.0 82012 11368 ? S 11:04 0:00 /usr/local/cpanel/3rdparty/bin/perl /usr/local/cpanel/
nobody 31578 0.0 0.0 97028 4800 ? S 11:04 0:00 /usr/local/apache/bin/httpd -k start
nobody 31579 0.0 0.0 97028 5048 ? S 11:04 0:00 /usr/local/apache/bin/httpd -k start

You can use process control the worker by using the following directives:
ServerLimit 16
StartServers 2
MaxRequestWorkers 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
Set values accordingly.

Related

Can you take a thread dump of a non-java process?

I have done quite a bit of research, and cant find any documentation on this. I may be using the wrong terminology with the term "thread dump", so I apologize for any lack of knowledge on this topic.
I am looking for a way to take a thread dump of an Apache webserver running on an RHEL AWS instance. The Apache webserver is running on the httpd process. From my understanding, tools like jstack and jmap are specific to taking thread dumps of JVM processes only, and httpd is not compatible.
When I use ps -aux | grep apache I receive the following output of processes.
ps -aux | grep apache
ssm-user 1539 0.0 0.0 112812 960 pts/1 S+ 17:26 0:00 grep apache
apache 1554 0.0 0.2 272752 15488 ? S 16:12 0:00 /usr/sbin/httpd -DFOREGROUND
apache 1713 0.0 0.1 270376 13452 ? S 16:13 0:00 /usr/sbin/httpd -DFOREGROUND
apache 1715 0.0 0.1 270376 13452 ? S 16:13 0:00 /usr/sbin/httpd -DFOREGROUND
apache 1956 0.0 0.1 270556 14080 ? S 13:16 0:00 /usr/sbin/httpd -DFOREGROUND
apache 5700 0.0 0.2 272752 15704 ? S May22 0:00 /usr/sbin/httpd -DFOREGROUND
apache 5701 0.0 0.2 272996 16064 ? S May22 0:00 /usr/sbin/httpd -DFOREGROUND
apache 5703 0.0 0.1 270676 14368 ? S May22 0:00 /usr/sbin/httpd -DFOREGROUND
apache 5704 0.0 0.2 272720 15636 ? S May22 0:00 /usr/sbin/httpd -DFOREGROUND
apache 11441 0.0 0.2 272776 15744 ? S 04:55 0:00 /usr/sbin/httpd -DFOREGROUND
apache 11442 0.0 0.2 272800 15832 ? S 04:55 0:00 /usr/sbin/httpd -DFOREGROUND
I am also unsure why there are so many of the same process, but I wanted to figure out if its possible to take a thread dump of one of the processes before I dive into solving the duplicate processes.
Are there any tools or commands I can use to accomplish a thread dump of an httpd process?

How do I find the name of a process in linux?

I'm really struggling with how to find processes by name in linux. I'm sure it's probably something simple that I'm missing.
Are you looking for the command ps ?
Here an example
nabil#LAPTOP:~$ ps xua | grep python
rootwsl 327 0.0 0.1 29568 17880 ? Ss Jan30 0:02 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
rootwsl 411 0.0 0.1 108116 20740 ? Ssl Jan30 0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
nabil 106387 0.0 0.0 3444 736 pts/1 S+ 23:26 0:00 grep --color=auto python

rsync daemon behaving eratically

I'm running an rsync daemon (providing a mirror for the SaneSecurity signatures).
rsync is started like this (from runit):
/usr/bin/rsync -v --daemon --no-detach
And the config contains:
use chroot = no
munge symlinks = no
max connections = 200
timeout = 30
syslog facility = local5
transfer logging = no
log file = /var/log/rsync.log
reverse lookup = no
[sanesecurity]
comment = SaneSecurity ClamAV Mirror
path = /srv/mirror/sanesecurity
read only = yes
list = no
uid = nobody
gid = nogroup
But what I'm seeing is a lot of "lingering" rsync processes:
# ps auxwww|grep rsync
root 423 0.0 0.0 4244 1140 ? Ss Oct30 0:00 runsv rsync
root 2529 0.0 0.0 11156 2196 ? S 15:00 0:00 /usr/bin/rsync -v --daemon --no-detach
nobody 4788 0.0 0.0 20536 2860 ? S 15:10 0:00 /usr/bin/rsync -v --daemon --no-detach
nobody 5094 0.0 0.0 19604 2448 ? S 15:13 0:00 /usr/bin/rsync -v --daemon --no-detach
root 5304 0.0 0.0 11156 180 ? S 15:15 0:00 /usr/bin/rsync -v --daemon --no-detach
root 5435 0.0 0.0 11156 180 ? S 15:16 0:00 /usr/bin/rsync -v --daemon --no-detach
root 5797 0.0 0.0 11156 180 ? S 15:19 0:00 /usr/bin/rsync -v --daemon --no-detach
nobody 5913 0.0 0.0 20536 2860 ? S 15:20 0:00 /usr/bin/rsync -v --daemon --no-detach
nobody 6032 0.0 0.0 20536 2860 ? S 15:21 0:00 /usr/bin/rsync -v --daemon --no-detach
root 6207 0.0 0.0 11156 180 ? S 15:22 0:00 /usr/bin/rsync -v --daemon --no-detach
nobody 6292 0.0 0.0 20544 2744 ? S 15:23 0:00 /usr/bin/rsync -v --daemon --no-detach
root 6467 0.0 0.0 11156 180 ? S 15:25 0:00 /usr/bin/rsync -v --daemon --no-detach
root 6905 0.0 0.0 11156 180 ? S 15:29 0:00 /usr/bin/rsync -v --daemon --no-detach
(it's currently 15:30)
So there's processes (not even having dropped privileges!) hanging around since 15:10, 15:13 and the like.
And what are they doing?
Let's check:
# strace -p 5304
strace: Process 5304 attached
select(4, [3], NULL, [3], {25, 19185}^C
strace: Process 5304 detached
<detached ...>
# strace -p 5797
strace: Process 5797 attached
select(4, [3], NULL, [3], {48, 634487}^C
strace: Process 5797 detached
<detached ...>
This happended with both rsync from Ubuntu Xenial as well as installed from PPA (currently using rsync 3.1.2-1~ubuntu16.04.1york0 )
One process is created for each connection. Before a client selects the module the process does not know if it should drop privileges.
You can easily create such a process.
nc $host 873
You will notice that the connection will not be closed after 30s because the timeout is just a disk i/o timeout. The rsync client have a --contimeout option, but it seems that a server side option is missing.
In the end, I resorted to invoking rsync from (x)inetd instead of running it standalone.
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/timeout
server_args = -k 60s 60s /usr/bin/rsync --daemon
log_on_failure += USERID
flags = IPv6
}
As an additional twist, I wrapped the rsync invocation with timeout, adding another safeguard against long-running processes.

nginx is installed but site does not load

I installed LEMP with this tutorial I have done all it says but when I enter my server ip address in my browser it takes some time to load the page and it seems like my browser is doing some processes to load the page but at last the page is blank.
I'v checked all the installation again and they were all installed.
I'v installed apache at the past and I know for apache server if you enter server ip address it shows " apache is functioning " but It's my first time installing nginx ; I want to install DirectAdmin and I don't know nginx is installed or not.
If anyone is familiar with nginx and can help me, I'll be apreciate that.
Update: When I use service nginx status it shows nginx is running.
Update: Flowing are the results of my checkings:
Results of netstat -tulpn | grep :80 :
tcp 0 0 0.0.0.0:80 0.0.0.0:* LIST EN 10302/nginx
Results of ps aux | grep nginx :
nginx 8556 0.0 0.0 222416 3552 ? S 09:04 0:00 php-fpm: pool w ww
nginx 8557 0.0 0.0 222416 3552 ? S 09:04 0:00 php-fpm: pool w ww
nginx 8558 0.0 0.0 222416 3552 ? S 09:04 0:00 php-fpm: pool w ww
nginx 8559 0.0 0.0 222416 3552 ? S 09:04 0:00 php-fpm: pool w ww
nginx 8560 0.0 0.0 222416 3552 ? S 09:04 0:00 php-fpm: pool w ww
root 10302 0.0 0.0 96032 1980 ? Ss 09:11 0:00 nginx: master p rocess /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 10304 0.0 0.0 96436 2692 ? S 09:11 0:00 nginx: worker p rocess
nginx 10305 0.0 0.0 96436 2692 ? S 09:11 0:00 nginx: worker p rocess
nginx 10306 0.0 0.0 96436 2660 ? S 09:11 0:00 nginx: worker p rocess
nginx 10307 0.0 0.0 96436 2672 ? S 09:11 0:00 nginx: worker p rocess
root 12564 0.0 0.0 103312 856 pts/0 S+ 09:59 0:00 grep nginx
FIIIIINNNNNNAAAAAALLLLLLLY I Found the problem!
The problem was with my firewall.
If anyone else has the same problem it may be the firewall settings problem like mine So Do the flowing to fix this:
vim /etc/sysconfig/iptables
in the opened file find this line :
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
Check that --dport 80 is set to the port that you entered in /etc/nginx/conf.d/default.conf if its something else like --dport 22 change it to your default port.
Update:
After you changed the port you should run this code:
service iptables restart
And this is the page shows nginx is running :

Multiple apache and finding its ports

The following command
[cuser#vdev-b7-5461-4f3c-9d98-7fc3ec6 kafka]$ ps aux|grep apache
apache 3967 0.0 0.0 175412 3192 ? S 03:40 0:00 /usr/sbin/httpd -k start
apache 3968 0.0 0.0 175412 3192 ? S 03:40 0:00 /usr/sbin/httpd -k start
apache 3969 0.0 0.0 175412 3192 ? S 03:40 0:00 /usr/sbin/httpd -k start
apache 3970 0.0 0.0 175412 3192 ? S 03:40 0:00 /usr/sbin/httpd -k start
apache 3971 0.0 0.0 175276 2700 ? S 03:40 0:00 /usr/sbin/httpd -k start
apache 3972 0.0 0.0 175276 2700 ? S 03:40 0:00 /usr/sbin/httpd -k start
apache 3974 0.0 0.0 175412 3188 ? S 03:40 0:00 /usr/sbin/httpd -k start
apache 3975 0.0 0.0 175276 2696 ? S 03:40 0:00 /usr/sbin/httpd -k start
clduser 9566 0.0 0.0 103244 844 pts/1 S+ 16:41 0:00 grep apache
There are multiple apache process running in my machine. Is there a way for me to determine the files/directory each of these process uses to run it?
Also, would like to know the ports that they are using?
[user#vdev-37-5461-4f3c-9d98-7af28dfc3ec6 kafka]$ netstat -tulpn|grep 80
(No info could be read for "-p": geteuid()=500 but you should be root.)
tcp 0 0 :::80 :::* LISTEN -
This above command shows port 80 is being used but I want to know what process is using it?
[duser#vpsq-dev-4ac0b737-5461-4f3c-9d98-7af28dfc3ec6 kafka]$ find / -iname apache 2>/dev/null
/opt/logstash/vendor/bundle/jruby/1.9/gems/jruby-kafka-1.4.0-java/lib/org/apache
/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-0.1.18-java/lib/org/apache
/opt/logstash/vendor/bundle/jruby/1.9/gems/jruby-kafka-1.1.2-java/lib/org/apache
/home/duser/logstash-1.5.0.rc2/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-0.1.18-java/lib/org/apache
/home/duser/logstash-1.5.0.rc2/vendor/bundle/jruby/1.9/gems/jruby-kafka-1.1.2-java/lib/org/apache

Resources