ovs-ofctl doen not work - connection refused - sockets

I am following openflow tutorial on openflow tutorial. I am using mininet and ryu controller and openvswitch version 2.8.0. When I try to use command:
sudo ovs-ofctl show s1
It gives error as below:
asd#asd:~/ryu/ryu/mpls$ sudo ovs-ofctl show s1
ovs-ofctl: /var/run/openvswitch/s1.mgmt: failed to open socket (Connection refused)
As I am using sudo, I think there should not be any problem regarding permissions for opening socket connection. Not sure what is causing this error.
Help is appreciated.

The error message is saying that ovs-vswitchd did not open the Unix socket expected at /var/run/openvswitch/s1.mgmt. This usually means that ovs-vswitchd (the daemon process for Open vSwitch) is not running.
You can check that by running:
$ ps aux | grep ovs-vswitchd
root 77289 0.0 0.0 25632 4916 ? Ss 16:05 0:00 ovsdb-server --remote=punix:/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --log-file=/var/log/openvswitch/ovs-vswitchd.log -vsyslog:info -vfile:info --pidfile --detach
root 77295 100 0.2 2608140 45820 ? Ssl 16:05 3:13 ovs-vswitchd unix:/var/run/openvswitch/db.sock --pidfile --detach --log-file=/var/log/openvswitch/ovs-vswitchd.log -vfile:info
paul 77447 0.0 0.0 14228 968 pts/2 S+ 16:08 0:00 grep --color=auto ovs-vswitchd
The first process, ovsdb-server, answers to OVSDB queries. The second process, ovs-vswitchd, answers to OpenFlow queries and processes packets.

Related

dnsmasq: failed to create listening socket for xxx.xxx.xxx.xxx: Address already in use

when i try to start the dnsmasq, I meet the problem dnsmasq:failed to create listening socket :address already in use.It may be this below process prevent the dnsmasq, but i do not know how to stop this process. After i kill this process, it will restart again.
root 40012 0.0 0.0 15128 156 ? Ss 10:16 0:00 /usr/sbin/in.tftpd --listen --user tftp --address [::]:69 --secure /var/lib/tftpboot
Service tftpd-hpa stop
stop the tftpd-hpa service and then restart dnsmasq can solve this issue

Docker REST API is not binding on port for Jenkins

I am using :
docker version: 1.11.1, build 5604cbe . I have made entries in /etc/default/docker as follows to configure REST API of docker for jenkins user group :
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
DOCKER_OPTS="G- jenkins -H unix://var/run/docker.sock -H tcp://0.0.0.0:9090"
export DOCKER_HOST="tcp://0.0.0.0:9090"
ps- I have also tried with 127.0.0.1
Then I did sudo service docker restart
command $ ps aux|grep docker returned:
root 12385 0.0 0.2 421840 36016 ? Ssl 19:21 0:00 /usr/bin/docker daemon -H fd://
root 12391 0.0 0.0 294652 12188 ? Ssl 19:21 0:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc
root 12654 0.0 0.0 21296 1028 pts/1 S+ 19:28 0:00 grep --color=auto docker
Seems like The REST API is not getting bind to port:9090.
Then I am using Jenkins Docker build step plugin to connect with docker REST API. It returns following :
Building in workspace /var/lib/jenkins/jobs/Telco_automated_build/workspace
[Docker] INFO: Pulling image registry.hub.docker.com/pratyush/product:latest
ERROR: Build step failed with exception
javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:9090 [/127.0.0.1] failed: Connection refused
at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:513)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:424)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:333)
at com.github.dockerjava.jaxrs.PullImageCmdExec.execute(PullImageCmdExec.java:37)
at com.github.dockerjava.jaxrs.PullImageCmdExec.execute(PullImageCmdExec.java:17)
at com.github.dockerjava.jaxrs.AbstrDockerCmdExec.exec(AbstrDockerCmdExec.java:57)
at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:29)
at com.github.dockerjava.core.command.PullImageCmdImpl.exec(PullImageCmdImpl.java:15)
at org.jenkinsci.plugins.dockerbuildstep.cmd.PullImageCommand.execute(PullImageCommand.java:75)
at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:75)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
At the jenkins global setting when i hit test-connection it returns:
Something went wrong, cannot connect to http://127.0.0.1:9090/, cause: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:9090 [/127.0.0.1] failed: Connection refused
PS- I have restarted Jenkins server after changing global setting.
Any help, where am I missing ?
Ubuntu 16.04 uses systemd now I believe. In which case the docker daemon arguments are not set using /etc/default/docker. You can see they're not being picked up in the output of your $ ps aux|grep docker.
Instead you need to follow the instructions to set daemon args in systemd-based setups.

postgres PEM server, issue connecting the data base

