How do I check if Kibana 4 is running on a linux machine? - kibana-4

I have configured a linux machine, I just wish to check if kibana 4 is running perfectly.

You can always use :
ps auwx | grep kibana
it'll list the kibana process
Care: it'll list also the command itself

We can also use the command:
ps -ef | grep -irn kibana
This will list all the kibana processes running at the instance..

Related

How to access a Docker container on the host by a name (not IP)?

I want to run MS SQL server (docker image: microsoft/mssql-server-windows-developer) in a docker container. Using Windows on the host and the container. Afterwards, the database should be accessible from the host (using SQL Management Studio) by a useful, name (so that the instructions can be re-used). However, docker generates a seemingly random IP, which is not as useful, especially as it resets on every call to run.
So, I would like to give the container a hostname that is accessible from the host machine (e.g. by SQL Management Studio). I'd like to avoid a mere IP here, but it would suffice, if no better solution presents itself.
Creating a network in docker did not work, as this functionality apparently is only supported under Linux.
--network-alias also failed.
The run command looks like this:
docker run -d -p 1433:1433 -e sa_password=1234qwerT -e ACCEPT_EULA=Y --name docker_sql microsoft/mssql-server-windows-developer
This is very similar to this question here: How to get a Docker container's IP address from the host?
I think you can achieve what you want by way of a 2 step process:
Obtain the container id for your container as part of your docker run command.
Use docker inspect to get the container's IP address.
If you really don't want to use the IP address, then you can always add the IP address to your hosts file, but simply using the IP address as a shell variable should be almost as useful.
So, for example, from a bash shell:
CID=$(docker run -d ubuntu /bin/sh -c 'while /bin/true; do sleep 10 ; done')
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ID)
Now you can use $IP within scripts as you see fit. (Substitute the CID=... line with whatever docker run command you are using to start your container).
As per bluescores' comment and stumbling upon this related question, I tried and verified that connecting to localhost is possible - so there actually is no need to configure a name for the container-sql-server or to configure its IP.
The general problem might persist for other applications, but for what I want to achieve currently, localhost will suffice.

How to check if ZooKeeper is running or up from command prompt?

