How to stop and restart memcached server 1.4.5 in linux OS from command line?
Using root, try something like this:
/etc/init.d/memcached restart
Log in as root or do
su -
Then:
service memcached restart
If that doesn't work, then:
/etc/init.d/memcached restart
It all depends on which Linux distro (or other OS) you're using.
If you're using homebrew:
brew services restart memcached
sudo service memcached stop
sudo service memcached start
sudo service memcached restart
if linux
if install by apt-get
service memcached stop
service memcached restart
if install by source code
Usage: /etc/init.d/memcached {start|stop|restart|force-reload|status}
can also simply kill $pid to stop
sudo /etc/init.d/memcached restart
As root on CentOS 7:
systemctl start memcached
systemctl stop memcached
systemctl restart memcached
To tell the service to start at reboot (ex chkconfig):
systemctl enable memcached
To tell the service to not start at reboot:
systemctl disable memcached
To shutdown memcache daemon:
sudo service memcached stop
To start memcached daemon:
sudo service memcached start
Restart memcached server:
sudo service memcached restart
You can see if Memcache is currently runing:
sudo ps -e | grep memcached
And you can check the TCP or UDP ports if something (e.g. Memcache) is listening to it:
netstat -ap | grep TheChosenPort#
netstat -ap | grep 11211
For some Linuxes you need to change your commands like:
sudo /etc/init.d/memcached start
sudo /etc/init.d/memcached restart
sudo /etc/init.d/memcached stop
If you want to be allowed to shutdown the memcached server you can give it that option before start it :
memcached -A &
With this option when you connect to memcached server for example:
telnet localhost 11211
then you can use shutdown command to shutdown the server. You can also shutdown the memcached server when it is run as a process, first find the process PID using:
pidof memcached
then use:
kill PID command
This worked for me:
brew services stop memcached
If you have an older version of memcached and need a script to wrap memcached as a service, here it is:
Memcached Service Script
For me, I installed it on a Mac via Homebrew and it is not set up as a service. To run the memcached server, I simply execute memcached -d. This will establish Memcached server on the default port, 11211.
> memcached -d
> telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
version
VERSION 1.4.20
Related
I have two mongoDBs running on port 27017 and 27018 and now it happened twice, that someone patched the server (Red Hat Enterprise Linux Server release 7.8 Maipo ) and the configuration of mongodb has been lost, so I had to fix it manually by
mongod -port 27017 -config /etc/mongod.conf
mongod -port 27018 -config /etc/mongod_second.conf
Can you tell me who is responsible for that issue, so that this configuration is set automatically?
Do I need to
enable the mongod as a service, so it start up with the right configuration after every patch of the server?
an sudo systemctl enable mongod is not working for me
or
tell the admin who is patching the server to run this mongod -port 27018 - config ... everytime he is restarting the server
Thanks for your help
MongoDB provides installation instructions. Follow them to get the database properly installed. Then edit the configuration file instead of passing arguments when starting mongod.
I am trying to connect to my MongoDB database in localhost. While I type mongo in command shell I am getting an error in the command shell:
js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it. :
connect#src/mongo/shell/mongo.js:341:17
This will start the mongo server as a service:
brew services start mongodb-community
command mongod will run the MongoDB server using the default configuration. You can change these configurations by locating the default path of the configuration files.
The primary daemon process for the MongoDB database system is called mongod. You need to start this service before making connection attempts.
You can do this in Ubuntu by:
sudo service mongod start
or,
sudo systemctl start mongod
Start mongod on system boot by:
systemctl enable mongodb.service
I had the same issue.
When running mongod command, it mentioned the C:/data/db as E:/data/db path.
After I created the folder in mentioned E:/data/db path it works!
For windows user
1. Type ctrl + r
2. Scroll to mongodb server
3. start the server
do you have a linux distro? If you do, the solution is a bit annoying as you have to do it everytime you start your pc. The solution is:
Type "mongo" and "mongod" once in the terminal. It will show an error, don't worry, that's the whole point
type this:
chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart
tip: copy the whole thing and paste on the terminal using ctrl+shift+v. You're welcome :-)
I am trying to use mongoDB in Linux mint 19. But I am getting below error.
What is the solution ?
You're starting the mongo shell client, which by default tries to connect to a mongod server running on localhost and listening on port 27017. However, there is no server listening there so the mongo shell notes that and exits.
You'll need to investigate why there was no mongod server listening there:
The MongoDB Server package isn't installed
You're specifying a non-default port in e.g. /etc/mongod.conf
The mongod process/service is not running
...
First verify that the Server package is installed:
sudo dpkg -l | grep -i ".*mongodb.*server"
Then check the status of the mongod service and go from there. That will tell you if it's running, what port it's listening on, what config file is used, etc.
sudo systemctl status mongod
If it's not running then try to start it:
sudo systemctl start mongod
If it's still not running then look at the log messages:
sudo journalctl -u mongod.service
I am trying to start the server and getting an error
Port 5432 is already in use
I have brew uninstall postgress
which postgres
gives me nothing.
Activity monitor has 14 postgres processes which I cannot kill.
Force quit kill the process and restarts it with another pid.
The same with
sudo kill -9 PID
it kills the process and restarts it with another PID.
If you are running into this problem on OSX, do the following:
Find out what is running on that port:
$ lsof -n -i4TCP:5432
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python2.7 28687 afdasdfasd 3u IPv4 0x2f18e1284963d3e3 0t0 TCP 127.0.0.1:54970->127.0.0.1:postgresql (CLOSE_WAIT)
Kill it
$ kill -9 28687
Restart postgresapp
Have you checked for a launch daemon? It controls the Postgres process when Postgres is installed with Homebrew, and it automatically restarts Postgres after it is killed. Try
sudo launchctl list
or
sudo launchctl list | fgrep postg
to find the name of the daemon. You can stop the daemon with sudo launchctl stop <name> where name depends on the result of the first command.
Askubuntu provided an answer that worked for me:
sudo pkill -u postgres
Source: Nicely stop all postgres processes
$ brew services stop postgresql
This will kill all processes and let you start the server.
You can get the list of ports using:
sudo launchctl list
Then enter the application name, and using this command to get the port nunber:
sudo launchctl list | fgrep postg
In my case, the port is 83. Now use:
kill 83
then
sudo kill 5432
Run those commands
To check what is running on port 5432 - $ sudo lsof -i :5432
To kill Postgres - $ sudo pkill -u postgres
Use this:
brew services stop postgresql
Good luck!
I'm starting MongoDB using the following command:
sumeet#sumeet-acer:~$ sudo service mongod start
I get a reply as:
mongod start/running, process 7209
sumeet#sumeet-acer:~$
But when I try to enter MongoDB shell by typing mongo I get the following error:
sumeet#sumeet-acer:~$ mongo
MongoDB shell version: 2.0.4
connecting to: test
Fri Jun 12 14:01:59 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
By default, mongod and mongos use the 27017 port. Without any option, the client will try to connect to a server running on localhost and listening at that port.
A few general advices here:
check if the mongod server is really running (ps -edf | grep mongod);
check if it uses the default port (look in the config file1, or use nmap localhost -p0-65535 or netstat | grep 27017);
if mongod is not running, check in the log2 for clues about what goes wrong.
1 /etc/mongodb.conf (on Debian-like systems at least)
2 /var/log/mongodb (on Debian-like systems at least)
The default IP and Port for MongoDB is 127.0.0.1 & 27017.
If you are using config file for specifying settings than re-verify IP & Port mentioned in it.
If you are going with default option than mongod should function as expected.
try mongo 127.0.0.1:27017
this worked for me
For MongoDB 2.2.2 running on Ubuntu 12.10, it's in /var/lib/mongodb/mongod.lock
and after that running the repair command
sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/
courtesy: https://stackoverflow.com/a/13700262/4907105