Killing a mysqld process causes another mysqld process to immediately start - mamp

I'm having an issue starting the MySQL server using MAMP, and the problem may be that I can't seem to kill all my mysqld proceses before I open MAMP. Starting MAMP creates a second, conflicting mysqld process. Before opening MAMP, I use killall -9 mysqld, but that only creates another mysqld process with a different processid. Any idea what's causing the mysqld process to be created? I installed mysql after installing MAMP.

I uninstalled mysql, and then everything worked.

Related

Why Mongo Auto Restart after Shutdown

I tried to shut down my mongo process on a Linux server by running either mongod.sh stop or mongo --shutdown.
From the logs, I can see it shutting down with code:0
However, after that line, it logged **** SERVER RESTARTED ****, and then started a new process logging MongoDB starting: pid=xxxxx port=xxxxx dbpath=xxxxxxxxx 64-bit host=xxxxxxxx, which is not expected.
I tried on other instances using the same command, all of them were successfully shut down with only one line of **** SERVER RESTARTED ****, and nothing was logged after that.
Is there anyone knowing what possibly happened in this case? What can I do to disable this automatic restart after stopping the mongo process gracefully?
MongoDB is installed as a service.
For stop and disable use:
systemctl stop mongod
systemctl disable mongod

Clean shutdown of the mongod process

My mongodb run under Linux 6. I use the command db.shutdownServer() to close the database but the mongod process does not stop.
Stopping mongo directly with service mongod stop do a clean shutdown?
Thanks for your help
Proper ways to shutdown mongod is described in the documentation. They are:
Use shutdownServer()
From the mongo shell
use admin
db.shutdownServer()
Use --shutdown
From the Linux command line
mongod --shutdown
Use CTRL-C
When running the mongod instance in interactive mode, issue Control-C
Use kill
From the Linux command line
kill mongoProcessID
kill -2 mongodProcessID
So you need to figure out how /etc/init.d/mongodb stop actually stops the process on your Linux distribution. For example, on Debian it uses the wrapper which behaves similar to killall which is a proper method.
As per the documentation of mongodb, mongod --shutdown will work on linux system, but, on Mac, the --shutdown switch is not recognised. However, per the documentation, Ctrl+C will cleanly shutdown the db server. When you do a Ctrl+C on the same terminal where the db server is running, it initiates a dozen or so signalProcessingThread which indicates that the shutdown is proper and smooth. At the end, you can see that the process exits with code:0. Per the convention, Ctrl+C is awkward, but is clean, although not seemingly graceful.

FATAL ERROR lock file "postmaster.pid" already exists

