I am facing the problem to add/change attributes of the slave machines in the DCOS environment.
After changing attributes in
vi /var/lib/dcos/mesos-slave-common
MESOS_ATTRIBUTES=TYPE:DB;DB_TYPE:MONGO;
file, it not immediately getting updated in the cluster.
I have to run the following commands
systemctl stop dcos-mesos-slave
rm -f /var/lib/mesos/slave/meta/slaves/latest
systemctl start dcos-mesos-slave
This means essentially I have to restart the service in the slave.
And the slave is down for at least 1 hour,
Is there any other way achieve this?
As variant we are using some hack, we create /var/lib/dcos/mesos-slave-common file and "froze" it by changing access right, like:
echo "MESOS_ATTRIBUTES=TYPE:DB;DB_TYPE:MONGO;" | sudo tee /var/lib/dcos/mesos-slave-common
sudo chmod -w /var/lib/dcos/mesos-slave-common
# And after that you can execute node installation. Ugly, but that is working :)
sudo dcos_install.sh slave
Related
I have a Kafka instance running on my local machine (macOS Mojave) and I'm trying to have a Docker container see that.
There are two files in the Java program that will be built as the Docker container:
docker-entrypoint.sh:
#!/bin/bash
HOST_DOMAIN="kafka"
HOST_IP=$(awk '/32 host/ { print f } {f=$2}' <<< "$(</proc/net/fib_trie)" | head -n 1)
Dockerfile:
# ...
COPY docker-entrypoint.sh ./
RUN chmod 755 docker-entrypoint.sh
RUN apt-get install -y sudo
CMD ["./docker-entrypoint.sh"]
Now I want to write the following line:
$HOST_IP\t$HOST_DOMAIN
to /etc/hosts so the Docker container can work with Kafka. How can I do that, considering elevated access is needed to write to that file? I have tried these:
1- Changing CMD ["./docker-entrypoint.sh"] to CMD ["sudo", "./docker-entrypoint.sh"]
2- Using sudo tee
3- Using su root;tee ...
4- Running echo "%<user> ALL=(ALL) ALL" | tee -a /etc/sudoers > /dev/null, so I can then tee ... without sudo.
1, 2, and 3 lead to the following error:
sudo: no tty present and no askpass program specified
I don't understand this error. A search for it had solutions for when one is sshing to run a command, but here there is no ssh.
To do 4, I already need to be sudo, correct?
So, how can I achieve what I'm looking to do?
Dockerfile commands typically run as root unless you've changed the user account, so you should not need sudo.
You don't need to edit any hosts file
You can use host.docker.internal to reach the host from the container
https://docs.docker.com/docker-for-mac/networking/
Otherwise, just run Kafka in a container if you want to setup things locally
I wrote a script to download and install kubernetes on an ubuntu machine.
The last part of the script would be to start the kubelet service.
echo "Initializing the master node"
kubeadm reset
systemctl start kubelet.service
kubeadm init
I am forcing the user to run the script as root user. However, when the script reaches the systemctl command, it is not able to execute it. Moreover, I tried to execute the command manually as the root user. I was not able to do so. However, I am able to execute it as a regular user.
Does anyone know why? Is there a workaround?
A possible workaround is to start the service as a regular user, even though the script runs as root. First, you need to find out who is the "original" user:
originalUser="$(logname 2>/dev/null)"
and then call the service as this user:
su - "$originalUser" -c "systemctl start kubelet.service"
Maybe that specific service is dependent on being run by an user who is not root (some programs test for that).
Running postgreSQL 9.4.5_2 currently
I have tried
pg_ctl stop -W -t 1 -s -D /usr/local/var/postgres -m f
Normally no news is good news but after I will run
pg_ctl status -D /usr/local/var/postgres
and get pg_ctl: server is running (PID: 536)
I have also tried
pg_ctl restart -w -D /usr/local/var/postgres -c -m i
Response message is:
waiting for server to shut down.......................... failed
pg_ctl: server does not shut down
I've also checked my /Library/LaunchDaemons/ to see why the service is starting at login but no luck so far. Anyone have any ideas on where I should check next? Force quit in the activity monitor also isn't helping me any.
Sadly none of the previous answers help me, it worked for me with:
brew services stop postgresql
Cheers
I tried various options; finally, the below command worked.
sudo -u postgres ./pg_ctl -D /your/data/directory/path stop
example
sudo -u postgres ./pg_ctl -D /Library/PostgreSQL/11/data stop
As per the comments, the recommended command is without the ./ when calling pg_ctl:
sudo -u postgres pg_ctl -D /Library/PostgreSQL/11/data stop
Tried sudo and su but no such luck.
Just found this gui
https://github.com/MaccaTech/postgresql-mac-preferences
If anyone can help with the terminal commands that would be very much appreciated, but till then the gui will get the job done.
Had the same issue, I had installed postgres locally and wanted to wrap in a docker container instead.
I solved it pretty radically by 1) uninstalling postgres 2) kill the leftover process on postgres port. If you don't un-install the process restarts and grabs the port again - look at your Brewfile form brew bundle dump to check for a restart_service: true flag.
I reasoned that, as I am using containers, I should not need the local one anyway, but !! attention this will remove postgres from your system.
brew uninstall postgres
...
lsof -i :5432 # this to find the PID for the process
kill - 9 <the PID you found at previous command>
Note: if you still want to used psql you can brew install libpq, and add psql to your PATH (the command output shows you what to add to your .zshrc, or similar)
you can stop the server using this command
{pg_ctl -D /usr/local/var/postgres stop -s -m fast}
Adding onto the solutions already stated :
if you decide to use the pg_ctl command, ensure that you are executing the command as a user with the permissions to access the databases/database server.
this means :
the current logged in user on your terminal should have those permissions
or
first run :
$ sudo su <name_of_database_user>
pg_ctl -D /Library/PostgreSQL/<version_here>/data/ stop
the same goes for the start command.
credit : https://gist.github.com/kingbin/9435292
(essentially hosted a file with the commands on github, saved me some time :^) )
I had a stray docker container running Postgres that I had forgotten about.
I need help getting Riak to work with Chef.
Currently every time I chef an amazon box with Riak 1.4.8 using the default basho riak cook book I have to manually ssh into the machine kill -9 the beam.smp process then rm -rf /var/lib/riak/ring then I can finally do sudo riak start and it will work.
Prior to that I get:
Node 'riak#' not responding to pings.
I have even created a shell script:
#!/bin/bash
# Generated by Chef for <%= #node[:fqdn] %>
#<%= #node[:ec2][:local_ipv4] %>
# This script should be run by root.
riak stop
riakPid="/var/run/riak/riak.pid"
if [ -e "$riakPid" ]; then
kill -9 $(<${riakPid})
fi
rm -f /var/run/riak/*
rm -f /var/lib/riak/ring/*
riak start
And Chef says:
bash[/etc/riak/clearOldRiakInfo.sh] ran successfully
For the above script.
If I manually run that script everything works fine. Why is this not cheffing properly.
UPDATE:
This has been solved by creating a script to delete the ring directory when the machine gets cheffed.
This would only happen when I would create a new machine from scratch as the fqdn would get set correctly after Riak had started and created the ring. If I manually went on the box and deleted the ring then it would rechef perfectly fine. So I have to create the script so that the very first chef run on the machine would clean out the ring info.
Given the error message you provided, Riak is not starting because the Erlang node name is not being generated correctly. The Erlang node name configuration exists within vm.args and is produced by the node['riak']['args']['-name'] attribute.
The default for node['riak']['args']['-name'] is riak##{node['fqdn']}. Please check the value Ohai is reporting for node['fqdn']. Alternatively, if you are overriding this attribute somewhere else, ensure that produces a valid value for -name.
A more detailed description of -name within vm.args can be found here.
I'm using nginx on OS X 10.8. Freshly installed nginx but can't find a way to restart nginx except kill nginx_pid say kill 64116. Wondering if there are better ways to restart nginx.
Found some methods on Google and SO but didn't work:
nginx -s restart
sudo fuser -k 80/tcp ; sudo /etc/init.d/nginx restart
The error message for nginx -s restart is
nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
Sometimes also get this error msg:
nginx: invalid option: "-s restart"
Try running sudo nginx before starting nginx.
To reload config files:
sudo nginx -s reload
To fully restart nginx:
sudo nginx -s quit
sudo nginx
Details
There is no restart signal for nginx. From the docs, here are the signals that the master process accepts:
SIGINT, SIGTERM Shut down quickly.
SIGHUP Reload configuration, start the new worker process with a new configuration, and gracefully shut down old worker processes.
SIGQUIT Shut down gracefully.
SIGUSR1 Reopen log files.
SIGUSR2 Upgrade the nginx executable on the fly.
SIGWINCH Shut down worker processes gracefully.
Presumably you could send these signals to the process id manually, but the nginx command has the flag nginx -s <signal> that sends signals to the master process for you. Your options are:
stop SIGTERM
quit SIGQUIT
reopen SIGUSR1
reload SIGHUP
No need to futz with the pid manually.
Edit: just realized much of this info was already in comments on the other answers. Leaving this here anyway to summarize the situation.
What is your nginx pid file location? This is specified in the configuration file, default paths specified compile-time in the config script. You can search for it as such:
find / -name nginx.pid 2>/dev/null (must issue while nginx is running)
Solution:
sudo mkdir -p /usr/local/var/run/
ln -s /current/path/to/pid/file /usr/local/var/run/nginx.pid
$ sudo nginx -c /usr/local/etc/nginx/nginx.conf
$ sudo nginx -s reload
Source Link: https://blog.csdn.net/github_33644920/article/details/51733436
Try this:
sudo nginx -s stop
followed by a:
sudo nginx
It seems that nginx keeps track of its state, to if you stop it twice, it will complain. But the above worked for me.
I do it like this:
First kill the progress
ps aux | grep nginx
kill -9 {pid}
Then start nginx
nginx
It works!
As a future resource, you can consult http://wiki.nginx.org/CommandLine
Nginx probably runs as root, so you will need to run a variant of the following command to affect it.
sudo nginx -s stop | reload | quit | reopen
There is usually not much reason to restart Nginx like Apache would need. If you have modified a configuration file, you may just want to the reload option.
check if this directory exists:
/usr/local/var/run
this error can occurs when nginx try to initialise pid file in
localisation that doesn't exist.
There is a bug here. Depending on whether nginx is running while you modify/restart apache and/or modify nginx configs it is possible for this file (which is essentially just a process ID pointer) to be destroyed.
When you attempt to send any signal to nginx like
nginx -s quit;
nginx -s stop;
nginx -s reload;
nginx uses this file to reference the ID of the process to which it needs to send the signal. If the file isn't there the link between the active running process of nginx & the cli app is effectively broken.
I actually ended up in a state where two nginx processes were running simultaneously so killed both.
To work around this, you can either Force the termination of existing nginx processes via Activity Monitor (then run nginx & have the cli app create a new nginx.pid file) or if you REALLY need to keep nginx running but want to run nginx -s reload - manually create a file in the /run path called nginx.pid and insert the PID of the currently running nginx processs (obtained via Activity Monitor).
To reload the custom config file use
nginx -s reload -c /etc/nginx/conf.d/<config file>.conf
This could simply mean that nginx is already stopped - not running at the moment.
First, confirm whether nginx is running, execute:
$ ps aux | grep nginx
i got the same error link you, i tried many way to fix it but it not working
after that i run the command line and it work well:
nginx -c /usr/local/etc/nginx/nginx.conf
the information i got from here
https://blog.csdn.net/wn1245343496/article/details/77974756
One way to stop or reload is through the below command,
For stop:
sudo /usr/local/nginx/sbin/nginx -s stop
Run reload only if the nginx is running:
sudo /usr/local/nginx/sbin/nginx -s reload
By doing like the above, you wont get nginx: [error] open() "/usr/local/var/run/nginx.pid" this issue