如何在 Vagrant 中安装和 运行 elasticsearch?
How to install and run elasticsearch in Vagrant?
我正在尝试在 Vagrant 中安装和 运行 Elasticsearch。问题是当我尝试 运行 elasticsearch 时出现以下错误:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [file].
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_deprecation.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [deprecation_log_file].
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_index_indexing_slowlog.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [index_indexing_slow_log_file].
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_index_search_slowlog.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [index_search_slow_log_file].
Exception in thread "main" java.lang.IllegalStateException: Unable to access 'path.plugins' (/home/vagrant/elasticsearch-2.3.0/plugins)
Likely root cause: java.nio.file.AccessDeniedException: /home/vagrant/elasticsearch-2.3.0/plugins
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
at java.nio.file.Files.createDirectory(Files.java:674)
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
at java.nio.file.Files.createDirectories(Files.java:767)
at org.elasticsearch.bootstrap.Security.ensureDirectoryExists(Security.java:337)
at org.elasticsearch.bootstrap.Security.addPath(Security.java:314)
at org.elasticsearch.bootstrap.Security.addFilePermissions(Security.java:246)
at org.elasticsearch.bootstrap.Security.createPermissions(Security.java:212)
at org.elasticsearch.bootstrap.Security.configure(Security.java:118)
at org.elasticsearch.bootstrap.Bootstrap.setupSecurity(Bootstrap.java:196)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
我认为问题是它没有写权限。当我通过配置安装弹性时,我获得以下权限:
drwxr-xr-x 2 root root 4096 Apr 3 09:26 bin
drwxr-xr-x 2 root root 4096 Apr 3 09:26 config
drwxr-xr-x 2 root root 4096 Apr 3 09:26 lib
-rw-rw-r-- 1 vagrant vagrant 11358 Jan 27 12:53 LICENSE.txt
drwxrwxr-x 5 vagrant vagrant 4096 Mar 29 08:04 modules
-rw-rw-r-- 1 vagrant vagrant 150 Jan 27 12:53 NOTICE.txt
-rw-rw-r-- 1 vagrant vagrant 8700 Jan 27 12:53 README.textile
但是当我手动执行相同操作时:
drwxrwxr-x 2 vagrant vagrant 4096 Apr 2 18:20 bin
drwxrwxr-x 2 vagrant vagrant 4096 Apr 2 18:20 config
drwxrwxr-x 2 vagrant vagrant 4096 Apr 2 18:20 lib
-rw-rw-r-- 1 vagrant vagrant 11358 Jan 27 12:53 LICENSE.txt
drwxrwxr-x 5 vagrant vagrant 4096 Mar 29 08:04 modules
-rw-rw-r-- 1 vagrant vagrant 150 Jan 27 12:53 NOTICE.txt
-rw-rw-r-- 1 vagrant vagrant 8700 Jan 27 12:53 README.textile
我的 Vagrantfile 是:
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install software-properties-common python-software-properties -y
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
sudo apt-get install oracle-java8-installer -y -q
wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.0/elasticsearch-2.3.0.tar.gz
tar -xzf elasticsearch-*.tar.gz
mv elasticsearch-2.3.0 elasticsearch
rm elasticsearch-*
SHELL
end
当您 运行 从您的文件进行配置时,它 运行 是根用户,因此如您所见,vagrant 用户将没有对您的文件夹的写入权限。
规则的拇指是
privileged: false
-> 作为流浪者执行
privileged: true
-> 以 root 身份执行(如果省略特权则默认)
将您的 Vagrantfile 更改为
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install software-properties-common python-software-properties -y
apt-add-repository ppa:webupd8team/java
apt-get update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
apt-get install oracle-java8-installer -y -q
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.0/elasticsearch-2.3.0.tar.gz
tar -xzf elasticsearch-*.tar.gz
mv elasticsearch-2.3.0 elasticsearch
rm elasticsearch-*
SHELL
end
在第一个配置中,我删除了所有 sudo,因为它已经是 root 用户 运行正在执行命令。
第二个配置块将由 vagrant 用户 运行 进行,并将在 /home/vagrant 中从 vagrant 用户安装 ElasticSearch:
vagrant@precise64:~/elasticsearch/bin$ ./elasticsearch
[2016-04-03 10:55:01,423][INFO ][node ] [Araña] version[2.3.0], pid[6748], build[8371be8/2016-03-29T07:54:48Z]
[2016-04-03 10:55:01,424][INFO ][node ] [Araña] initializing ...
[2016-04-03 10:55:02,296][INFO ][plugins ] [Araña] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2016-04-03 10:55:02,328][INFO ][env ] [Araña] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [35.1gb], net total_space [39.4gb], spins? [possibly], types [ext4]
[2016-04-03 10:55:02,328][INFO ][env ] [Araña] heap size [1015.6mb], compressed ordinary object pointers [true]
[2016-04-03 10:55:02,329][WARN ][env ] [Araña] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536]
[2016-04-03 10:55:05,107][INFO ][node ] [Araña] initialized
[2016-04-03 10:55:05,108][INFO ][node ] [Araña] starting ...
[2016-04-03 10:55:05,228][INFO ][transport ] [Araña] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2016-04-03 10:55:05,238][INFO ][discovery ] [Araña] elasticsearch/gf23pBqpSs2wDrLswVeSyQ
[2016-04-03 10:55:08,313][INFO ][cluster.service ] [Araña] new_master {Araña}{gf23pBqpSs2wDrLswVeSyQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-04-03 10:55:08,341][INFO ][http ] [Araña] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2016-04-03 10:55:08,342][INFO ][node ] [Araña] started
[2016-04-03 10:55:08,366][INFO ][gateway ] [Araña] recovered [0] indices into cluster_state
^C[2016-04-03 10:55:22,870][INFO ][node ] [Araña] stopping ...
[2016-04-03 10:55:22,884][INFO ][node ] [Araña] stopped
[2016-04-03 10:55:22,885][INFO ][node ] [Araña] closing ...
[2016-04-03 10:55:22,899][INFO ][node ] [Araña] closed
来自您的访客:
$ cd /home/vagrant/elasticsearch-2.3.0/
$ sudo chmod -R a+w logs
为了安全起见,你也可以做...
$ sudo touch logs/elasticsearch.log logs/elasticsearch_deprecation.log logs/elasticsearch_index_indexing_slowlog.log logs/elasticsearch_index_search_slowlog.log
然后重新启动 and/or 从主机重新配置
$ vagrant reload
或
$ vagrant reload --provision
或
$ vagrant halt && vagrant up --provision
最后两个命令理想地做同样的事情,虽然我注意到 运行 重新加载而不是 halting/upping 时有些奇怪。
我正在尝试在 Vagrant 中安装和 运行 Elasticsearch。问题是当我尝试 运行 elasticsearch 时出现以下错误:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [file].
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_deprecation.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [deprecation_log_file].
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_index_indexing_slowlog.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [index_indexing_slow_log_file].
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_index_search_slowlog.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [index_search_slow_log_file].
Exception in thread "main" java.lang.IllegalStateException: Unable to access 'path.plugins' (/home/vagrant/elasticsearch-2.3.0/plugins)
Likely root cause: java.nio.file.AccessDeniedException: /home/vagrant/elasticsearch-2.3.0/plugins
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
at java.nio.file.Files.createDirectory(Files.java:674)
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
at java.nio.file.Files.createDirectories(Files.java:767)
at org.elasticsearch.bootstrap.Security.ensureDirectoryExists(Security.java:337)
at org.elasticsearch.bootstrap.Security.addPath(Security.java:314)
at org.elasticsearch.bootstrap.Security.addFilePermissions(Security.java:246)
at org.elasticsearch.bootstrap.Security.createPermissions(Security.java:212)
at org.elasticsearch.bootstrap.Security.configure(Security.java:118)
at org.elasticsearch.bootstrap.Bootstrap.setupSecurity(Bootstrap.java:196)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
我认为问题是它没有写权限。当我通过配置安装弹性时,我获得以下权限:
drwxr-xr-x 2 root root 4096 Apr 3 09:26 bin
drwxr-xr-x 2 root root 4096 Apr 3 09:26 config
drwxr-xr-x 2 root root 4096 Apr 3 09:26 lib
-rw-rw-r-- 1 vagrant vagrant 11358 Jan 27 12:53 LICENSE.txt
drwxrwxr-x 5 vagrant vagrant 4096 Mar 29 08:04 modules
-rw-rw-r-- 1 vagrant vagrant 150 Jan 27 12:53 NOTICE.txt
-rw-rw-r-- 1 vagrant vagrant 8700 Jan 27 12:53 README.textile
但是当我手动执行相同操作时:
drwxrwxr-x 2 vagrant vagrant 4096 Apr 2 18:20 bin
drwxrwxr-x 2 vagrant vagrant 4096 Apr 2 18:20 config
drwxrwxr-x 2 vagrant vagrant 4096 Apr 2 18:20 lib
-rw-rw-r-- 1 vagrant vagrant 11358 Jan 27 12:53 LICENSE.txt
drwxrwxr-x 5 vagrant vagrant 4096 Mar 29 08:04 modules
-rw-rw-r-- 1 vagrant vagrant 150 Jan 27 12:53 NOTICE.txt
-rw-rw-r-- 1 vagrant vagrant 8700 Jan 27 12:53 README.textile
我的 Vagrantfile 是:
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install software-properties-common python-software-properties -y
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
sudo apt-get install oracle-java8-installer -y -q
wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.0/elasticsearch-2.3.0.tar.gz
tar -xzf elasticsearch-*.tar.gz
mv elasticsearch-2.3.0 elasticsearch
rm elasticsearch-*
SHELL
end
当您 运行 从您的文件进行配置时,它 运行 是根用户,因此如您所见,vagrant 用户将没有对您的文件夹的写入权限。
规则的拇指是
privileged: false
-> 作为流浪者执行privileged: true
-> 以 root 身份执行(如果省略特权则默认)
将您的 Vagrantfile 更改为
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install software-properties-common python-software-properties -y
apt-add-repository ppa:webupd8team/java
apt-get update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
apt-get install oracle-java8-installer -y -q
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.0/elasticsearch-2.3.0.tar.gz
tar -xzf elasticsearch-*.tar.gz
mv elasticsearch-2.3.0 elasticsearch
rm elasticsearch-*
SHELL
end
在第一个配置中,我删除了所有 sudo,因为它已经是 root 用户 运行正在执行命令。
第二个配置块将由 vagrant 用户 运行 进行,并将在 /home/vagrant 中从 vagrant 用户安装 ElasticSearch:
vagrant@precise64:~/elasticsearch/bin$ ./elasticsearch
[2016-04-03 10:55:01,423][INFO ][node ] [Araña] version[2.3.0], pid[6748], build[8371be8/2016-03-29T07:54:48Z]
[2016-04-03 10:55:01,424][INFO ][node ] [Araña] initializing ...
[2016-04-03 10:55:02,296][INFO ][plugins ] [Araña] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2016-04-03 10:55:02,328][INFO ][env ] [Araña] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [35.1gb], net total_space [39.4gb], spins? [possibly], types [ext4]
[2016-04-03 10:55:02,328][INFO ][env ] [Araña] heap size [1015.6mb], compressed ordinary object pointers [true]
[2016-04-03 10:55:02,329][WARN ][env ] [Araña] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536]
[2016-04-03 10:55:05,107][INFO ][node ] [Araña] initialized
[2016-04-03 10:55:05,108][INFO ][node ] [Araña] starting ...
[2016-04-03 10:55:05,228][INFO ][transport ] [Araña] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2016-04-03 10:55:05,238][INFO ][discovery ] [Araña] elasticsearch/gf23pBqpSs2wDrLswVeSyQ
[2016-04-03 10:55:08,313][INFO ][cluster.service ] [Araña] new_master {Araña}{gf23pBqpSs2wDrLswVeSyQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-04-03 10:55:08,341][INFO ][http ] [Araña] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2016-04-03 10:55:08,342][INFO ][node ] [Araña] started
[2016-04-03 10:55:08,366][INFO ][gateway ] [Araña] recovered [0] indices into cluster_state
^C[2016-04-03 10:55:22,870][INFO ][node ] [Araña] stopping ...
[2016-04-03 10:55:22,884][INFO ][node ] [Araña] stopped
[2016-04-03 10:55:22,885][INFO ][node ] [Araña] closing ...
[2016-04-03 10:55:22,899][INFO ][node ] [Araña] closed
来自您的访客:
$ cd /home/vagrant/elasticsearch-2.3.0/
$ sudo chmod -R a+w logs
为了安全起见,你也可以做...
$ sudo touch logs/elasticsearch.log logs/elasticsearch_deprecation.log logs/elasticsearch_index_indexing_slowlog.log logs/elasticsearch_index_search_slowlog.log
然后重新启动 and/or 从主机重新配置
$ vagrant reload
或
$ vagrant reload --provision
或
$ vagrant halt && vagrant up --provision
最后两个命令理想地做同样的事情,虽然我注意到 运行 重新加载而不是 halting/upping 时有些奇怪。