I have recently installed PostGIS on my Mac (El Capitan 10.11.4, Postgres is version 9.5.1) using Homebrew, and I am following these instructions - http://morphocode.com/how-to-install-postgis-on-mac-os-x/
When I try to start Postgres using
pg_ctl -D /usr/local/var/postgres start
I get the following error:
$ FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 280) running in data directory "/usr/local/var/postgres"?
So I spent a few hours researching how to address this, but to no avail.
Notably, I tried to kill the PID as recommended in an answer on Superuser - https://superuser.com/questions/553045/fatal-lock-file-postmaster-pid-already-exists- (in the case above, I ran kill 208), but as soon as I tried to start Postgres again, I got the same error, albeit with a different PID number. I saw a few people recommended deleting the postmaster.pid file, but I feel like maybe I should save that as a last resort...
Admittedly part of the reason I'm not sure how to fix this is that I'm not really clear on what the postmaster even is - I'm just starting to learn about all of this.
Hopping into a Postgres database via the psql db_name command works just fine, for what it's worth.
Posting this in case it helps someone else:
I was having this same problem as the OP after a hard reboot when my laptop crashed. What helped me was running the following command to see what PID was associated with postmaster.pid:
cat /usr/local/var/postgres/postmaster.pid
The first number that appears will be the PID. Looking in Activity Monitor, I was able to see that Postgres was running, but without a PID number that matched the one shown.
Instead of the steps outlined in the answer referenced on Superuser, I restarted my laptop properly and then opened up Terminal and ran
brew services restart postgresql
This worked without having to remove postmaster.pid, which I saw a few other posts recommend. Sometimes it's the simple solutions that work.
I add here what worked for me, after a long time of searching:
Delete the postmaster.pid file:
rm /usr/local/var/postgres/postmaster.pid
Restart your postgres:
brew services restart postgresql
Hope this helps someone ...
Update 8/2022:
As Mike commented, for M1 Mac you would replace stage 1 with:
rm /opt/homebrew/var/postgresql/postmaster.pid
With M1 and specify Postgres Version # 14
rm -rf /opt/homebrew/var/postgresql#14/postmaster.pid
It often happens to me in OSx, when my system shutdown unexpectedly.
You can just remove the file postmaster.pid.
cd Library/Application Support/Postgres/var-{postgres-version}
and remove the postmaster.pid file
in case you use brew then your path should be something like:
/usr/local/var/postgres/postmaster.pid
restart the Postgres by using this command
pg_ctl -D /usr/local/var/postgres restart
Since you can connect to the database, you don't need to start the server again - it's already running.
pg_ctl is used to control the PostgreSQL server. Since your server is already started, your command:
pg_ctl -D /usr/local/var/postgres start
Returns an error, saying that there is a lock on postmaster.pid - which is true since there is already a server running under that PID.
There are two ways:
The most basic way - skip that step, your server is already running!
Executing a needless operation - stopping the server, and then starting it again.
You could stop your server doing :
pg_ctl -D /usr/local/var/postgres stop
So that you won't have the lock on postmaster anymore and you could use your command to start it again.
Postmaster is the main PostgreSQL process. You're trying to start PostgreSQL that's already running (and you're saying yourself you can connect to it). Just skip that step of your process.
When the system shutdown unexpectedly, my postgres crashs and i'm unable to connect to it.
What worked for me was:
1˚ Check postgres log:
tail -n 10000 /usr/local/var/log/postgres.log
2˚ Find the PID of postgress, should look like this:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 707) running in data directory "/usr/local/var/postgres"?
3˚ Kill that process:
kill 707
4˚ Restart your postgres
brew services restart postgresql
After those steps i was able to connect to the database within my rails application.
If you got no important data to lose :
sudo killAll postgres
brew services restart postgresql
AGAIN : You could get data corrupted by doing this !
do it at your own risk !
I am using mac and these step work for me:-
step1: cd Library/Application\ Support/Postgres
(most commonly your Postgres installation will be located here)
step2: cd var-13
(if you are using version 12 then use cd var-12. Hope got the point)
step3: ls
(As you can see among the files you find the postmaster.pid, perfect.)
step4: rm postmaster.pid
When you have removed the stale postmaster.pid file you can restart PostgreSQL and everything should work as normal.
My OSX laptop had shutdown unexpectedly, and I was getting a stale postmaster.pid error in the PostgresApp. Shutting down my laptop and turning it back on again solved the problem.
After running the following commands
rm /usr/local/var/postgres/postmaster.pid
brew services restart postgresql
The error lock file "postmaster.pid" already exists comes up again.
When we run launchctl list | grep postgres
28618 0 homebrew.mxcl.postgresql
The existing file "postmaster.pid" was created by this daemon process hosted by launchctl.
We try to stop the homebrew.mxcl.postgresql through
sudo launchctl stop homebrew.mxcl.postgresql
launchctl disable homebrew.mxcl.postgresql
Unfortunately, none of them could stop the homebrew.mxcl.postgresql.
The reason is Disable and enable an agent using (persists between boots)
https://apple.stackexchange.com/questions/105892/disable-services-in-osx-services-msc
launchctl enable <name> or launchctl disable <name>
Two ways to solve it when the error lock file "postmaster.pid" already exists comes up again
In order to stop an agent immediately through
launchctl kill homebrew.mxcl.postgresql
Restart your desktop and run brew services start postgresql#14. Now, PostgreSQL could start successfully.
Hope it could help someone who met the same issue again.
This worked for me. First locate postmaster.pid (for me it was in the var directory as seen below, although it will be different on depending on your operating system). Then get rid of postmaster.pid, then kill the postgres process, then start/restart postgres service.
cd /var/lib/pgsql/data/
rm postmaster.pid
sudo pkill -u postgres
sudo systemctl start postgresql.service
If you have installed postgres with brew then simply run the following command and it will manage everything
brew services restart postgresql

Mongo 2.6.3 does not start on init

On fresh install of Ubuntu 14.04, I have installed mongodb 2.6.3 from mongo package,
problem is, that it does not start on reboot. It starts normally when I do
sudo service mongod start
and there are no errors in log file.
but when I reboot, log file has no new entries and
service mongod status
produces
mongod stop/waiting
I have tried mongod --repair, with no effect. I have tried fresh install of Ubuntu 14.04, as I thought that my older many times upgraded OS might have something wrong with it, but nothing changed.
With older version mongo that comes from ubuntu package manager, everything was starting up nicely.
Can you please give some advice on where to look to fix this issue and make mongod start up when system is booted up. Thanks!
Had the same problem. In the log file there was an:
************
Unclean shutdown detected
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
************
To solve this error, I just removed the lock file and it worked again.
sudo rm /var/lib/mongodb/mongod.lock
I believe the issue is that mongo upstart job checks if mongo is installed by the package manager. You need to edit the upstart job to use the new from-source binary location (which I think is /opt/mongodb/bin/mongod).

Eclipse hanging, how to kill it properly?

Sometimes my Eclipse hangs and I need to kill it violently. However, I have been unable to do it properly. It seems that kill -9 does not actually shut it down in a proper way since I can still see the hanged window. What command sequence would kill my Eclipse properly so I could restart it?
I am running Ubuntu 12.10 and Eclipse 4.2(Juno).
You can also use jps -l to get all of the process id's of java processes
You need to kill the javaw process on which Eclipse runs (usually it is the one with about 1GB memory usage :) )
Based on the answer of Uku and Michael you can do the following:
On your terminal first run:
jps -l
Check the pid of the process that is running Eclipse and copy the pid.
Then kill the process id by running:
// use the actual process id
kill -p {the_copied_pid}