I exploring a few options to setup kafka and I knew that the Zookeeper has to be up and running to initiate a kafka.
I would like to know how can I find the below.
1) hostname and port for my zookeeper instance---I checked the zoo.cfg and I could only find the ClientPort not the hostname, will hostname be the hostname of my box??
2) To check if ZooKeeper is up and running---I tried to do a ps -ef | grep "zoo" I could not find anything. May be I am using a wrong key word to search??
Any help would be really appreciated?
To check if Zookeeper is accessible. One method is to simply telnet to the proper port and execute the stats command.
root#host:~# telnet localhost 2181
Trying 127.0.0.1...
Connected to myhost.
Escape character is '^]'.
stats
Zookeeper version: 3.4.3-cdh4.0.1--1, built on 06/28/2012 23:59 GMT
Clients:
Latency min/avg/max: 0/0/677
Received: 4684478
Sent: 4687034
Outstanding: 0
Zxid: 0xb00187dd0
Mode: leader
Node count: 127182
Connection closed by foreign host.
One other way would be to use 4 letter commands to validate if zookeeper service is healthy or not
echo stat | nc <zookeeper ip> 2181
echo mntr | nc <zookeeper ip> 2181
echo isro | nc <zookeeper ip> 2181
More details on the documentation link below
https://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands
Go to bin directory of Zookeeper and type
./zkServer.sh status
For More info go through below link:
http://www.ibm.com/developerworks/library/bd-zookeeper/
Hope this could help you.
echo stat | nc localhost 2181 | grep Mode
echo srvr | nc localhost 2181 | grep Mode #(From 3.3.0 onwards)
Above will work in whichever modes Zookeeper is running (standalone or embedded).
Another way
If zookeeper is running in standalone mode, its a JVM process. so -
jps | grep Quorum
will display list of jvm processes; something like this for zookeeper with process ID
HQuorumPeer
I did some test:
When it's running:
$ /usr/lib/zookeeper/bin/zkServer.sh status
JMX enabled by default
Using config: /usr/lib/zookeeper/bin/../conf/zoo.cfg
Mode: follower
When it's stopped:
$ zkServer status
JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Error contacting service. It is probably not running.
I'm not running on the same machine, but you get the idea.
Zookeeper is just a Java process and when you start a Zookeeper instance it runs a org.apache.zookeeper.server.quorum.QuorumPeerMain class. So you can check for a running Zookeeper like this:
jps -l | grep zookeeper
or even like this:
jps | grep Quorum
upd:
regarding this: will hostname be the hostname of my box?? - the answer is yes.
enter the below command to verify if zookeeper is running :
echo "ruok" | nc localhost 2181 ; echo
expected response: imok
From a Windows 10
Open Command Promt then type telnet localhost 2181and then you type srvr
OR
From inside bin folder, open a PowerShell window and type zkServer.sh status
I use:
jps
Depending on your installation a running Zookeeper would look like
HQuorumPeer
or sth. with zookeeper in it's name.
For people who uses the official docker image:
https://hub.docker.com/_/zookeeper
in the whitelist is only enabled srvr
See below the example:
telnet hostname 2181
Trying ::1...
Connected to localhost.
Escape character is '^]'.
srvr
Zookeeper version: 3.7.0-e3704b390a6697bfdf4b0bef79e3da7a4f6bac4b, built on 2021-03-17 09:46 UTC
Latency min/avg/max: 0/0.0/0
Received: 3
Sent: 2
Connections: 1
Outstanding: 0
Zxid: 0x0
Mode: standalone
Node count: 5
Connection closed by foreign host.
Doc:
ZOO_4LW_COMMANDS_WHITELIST
Defaults to srvr. Zookeeper's 4lw.commands.whitelist
A list of comma separated Four Letter Words commands that user wants to use. A valid Four Letter Words command must be put in this list else ZooKeeper server will not enable the command. By default the whitelist only contains "srvr" command which zkServer.sh uses. The rest of four letter word commands are disabled by default.
For Window, users Install mobaxterm https://mobaxterm.mobatek.net/download.html
The mobaxterm terminal allows you to run all Linux commands
For those of you who used homebrew, use this command -
/opt/homebrew/Cellar/zookeeper/3.8.1/bin/zkServer status

How does docker's `net=host` setting work, and how can I do something similar with e.g. VirtualBox?

Docker has a run option net=host documented here that allows you to run a virtual machine that shares the network stack with the host — for example, processes inside the docker container can connect to the host machine via localhost and vice versa.
I want to set up a Linux VM on Mac OS X that does the same thing; I've tried using Vagrant and its various networking settings without much luck.
Does Docker's VM rely on the host and guest OSes both being Linux, or is there some way to accomplish this OSX->Linux that I'm missing?
Thanks to some help from my colleagues I found a solution to this problem. This solution works with boot2docker/VirtualBox. I just created my docker VM with boot2docker init, I didn't make any specific changes to the VM configuration.
First you run the docker image with --net=host, so that it shares the network with the host VM e.g.
docker run -it --net=host ubuntu bash
Then you need to find the IP address from the VM used for the docker containers, you can do this by running boot2docker ssh the OSX host.
You can then find the IP address of the VM by finding its gateway:
$ netstat -rn | grep UG | awk '{print $2}'
10.0.2.2
So in my case it's 10.0.2.2. You can now access ports opened on the host, i.e. on a program running on OSX from your docker container by using this IP address.
To automate you could find the IP address first and then pass it into the docker command as an environment variable...
I have found another answer that works, I'll share that here so that people can choose :)
First you need to figure out what the IP address of the preferred network interface is on your OSX host is. The following shell command did this for me:
echo "show State:/Network/Global/IPv4" | scutil | grep PrimaryInterface | awk '{print $3}' | xargs ifconfig | grep inet | grep -v inet6 | awk '{print $2}'
In my case this prints out: 10.226.98.247
Then you can simply use that address inside docker, or even better give this address a hostname for inside docker:
docker run -it --add-host dockerhost:10.226.98.247 ubuntu bash
Then you can use the same dockerhost hostname in your docker container regardless of what environment you're launching your container in...

