Addition of two variables in slurm script - bash

I am having slurm scirpt processing fmri data and the maximum value I can give in an array is 999, but the name of my subject ist over 1000.
So I need to to an addition in my slurm script. I tried:
a=${SLURM_ARRAY_TASK_ID} sum=$(($a + 1200))
#!/bin/sh
#
#SBATCH --job-name psy-stephan_fmriprep_gsp
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem=8GB
#SBATCH --output /projects/core-psy/logs/nako/stephan/slurm-%j.log
#SBATCH --error /projects/core-psy/logs/nako/stephan/slurm-%j.err
a=${SLURM_ARRAY_TASK_ID}
sum=$(($a + 1200))
singularity run \
--home /projects/core-psy/tmp3:/home/fmriprep \
--cleanenv \
-B /projects/core-psy/data/nako//swunderl/GSP_new/:/input \
-B /projects/core-psy/data/nako/swunderl/GSP_new/derivatives:/output \
-B //projects/core-psy/data/nako/swunderl/GSP_new_workdir/:/workdir \
-B /projects/core-psy/data/nako/swunderl/license.txt:/license \
/projects/core-psy/images/fmriprep-20.2.2.simg /input/sub-$sum /output participant \
--fs-license-file /license \
--skip-bids-validation \
--use-aroma \
--fs-no-reconall \
-w /workdir/ \
#--output-layout bids \
# sbatch --account=core-psy sbatch-multiple-job.slurm
So i can pass as a command SLURM_ARRAY_TASK_ID as 1.
But the addition keeps giving me sub-0+1200 and not the actual sum of both numbers.