I'm not good with Postgres database troubleshooting, but I have a big project data base running on it.
Today suddenly I'm getting an error while I try to access my server, attached is the picture of the error screenshot. I really don't want to lose my data because its not backed up for few months.
I tried to reinstall but it says the port is messed up somewhere.
The message while I reinstall is:
"psql:could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "127.0.0.1" and accepting
TCP/IP connection on port 5432?
Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? That are two questions you could answer:
Is the server running on host "127.0.0.1" (aka localhost) use:
ps auxw | grep postgres # to answer this question
... accepting TCP/IP connections on port 5432? there are several ways to answer this question:
psql -h 127.0.0.1 -p 5432 postgres
telnet localhost 5432
nmap -p 5432 localhost
The result for (1) should be like:
postgres 30402 0.0 0.1 238488 12924 ? S 12:09 0:01 /opt/postgres/bin/postmaster -D /data/db/postgres/pgdata
postgres 30409 0.0 0.0 94644 1308 ? Ss 12:09 0:00 postgres: logger process
postgres 30411 0.0 0.3 238628 46964 ? Ss 12:09 0:01 postgres: checkpointer process
postgres 30412 0.0 0.0 238628 4764 ? Ss 12:09 0:00 postgres: writer process
postgres 30413 0.0 0.0 238628 5832 ? Ss 12:09 0:00 postgres: wal writer process
postgres 30414 0.0 0.0 239036 2820 ? Ss 12:09 0:01 postgres: autovacuum launcher process
postgres 30415 0.0 0.0 97884 2460 ? Ss 12:09 0:03 postgres: stats collector process
The result for (2) should be like:
Password:
The result for (3) should be like:
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
The result for (4) should be like:
Starting Nmap 6.40 ( http://nmap.org ) at 2016-05-18 15:14 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000050s latency).
Other addresses for localhost (not scanned): 127.0.0.1
rDNS record for 127.0.0.1: localhost.localdomain
PORT STATE SERVICE
5432/tcp open postgresql
Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
if (1) fails (gives no relevant output) postgres is obviously not running.
you didn't start it (there should be a file for the service in /etc/init.d/)
you attempted to start it, but it failed to startup
the binaries were not present, not found, or wrong
the data directory was not present, not found, or had the wrong owner/rights
the data directory contained files, but not for this version
if (2,3,4) fail (give no relevant output)
postgres is not listening on the inet socket, but only on the unix-domain socket : check your config-file for listen_address = '*'
finally, there could be a firewall-issue. (Check your iptables settings. or whatever)

Mac OSX Lion Postgres does not accept connections on /tmp/.s.PGSQL.5432

I'm getting a common Mac OSX error for Homebrew installations of Postgres,
No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
This is apparently due to there being multiple installs on the system. However, the usual steps are not resolving things.
I can successfully start Postgres and running:
ps auxw | grep post
returns ..
euanmillar 847 0.0 0.0 2432768 588 s000 R+ 11:19am 0:00.00 grep postgres
euanmillar 845 0.0 0.0 2439324 448 ?? Ss 11:19am 0:00.00 postgres:
stats collector process
euanmillar 844 0.0 0.0 2443176 1520 ?? Ss 11:19am 0:00.00 postgres:
autovacuum launcher process
euanmillar 843 0.0 0.0 2443044 544 ?? Ss 11:19am 0:00.00 postgres: wal writer process
euanmillar 842 0.0 0.0 2443044 584 ?? Ss 11:19am 0:00.00 postgres: writer process
euanmillar 841 0.0 0.0 2443044 596 ?? Ss 11:19am 0:00.00 postgres: checkpointer process
euanmillar 839 0.0 0.0 2443044 3616 s000 S 11:19am 0:00.02 /us
so it looks like postgres is running.
I have commented in the following lines in postgresql.conf
port = 5432
unix_socket_directory = '/var/pgsql_socket'
unix_socket_permissions = 0777
and in var/pgsql_socket/ I do have a hidden file .s.PGSQL.5432
I have tried solutions to many of the posts here. This one especially seems similar:
https://dba.stackexchange.com/questions/21587/postgresql-is-running-locally-but-i-cannot-connect-why
But the difference is that I do have a '/var/pgsql_socket' directory which is CHOWN-ed to everyone. I have used Homebrew to completely remove and re-install Postgres and still I have the same issue.
You need to remove the postmaster.pid, which should be in the following path:
/usr/local/var/postgres/postmaster.pid
For me, i removed postmaster.pid in /usr/local/var/postgres. fixed me right up.
A simpler solution is to locate where the socket actually is vs where it's expected to be. In my case, I ran:
$ locate PGSQL.5432
/private/var/pgsql_socket/.s.PGSQL.5432
/private/var/pgsql_socket/.s.PGSQL.5432.lock
Then just symlink the expected socket location to the actual socket location.
$ ln -s /private/var/pgsql_socket/.s.PGSQL.5432 /tmp/.s.PGSQL.5432
The system client is being used and not your brew version. The symlink approach only lasts until the next restart. This approach fixes the root issue I believe
sudo edit /etc/paths
Move the line containing /usr/local/bin to the top of the file. (Before /usr/bin)
Uninstall your postgres gem(s) (gem uninstall pg)
Start up new shell to load the new environment settings
bundle
That is not an OS X specific issue. You will need to clean up your postgres installation and then reinstall it again. I have faced this issue on my ubuntu 12.04. While cleaning your previous installation, you will need to remove all packages starting with postgres (postgresql, postgresql-common, postgresql-client etc), in other words, postgres*. I have not used brew, have used port on OS X Lion. I guess the equivalent command should be sudo brew remove postgres*. A sudo brew install postgresql should then do the trick.
Also, if you feel the server is already running, you can try sudo -u postgres createuser. If that fails, you will need to reinstall.
However, the output of your ps aux | grep post is actually the grep command itself. Not of the postgres server running.
EDIT: Looks like the following link could be of help https://dba.stackexchange.com/questions/21587/postgresql-is-running-locally-but-i-cannot-connect-why
If yes, then this question might be a duplicate.
I had the same problem on Mac Serria. In Mac Serria you can find postmaster.pid inside /Users/<user_name>/Library/Application Support/Postgres/var-9.6 if you used GUI installer rather than homebrew.
Once you delete this file then everything should work fine.

How to install PostgreSQL 9.1 on OSX Lion

I downloaded PostgreSQL from the official website and ran the .dmg installer. After that I downloaded pgadmin3 and I am indeed able to connect to the database.
when I run 'psql' I get the following error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
After hours of googling I read about some $PATH issues, so I put this into my .bashrc:
export PATH=/Library/PostgreSQL/9.1/bin:$PATH
However, this doesn't solve the error above at all. After some more hours of googling I tried to run 'psql -l localhost -U postgres'. This gives another error:
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
After some more googling I tried to edit /Library/PostgreSQL/9.1/data/pg_hba.conf and replaced all occurrences of 'md5' with 'trust'.
Then I changed user to postgres and executed 'pg_ctl stop' and 'pg_ctl start', switched back to my own user and tried to connect again, no luck.
Here are some more infos:
[~]$ which psql
/Library/PostgreSQL/9.1/bin/psql
ps aux | grep postgres
postgres 19022 0.0 0.0 2446096 484 ?? Ss 11:31PM 0:00.01 postgres: stats collector process
postgres 19021 0.0 0.0 2486532 1776 ?? Ss 11:31PM 0:00.01 postgres: autovacuum launcher process
postgres 19020 0.0 0.0 2486400 576 ?? Ss 11:31PM 0:00.03 postgres: wal writer process
postgres 19019 0.0 0.0 2486400 820 ?? Ss 11:31PM 0:00.05 postgres: writer process
postgres 19017 0.0 0.0 2446096 356 ?? Ss 11:31PM 0:00.01 postgres: logger process
postgres 19015 0.0 0.1 2486400 8216 s001 S 11:31PM 0:00.17 /Library/PostgreSQL/9.1/bin/postgres
sudo find / -name .s.PGSQL.5432
No file was found?!?
Update 1:
In /etc/sysctl.conf I added the values suggested by the installer's README:
kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
Before these settings, the installer quits with an error, afterwards the wizard appears and installs postgres (and again, using pgadmin3 works, so I assume that the database is running fine).
Run lsof on the master process to all of this. In your case it's 19015 (shown with my PID):
> sudo lsof -p 286 | awk '$5 == "unix" && $NF ~ /\// { print $NF }'
/tmp/.s.PGSQL.5432
You can leave off the awk, but basically it's getting the UNIX socket on which postgres is listening. From there, you can use the -h option to psql (but only include the directory).
> psql -h /tmp template1
template1=# \q
If that doesn't work, you can check the lsof output to show you what TCP port it's actually listening on, and if it's not 5432, use the -p option to postgres
If you are able to connect to the database through pgadmin3, then your database is running.
(1) I'd verify by running netstat -an | grep 5432 on the command line, as a paranoia check. You are in business i.e. you actually installed Postgresql if you get this below:
tcp4 0 0 *.5432 . LISTEN
tcp6 0 0 *.5432 . LISTEN
ffffff80133bfed8 stream 0 0 ffffff8013be8000 0 0 0 /tmp/.s.PGSQL.5432
(2) Speaking for myself, I found that just running psql gets me your psql error message. I had to run
psql -h 127.0.0.1 -p 5432 [-d database] -U postgres
to connect with the database. In other words, I had to explicitly specify IP and port. Since you were able to run psql and get a non-connect error message, the OS understands that psql is a command and you don't have a pathing issue.