How to properly configure the Amazon EC2 AMI for 'hadoop-ec2'?

I am trying to launch an instance on Amazon EC2. I have researched this problem extensively, but I have not found any helpful information.
When I run the command hadoop-ec2 launch-cluster mycluster 2, I receive the following error message:
Starting master with AMI.
Required parameter 'AMI' missing (-h for usage)
I have entered my AWS key, AWS secret key, AWS key pairs, etc. I am using hadoop-1.0.4. I am using the default S3 bucket (hadoop-images), but I have tried many other AMIs and I always get the same error message.
Has anybody experience this problem before?
The basic issue is that the search for images the launch-hadoop-master script performs is not returning any results. The most likely cause of this due to the different AMIs that are available in different regions (but it could be due to any changes you've made to S3_BUCKET and HADOOP_VERSION in hadoop-ec2-env.sh).
From the launch-hadoop-master script:
# Finding Hadoop image
AMI_IMAGE=`ec2-describe-images -a | grep $S3_BUCKET
| grep $HADOOP_VERSION
| grep $ARCH
| grep available
| awk '{print $2}'`
# Start a master
echo "Starting master with AMI $AMI_IMAGE"
So, it appears that AMI_IMAGE is not being set to a valid image and thus the search for AMIs that match the various grep filters is failing (the defaults for the Hadoop 1.0.4 distribution are S3_BUCKET is hadoop-images, HADOOP_VERSION is 0.19.0 and ARCH is x86 if you're using m1.small instances). If you search the public AMIs in the US-West-2 region, you'll see that there aren't many Hadoop images, but if you search the public AMIs in the US-East-1 region, you'll see that there are quite a few. Thus, one way around this issue is to work in the US-East-1 region (this is simplest) or, alternatively, set EC2_URL in your login script via export EC2_URL=https://ec2.us-east-1.amazonaws.com but now you need make sure you put your keys in this region from the AWS console.
If you did indeed change HADOOP_VERSION to 1.0.4, I'll note that
ec2-describe-images -a | grep hadoop-images
| grep "1.0.4"'
| grep x86
| grep available
doesn't return any images in the US-East-1 region. Note that the version (HADOOP_VERSION) of the Hadoop distribution that you are running the hadoop-ec2 command from does not need to be the same as the version of Hadoop that the images will be running.
Lastly, as a blunt fix, you could find the AMI that you want to use, and force set AMI_IMAGE to the image name in the launch-hadoop-master and launch-hadoop-cluster scripts.

Bash: Check up, Run a process if not running [duplicate]

This question already has answers here:
How do I write a bash script to restart a process if it dies?
(10 answers)
Closed 6 years ago.
Bash: Check up, Run a process if not running
Hi ,
My requirement is that , if Memcache server is down for any reason in production , i want to restart it immediately
Typically i will start Memcache server in this way with user as nobody with replication as shown below
memcached -u nobody -l 192.168.1.1 -m 2076 -x 192.168.1.2 -v
So for this i added a entry in crontab this way
(crontab -e)
*/5 * * * * /home/memcached/memcached_autostart.sh
memcached_autostart.sh
#!/bin/bash
ps -eaf | grep 11211 | grep memcached
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
memcached -u nobody -l 192.168.1.1 -m 2076 -x 192.168.1.2 -v
else
echo "eq 0 - memcache running - do nothing"
fi
My question is inside memcached_autostart.sh , for autorestarting the memcached server , is there any problem with the above script ??
Or
If there is any better approach for achieving this (rather than using cron job )
Please share your experience .
Yes the problem is ps -eaf | grep 11211 | grep memcached I assume is the process ID which always changes on every start, so what you should do is ps -ef | grep memcached
hope that helped
Instead of running it from cron you might want to create a proper init-script. See /etc/init.d/ for examples. Also, if you do this most systems already have functionality to handle most of the work, like checking for starting, restarting, stopping, checking for already running processes etc.
Most daemon scripts save the pid to a special file (e.g. /var/run/foo), and then you can check for the existence of that file.
For Ubuntu, you can see /etc/init.d/skeleton for example script that you can copy.

Resources