Since you do not need to perform math on a, you can perform variable expansion on the string to make a 4 digit subject label for your fmriprep command:
sum="1${SLURM_ARRAY_TASK_ID}"
This way sbatch -a 200 ./your_job_script.sh will run for sub-1200. If you have labels like 1001, you will need to add to the variable expansion since 001 becomes a SLURM_ARRAY_TASK_ID of 1.
Here's an example adapted from my own - albeit not the most succint - code for sbatch scripts
if [ ${#SLURM_ARRAY_TASK_ID} == 1 ];
then
inputNo="100${SLURM_ARRAY_TASK_ID}"
singularity run \
--home /projects/core-psy/tmp3:/home/fmriprep \
--cleanenv \
-B /projects/core-psy/data/nako//swunderl/GSP_new/:/input \
-B /projects/core-psy/data/nako/swunderl/GSP_new/derivatives:/output \
-B //projects/core-psy/data/nako/swunderl/GSP_new_workdir/:/workdir \
-B /projects/core-psy/data/nako/swunderl/license.txt:/license \
/projects/core-psy/images/fmriprep-20.2.2.simg /input/sub-${inputNo} /output participant \
--fs-license-file /license \
--skip-bids-validation \
--use-aroma \
--fs-no-reconall \
-w /workdir/
elif [ ${#SLURM_ARRAY_TASK_ID} == 2 ];
then
inputNo="10${SLURM_ARRAY_TASK_ID}"
singularity run \
--home /projects/core-psy/tmp3:/home/fmriprep \
--cleanenv \
-B /projects/core-psy/data/nako//swunderl/GSP_new/:/input \
-B /projects/core-psy/data/nako/swunderl/GSP_new/derivatives:/output \
-B //projects/core-psy/data/nako/swunderl/GSP_new_workdir/:/workdir \
-B /projects/core-psy/data/nako/swunderl/license.txt:/license \
/projects/core-psy/images/fmriprep-20.2.2.simg /input/sub-${inputNo} /output participant \
--fs-license-file /license \
--skip-bids-validation \
--use-aroma \
--fs-no-reconall \
-w /workdir/
elif [ ${#SLURM_ARRAY_TASK_ID} == 3 ];
then
inputNo="1${SLURM_ARRAY_TASK_ID}"
singularity run \
--home /projects/core-psy/tmp3:/home/fmriprep \
--cleanenv \
-B /projects/core-psy/data/nako//swunderl/GSP_new/:/input \
-B /projects/core-psy/data/nako/swunderl/GSP_new/derivatives:/output \
-B //projects/core-psy/data/nako/swunderl/GSP_new_workdir/:/workdir \
-B /projects/core-psy/data/nako/swunderl/license.txt:/license \
/projects/core-psy/images/fmriprep-20.2.2.simg /input/sub-${inputNo} /output participant \
--fs-license-file /license \
--skip-bids-validation \
--use-aroma \
--fs-no-reconall \
-w /workdir/
fi

Related

Bash scripts return a substring not whole value in column for psql

I want to get the value of message in db, which for example is "the error is missing index " but when I run the code belong, it only return me 'the' for error_type. How could this happen that only return me the first word but not the whole value of the query result? How can I get the query results with the whole value?
declare -a ROW=($(psql \
-X \
-U $DB_USER \
-h $DB_HOST \
-d $DB_NAME \
-p $DB_PORT \
--single-transaction \
--set AUTOCOMMIT=off \
--set ON_ERROR_STOP=on \
--no-align \
-t \
--field-separator ' ' \
--quiet \
-c "SELECT message
FROM error_message
WHERE created_at > '$t1' and created_at < '$t'")
)
error_type=${ROW[0]}
echo $error_type
Don't use an array, use an ordinary string variable to contain the whole result.
error_type=$(psql \
-X \
-U $DB_USER \
-h $DB_HOST \
-d $DB_NAME \
-p $DB_PORT \
--single-transaction \
--set AUTOCOMMIT=off \
--set ON_ERROR_STOP=on \
--no-align \
-t \
--field-separator ' ' \
--quiet \
-c "SELECT message
FROM error_message
WHERE created_at > '$t1' and created_at < '$t'")
echo "$error_type"
Remember to quote variables unless you need word splitting and wildcard expansion to be done.

query return null in bash for psql

I am tring to get the count for the records in a certain table in bash scripts but the $num is null when returned (should be a number). And the query is correct when I directly run in pgadmin that I can get the number of rows. Any one know what is wrong?
declare -a ROW=($(psql \
-X \
-U $DB_USER \
-h $DB_HOST \
-d $DB_NAME \
-p $DB_PORT \
--set ON_ERROR_STOP=on \
--no-align \
-t \
--field-separator ' ' \
--quiet \
-c "SELECT count(*) as num
FROM table_test)")
)
echo "num_error: $num here"
if [[ $num == 0 ]]; then
echo "no error occur within the past 1 hour"
elif [[ $num == '' ]]; then
echo "return nothing"
else echo "$num"
fi
SQL aliases don't become shell variables, so using AS num in the query will not set $num in the shell.
The output of the query is being put in the ROW array, so you can get the value you want from ${ROW[0]}. There's also no need to use an array if the query just returns a single value. So you could do:
num=$(psql \
-X \
-U $DB_USER \
-h $DB_HOST \
-d $DB_NAME \
-p $DB_PORT \
--set ON_ERROR_STOP=on \
--no-align \
-t \
--field-separator ' ' \
--quiet \
-c "SELECT count(*)
FROM table_test)")
)

Submit multiple json payloads with curl

I am working with the confluent kafka, zookeeper in docker. I successfully submit a json file to kafka topic then consume as follow
curl -X POST \
-H "Content-Type: application/json" \
--data '{"name": "quickstart-file-source", "config {"connector.class":"org.apache.kafka.connect.file.FileStreamSourceConnector", "tasks.max":"1", "topic":"quickstart-data", "file": "/tmp/quickstart/input.json"}}' \
http://localhost:28081/connectors
Above curl command has only one json file which executes successfully but I need to post multiple json files. Is there any way to do it?
Here is my kafka connect
docker run -d \
--name=kafka-connect-avro \
--net=host \
-e CONNECT_BOOTSTRAP_SERVERS=localhost:29091 \
-e CONNECT_REST_PORT=28081 \
-e CONNECT_GROUP_ID="quickstart-avro" \
-e CONNECT_CONFIG_STORAGE_TOPIC="quickstart-avro-config" \
-e CONNECT_OFFSET_STORAGE_TOPIC="quickstart-avro-offsets" \
-e CONNECT_STATUS_STORAGE_TOPIC="quickstart-avro-status" \
-e CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR=1 \
-e CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR=1 \
-e CONNECT_STATUS_STORAGE_REPLICATION_FACTOR=1 \
-e CONNECT_KEY_CONVERTER="org.apache.kafka.connect.json.JsonConverter" \
-e CONNECT_VALUE_CONVERTER="org.apache.kafka.connect.json.JsonConverter" \
-e CONNECT_INTERNAL_KEY_CONVERTER="org.apache.kafka.connect.json.JsonConverter" \
-e CONNECT_INTERNAL_VALUE_CONVERTER="org.apache.kafka.connect.json.JsonConverter" \
-e CONNECT_REST_ADVERTISED_HOST_NAME="localhost" \
-e CONNECT_LOG4J_ROOT_LOGLEVEL=DEBUG \
-v /tmp/quickstart/file:/tmp/quickstart \
confluentinc/cp-kafka-connect:latest
Reference link
You could make individual JSON files in the current directory and post them separately in a loop
e.g.
$ ls *.json # list your connectors
payload1.json
payload2.json
And then loop over them
for f in `ls *.json`; do
curl -X POST -H "Content-Type: application/json" \
--data#${f} http://localhost:28081/connectors
done
Or simpler to use cat

How to install mono 4.8 on Ubuntu 16.04

Ok, I feel like I should be able to figure this out based on the documentation provided by Mono, but nothing is working. Based on this guide and this note, I've tried running
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/ubuntu/dists/wheezy/snapshots/4.8.0" | sudo tee /etc/apt/sources.list.d/mono-official.list
sudo apt-get update
I've modifed that 2nd line a few times and or simply edited /etc/apt/sources.list.d/mono-official.list, trying other similar things, butevery time I run the sudo apt-get update, I get:
user#NAS:~$ sudo apt-get update
E: Malformed entry 1 in list file /etc/apt/sources.list.d/mono-official.list (Component)
E: The list of sources could not be read.
I need 4.8, as the app I need to use with mono does not work as well with 5.0. I currently have mono 4.2.1, but I believe it came pre-installed on my distro.
Your procedure looks sound, one small issue is that the second step should be
echo "deb http://download.mono-project.com/repo/ubuntu wheezy/snapshots/4.8.0 main" | sudo tee /etc/apt/sources.list.d/mono-official.list
Next step (after apt-get update) is installing the mono-devel 4.8.0 package and all its dependencies by version:
apt-get -f install \
mono-devel=4.8.0.524-0xamarin11 \
libmono-cecil-private-cil=4.8.0.524-0xamarin11 \
mono-mcs=4.8.0.524-0xamarin11 \
mono-gac=4.8.0.524-0xamarin11 \
mono-xbuild=4.8.0.524-0xamarin11 \
libmono-cil-dev=4.8.0.524-0xamarin11 \
libmono-2.0-dev=4.8.0.524-0xamarin11 \
libmonosgen-2.0-dev=4.8.0.524-0xamarin11 \
libmono-accessibility4.0-cil=4.8.0.524-0xamarin11 \
libmono-cairo4.0-cil=4.8.0.524-0xamarin11 \
libmono-codecontracts4.0-cil=4.8.0.524-0xamarin11 \
libmono-compilerservices-symbolwriter4.0-cil=4.8.0.524-0xamarin11 \
libmono-corlib4.5-cil=4.8.0.524-0xamarin11 \
libmono-cscompmgd0.0-cil=4.8.0.524-0xamarin11 \
libmono-csharp4.0c-cil=4.8.0.524-0xamarin11 \
libmono-custommarshalers4.0-cil=4.8.0.524-0xamarin11 \
libmono-data-tds4.0-cil=4.8.0.524-0xamarin11 \
libmono-db2-1.0-cil=4.8.0.524-0xamarin11 \
libmono-debugger-soft4.0a-cil=4.8.0.524-0xamarin11 \
libmono-http4.0-cil=4.8.0.524-0xamarin11 \
libmono-i18n4.0-all=4.8.0.524-0xamarin11 \
libmono-ldap4.0-cil=4.8.0.524-0xamarin11 \
libmono-management4.0-cil=4.8.0.524-0xamarin11 \
libmono-messaging4.0-cil=4.8.0.524-0xamarin11 \
libmono-messaging-rabbitmq4.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-build4.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-build-engine4.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-build-framework4.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-build-tasks-v4.0-4.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-build-utilities-v4.0-4.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-csharp4.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-visualc10.0-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-web-infrastructure1.0-cil=4.8.0.524-0xamarin11 \
libmono-oracle4.0-cil=4.8.0.524-0xamarin11 \
libmono-parallel4.0-cil=4.8.0.524-0xamarin11 \
libmono-peapi4.0a-cil=4.8.0.524-0xamarin11 \
libmono-posix4.0-cil=4.8.0.524-0xamarin11 \
libmono-rabbitmq4.0-cil=4.8.0.524-0xamarin11 \
libmono-relaxng4.0-cil=4.8.0.524-0xamarin11 \
libmono-security4.0-cil=4.8.0.524-0xamarin11 \
libmono-sharpzip4.84-cil=4.8.0.524-0xamarin11 \
libmono-simd4.0-cil=4.8.0.524-0xamarin11 \
libmono-smdiagnostics0.0-cil=4.8.0.524-0xamarin11 \
libmono-sqlite4.0-cil=4.8.0.524-0xamarin11 \
libmono-system4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-componentmodel-composition4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-componentmodel-dataannotations4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-configuration4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-configuration-install4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-core4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-data4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-data-datasetextensions4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-data-entity4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-data-linq4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-data-services4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-data-services-client4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-deployment4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-design4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-drawing4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-drawing-design4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-dynamic4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-enterpriseservices4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-identitymodel4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-identitymodel-selectors4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-io-compression4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-io-compression-filesystem4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-json4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-json-microsoft4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-ldap4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-ldap-protocols4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-management4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-messaging4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-net4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-net-http4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-net-http-formatting4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-net-http-webrequest4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-numerics4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-numerics-vectors4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-core2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-debugger2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-experimental2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-interfaces2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-linq2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-observable-aliases0.0-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-platformservices2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-providers2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-runtime-remoting2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-windows-forms2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reactive-windows-threading2.2-cil=4.8.0.524-0xamarin11 \
libmono-system-reflection-context4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-runtime4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-runtime-caching4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-runtime-durableinstancing4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-runtime-interopservices-runtimeinformation4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-runtime-serialization4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-runtime-serialization-formatters-soap4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-security4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-servicemodel4.0a-cil=4.8.0.524-0xamarin11 \
libmono-system-servicemodel-activation4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-servicemodel-discovery4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-servicemodel-internals0.0-cil=4.8.0.524-0xamarin11 \
libmono-system-servicemodel-routing4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-servicemodel-web4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-serviceprocess4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-threading-tasks-dataflow4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-transactions4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-abstractions4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-applicationservices4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-dynamicdata4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-extensions4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-extensions-design4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-http4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-http-selfhost4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-http-webhost4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-mobile4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-mvc3.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-razor2.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-regularexpressions4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-routing4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-services4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-webpages2.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-webpages-deployment2.0-cil=4.8.0.524-0xamarin11 \
libmono-system-web-webpages-razor2.0-cil=4.8.0.524-0xamarin11 \
libmono-system-windows4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-windows-forms4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-windows-forms-datavisualization4.0a-cil=4.8.0.524-0xamarin11 \
libmono-system-workflow-activities4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-workflow-componentmodel4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-workflow-runtime4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-xaml4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-xml4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-xml-linq4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-xml-serialization4.0-cil=4.8.0.524-0xamarin11 \
libmono-tasklets4.0-cil=4.8.0.524-0xamarin11 \
libmono-webbrowser4.0-cil=4.8.0.524-0xamarin11 \
libmono-webmatrix-data4.0-cil=4.8.0.524-0xamarin11 \
libmono-windowsbase4.0-cil=4.8.0.524-0xamarin11 \
libmono-xbuild-tasks4.0-cil=4.8.0.524-0xamarin11 \
libnunit-cil-dev=2.6.3+dfsg-1~xamarin2 \
libmono-codecontracts4.0-cil=4.8.0.524-0xamarin11 \
libmono-compilerservices-symbolwriter4.0-cil=4.8.0.524-0xamarin11 \
libmono-peapi4.0a-cil=4.8.0.524-0xamarin11 \
libmono-relaxng4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-configuration-install4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-data-linq4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-io-compression-filesystem4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-runtime4.0-cil=4.8.0.524-0xamarin11 \
libmono-system-servicemodel4.0a-cil=4.8.0.524-0xamarin11 \
libmono-system-web-services4.0-cil=4.8.0.524-0xamarin11 \
mono-csharp-shell=4.8.0.524-0xamarin11 \
mono-4.0-gac=4.8.0.524-0xamarin11 \
libmono-corlib4.5-cil=4.8.0.524-0xamarin11 \
libmono-microsoft-csharp4.0-cil=4.8.0.524-0xamarin11 \
mono-gac=4.8.0.524-0xamarin11 \
mono-runtime=4.8.0.524-0xamarin11 \
libmono-i18n-cjk4.0-cil=4.8.0.524-0xamarin11 \
libmono-i18n-mideast4.0-cil=4.8.0.524-0xamarin11 \
libmono-i18n-other4.0-cil=4.8.0.524-0xamarin11 \
libmono-i18n-rare4.0-cil=4.8.0.524-0xamarin11 \
libmono-i18n-west4.0-cil=4.8.0.524-0xamarin11 \
ca-certificates-mono=4.8.0.524-0xamarin11 \
libmonosgen-2.0-1=4.8.0.524-0xamarin11 \
"libnunit-console-runner2.6.3-cil=2.6.3+dfsg-1~xamarin2" \
"libnunit-core2.6.3-cil=2.6.3+dfsg-1~xamarin2" \
"libnunit-core-interfaces2.6.3-cil=2.6.3+dfsg-1~xamarin2" \
"libnunit-framework2.6.3-cil=2.6.3+dfsg-1~xamarin2" \
"libnunit-mocks2.6.3-cil=2.6.3+dfsg-1~xamarin2" \
"libnunit-util2.6.3-cil=2.6.3+dfsg-1~xamarin2" \
libmono-i18n4.0-cil=4.8.0.524-0xamarin11 \
mono-runtime-sgen=4.8.0.524-0xamarin11 \
mono-runtime-common=4.8.0.524-0xamarin11 \
monodoc-browser=4.2-0xamarin1 \
monodoc-base=4.8.0.524-0xamarin11
Actually, if you add ppa with target version (as user8174722 said)
echo "deb http://download.mono-project.com/repo/ubuntu wheezy/snapshots/4.8.0 main" | sudo tee /etc/apt/sources.list.d/mono-official.list
and you have not add any other version or main repo, you can install mono v4.8.0 with pure
apt install mono-devel
and you don't need to specify all this versions.
But be sure that you do not have other mono-project's repo in your /etc/apt directory. You can check it with
grep -d recurse -e 'mono-project' /etc/apt
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-complete
sudo vi /etc/ssh/sshd_config
^^ password authentication -> yes
You can found instruction to setup latest version of mono for ubuntu 16.04 and other distros/version on mono project site
www.mono-project.com/download/stable/
Ubuntu 16.04 (i386, amd64, armhf, arm64, ppc64el)
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-
keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt install apt-transport-https ca-certificates
echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel

How can I get Elasticsearch running on CoreOS?

I've a CoreOS cluster with three servers (on Digital Ocean), at this moment running MongoDB. Now I want to start Elasticsearch on this cluster with 1 replica (not using the Mongo river).
I followed the description as outlined here.
Resulting in two services, elasticsearch#.service & elasticsearch-discovery#.service.
elasticsearch#.service
[Unit]
Description=ElasticSearch service
After=etcd.service
After=docker.service
Before=elasticsearch-discovery#%i.service
Requires=elasticsearch-discovery#%i.service
[Service]
KillMode=none
TimeoutStartSec=0
TimeoutStopSec=360
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker kill %p-%i
ExecStartPre=-/usr/bin/docker rm %p-%i
ExecStartPre=-/usr/bin/bash -c "echo PreKill and rm done;"
ExecStartPre=/usr/bin/mkdir -p /data/elasticsearch
ExecStartPre=/usr/bin/docker pull dockerfile/elasticsearch
ExecStartPre=/usr/bin/bash -c "echo mkdir and docker pull done;"
ExecStart=/bin/bash -c "\
echo StartingUp; \
curl -f ${COREOS_PUBLIC_IPV4}:4001/v2/keys/services/elasticsearch; \
if [ $? = 0 ]; then \
UNICAST_HOSTS = $(etcdctl ls --recursive /services/elasticsearch | sed 's/\/services\/elasticsearch\///g' | sed 's/$/:9300/' | paste -s -d ','); \
echo Key found; \
else \
UNICAST_HOSTS=''; \
echo No Key found; \
fi;"
ExecStartPost=/bin/bash -c "\
echo Starting Docker; \
/usr/bin/docker run \
--name %p-%i \
--publish 9200:9200 \
--publish 9300:9300 \
--volume /data/elasticsearch:/data \
dockerfile/elasticsearch \
/elasticsearch/bin/elasticsearch \
--node.name=%p-%i \
--cluster.name=nvssearch \
--network.publish_host=${COREOS_PUBLIC_IPV4} \
--discovery.zen.ping.multicast.enabled=false \
--discovery.zen.ping.unicast.hosts=$UNICAST_HOSTS;"
ExecStop=/bin/bash/ -c "/usr/bin/docker kill %p-%i"
Restart=on-failure
[X-Fleet]
X-Conflicts=%p#*.service
elasticsearch-discovery#.service
[Unit]
Description=ElasticSearch discovery service
BindsTo=elasticsearch#%i.service
After=elasticsearch#%i.service
[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/bash -c '\
while true; do \
curl -f ${COREOS_PUBLIC_IPV4}:9200; \
if [ "$?" = "0" ]; then \
etcdctl set /services/elasticsearch/${COREOS_PUBLIC_IPV4} \ '{"http_port": 9200, "transport_port": 9300}\' --ttl 60; \
else \
etcdctl rm /services/elasticsearch/${COREOS_PUBLIC_IPV4}; \
fi; \
sleep 45; \
done'
ExecStop=/usr/bin.etcdctl rm /services/elasticsearch/${COREOS_PUBLIC_IPV4}
[X-Fleet]
X-ConditionMachineOf=elasticsearch#%i.service
But if I try to run the service (fleetctl submit / load / start elasticsearch#1.service), it immediately dies:
elasticsearch#1.service 475f6273.../IP inactive dead
Running fleetctl journal elasticsearch#1 results in the following message:
Mar 17 09:17:04 nvs-1 systemd[1]: Stopped ElasticSearch service.
That's all, no echoes I've added (to the service) are shown, or whatsoever. Anyone any ideas on how to get me further?
It is somewhat simpler to get Elasticsearch running with Weave. My blog post shows how to run it on Vagrant, however moving the same setup to cloud should be pretty straight-forward.
I've followed the same article you did and ran into the same issue. I tracked it down to the docker container not being available anymore, so I change the docker run command in the elasticsearch#service unit:
[Unit]
Description=ElasticSearch service
After=docker.service
Requires=docker.service
[Service]
TimeoutSec=180
EnvironmentFile=/etc/environment
ExecStartPre=/usr/bin/mkdir -p /data/elasticsearch
ExecStartPre=/usr/bin/docker pull elasticsearch
ExecStart=/bin/bash -c '\
curl -f ${COREOS_PRIVATE_IPV4}:4001/v2/keys/services/elasticsearch; \
if [ "$?" = "0" ]; then \
UNICAST_HOSTS=$(etcdctl ls --recursive /services/elasticsearch \
| sed "s/\/services\/elasticsearch\///g" \
| sed "s/$/:9300/" \
| paste -s -d","); \
else \
UNICAST_HOSTS=""; \
fi; \
/usr/bin/docker run \
--rm \
--name %p-%i \
--publish 9200:9200 \
--publish 9300:9300 \
--volume /data/elasticsearch:/data \
elasticsearch \
--node.name=%p-%i \
--cluster.name=logstash \
--network.publish_host=${COREOS_PRIVATE_IPV4} \
--discovery.zen.ping.multicast.enabled=false \
--discovery.zen.ping.unicast.hosts=$UNICAST_HOSTS'
ExecStop=/usr/bin/docker stop %p-%i
ExecStop=/usr/bin/docker rm %p-%i
[X-Fleet]
X-Conflicts=%p#*.service
Apart from that I think, on your original post, you're missing some quotes, double quotes and have some wrong blank spaces.
This is my current elastic-discovery#service for reference:
[Unit]
Description=ElasticSearch discovery service
BindsTo=elasticsearch#%i.service
[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/bash -c '\
while true; do \
curl -f ${COREOS_PRIVATE_IPV4}:9200; \
if [ "$?" = "0" ]; then \
etcdctl set /services/elasticsearch/${COREOS_PRIVATE_IPV4} \'{"http_port": 9200, "transport_port": 9300}\' --ttl 60; \
else \
etcdctl rm /services/elasticsearch/${COREOS_PRIVATE_IPV4}; \
fi; \
sleep 45; \
done'
ExecStop=/usr/bin/etcdctl rm /services/elasticsearch/${COREOS_PRIVATE_IPV4}
[X-Fleet]
X-ConditionMachineOf=elasticsearch#%i.service

Resources