Merge pull request #13579 from nik9000/run_plugin_as_elasticsearch_in_tar

Run bin/plugin as elasticsearch in tar distro
This commit is contained in:
Nik Everett 2015-09-22 11:19:19 -04:00
commit 4d47015a0c
5 changed files with 34 additions and 12 deletions

View File

@ -13,6 +13,15 @@ Run the following command to get usage instructions:
sudo bin/plugin -h
-----------------------------------
[IMPORTANT]
.Running as root
=====================
If Elasticsearch was installed using the deb or rpm package then run
`bin/plugin` as `root` so it can write to the appropriate files on disk.
Otherwise run `bin/plugin` as the user that owns all of the Elasticsearch
files.
=====================
[[installation]]
=== Installing Plugins
@ -222,4 +231,3 @@ plugin.mandatory: mapper-attachments,lang-groovy
--------------------------------------------------
For safety reasons, a node will not start if it is missing a mandatory plugin.

View File

@ -316,16 +316,12 @@ wait_for_elasticsearch_status() {
echo "Making sure elasticsearch is up..."
wget -O - --retry-connrefused --waitretry=1 --timeout=60 --tries 60 http://localhost:9200 || {
echo "Looks like elasticsearch never started. Here is its log:"
if [ -r "/tmp/elasticsearch/elasticsearch.pid" ]; then
cat /tmp/elasticsearch/logs/elasticsearch.log
else
if [ -e '/var/log/elasticsearch/elasticsearch.log' ]; then
cat /var/log/elasticsearch/elasticsearch.log
if [ -e "$ESLOG/elasticsearch.log" ]; then
cat "$ESLOG/elasticsearch.log"
else
echo "The elasticsearch log doesn't exist. Maybe /vag/log/messages has something:"
tail -n20 /var/log/messages
fi
fi
false
}
@ -398,6 +394,7 @@ move_config() {
mv "$oldConfig"/* "$ESCONFIG"
chown -R elasticsearch:elasticsearch "$ESCONFIG"
assert_file_exist "$ESCONFIG/elasticsearch.yml"
assert_file_exist "$ESCONFIG/logging.yml"
}
# Copies a script into the Elasticsearch install.

View File

@ -67,6 +67,7 @@ if [[ "$BATS_TEST_FILENAME" =~ 25_tar_plugins.bats$ ]]; then
}
export ESHOME=/tmp/elasticsearch
export_elasticsearch_paths
export ESPLUGIN_COMMAND_USER=elasticsearch
else
load os_package
if is_rpm; then
@ -75,6 +76,7 @@ else
GROUP='DEB PLUGINS'
fi
export_elasticsearch_paths
export ESPLUGIN_COMMAND_USER=root
install() {
install_package
verify_package_installation

View File

@ -32,10 +32,18 @@ install_plugin() {
assert_file_exist "$path"
"$ESHOME/bin/plugin" install "file://$path"
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/plugin" install "file://$path"
assert_file_exist "$ESPLUGINS/$name"
assert_file_exist "$ESPLUGINS/$name/plugin-descriptor.properties"
# At some point installing or removing plugins caused elasticsearch's logs
# to be owned by root. This is bad so we want to make sure it doesn't
# happen.
if [ -e "$ESLOG" ] && [ $(stat "$ESLOG" --format "%U") == "root" ]; then
echo "$ESLOG is now owned by root! That'll break logging when elasticsearch tries to start."
false
fi
}
install_jvm_plugin() {
@ -50,9 +58,17 @@ remove_plugin() {
local name=$1
echo "Removing $name...."
"$ESHOME/bin/plugin" remove $name
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/plugin" remove $name
assert_file_not_exist "$ESPLUGINS/$name"
# At some point installing or removing plugins caused elasticsearch's logs
# to be owned by root. This is bad so we want to make sure it doesn't
# happen.
if [ -e "$ESLOG" ] && [ $(stat "$ESLOG" --format "%U") == "root" ]; then
echo "$ESLOG is now owned by root! That'll break logging when elasticsearch tries to start."
false
fi
}
# Install the jvm-example plugin which fully excercises the special case file

View File

@ -73,7 +73,6 @@ export_elasticsearch_paths() {
export ESSCRIPTS="$ESCONFIG/scripts"
export ESDATA="$ESHOME/data"
export ESLOG="$ESHOME/logs"
}
# Checks that all directories & files are correctly installed