在Ubuntu14.04 上面安装Elasticsearch5.6.16,下面是操作步骤以及截图效果
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.deb sha1sum elasticsearch-5.6.16.deb
sudo dpkg -i elasticsearch-5.6.16.deb
ysq@ubuntu:~/Downloads$ sudo dpkg -i elasticsearch-5.6.16.deb
Selecting previously unselected package elasticsearch.
(Reading database ... 167157 files and directories currently installed.)
Preparing to unpack elasticsearch-5.6.16.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (5.6.16) ...
Setting up elasticsearch (5.6.16) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
ysq@ubuntu:~/Downloads$ whereis elasticsearch
elasticsearch: /etc/elasticsearch /usr/share/elasticsearch
ysq@ubuntu:~/Downloads$ cd /etc
ls -l
drwxr-s--- 3 root elasticsearch 4096 Apr 18 16:12 elasticsearch
cd /usr/share/
ls -l
drwxr-xr-x 6 root root 4096 Apr 18 16:12 elasticsearch
cd /etc/init.d/
ls -l
-rwxr-x--- 1 root root 5329 Mar 13 23:34 elasticsearch
ysq@ubuntu:~$ ps -p 1
PID TTY TIME CMD
1 ? 00:00:02 init
ysq@ubuntu:~$ sudo update-rc.d elasticsearch defaults 95 10
Adding system startup for /etc/init.d/elasticsearch ...
/etc/rc0.d/K10elasticsearch -> ../init.d/elasticsearch
/etc/rc1.d/K10elasticsearch -> ../init.d/elasticsearch
/etc/rc6.d/K10elasticsearch -> ../init.d/elasticsearch
/etc/rc2.d/S95elasticsearch -> ../init.d/elasticsearch
/etc/rc3.d/S95elasticsearch -> ../init.d/elasticsearch
/etc/rc4.d/S95elasticsearch -> ../init.d/elasticsearch
/etc/rc5.d/S95elasticsearch -> ../init.d/elasticsearch
ysq@ubuntu:~$
ysq@ubuntu:~$ sudo -i service elasticsearch start
* Starting Elasticsearch Server Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000008a660000, 1973026816, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1973026816 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid16744.log
fail]
出现这个错误是因为,你的内存不足,解决办法,修改elasticsearch的配置文件
sudo vim jvm.options
2g=512m
2g=512m
ysq@ubuntu:~$ ps -ef|grep elasticsearch
ysq 17008 3100 0 16:20 pts/1 00:00:00 grep --color=auto elasticsearch
ysq@ubuntu:~$ clear
ysq@ubuntu:/etc$ cd elasticsearch/
bash: cd: elasticsearch/: Permission denied
ysq@ubuntu:/etc$ cd elasticsearch/
bash: cd: elasticsearch/: Permission denied
ysq@ubuntu:/etc$ sudo chmod -R 775 elasticsearch/
ysq@ubuntu:/etc$ cd elasticsearch/
ysq@ubuntu:/etc/elasticsearch$
ysq@ubuntu:/etc/elasticsearch$ sudo vim jvm.options
sudo: vim: command not found
ysq@ubuntu:/etc/elasticsearch$ sudo apt-get install vim
Reading package lists... Done
Building dependency tree
Setting up vim-runtime (2:7.4.052-1ubuntu3.1) ...
Processing /usr/share/vim/addons/doc
Setting up vim (2:7.4.052-1ubuntu3.1) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
ysq@ubuntu:/etc/elasticsearch$ sudo vim jvm.options
ysq@ubuntu:/etc/elasticsearch$
sudo vim jvm.options
2g=512m
2g=512m
ysq@ubuntu:~$ sudo -i service elasticsearch start
* Starting Elasticsearch Server [ OK ]
ysq@ubuntu:~$
ysq@ubuntu:/etc/elasticsearch$ sudo vim jvm.options
ysq@ubuntu:/etc/elasticsearch$ cd ~
ysq@ubuntu:~$ sudo -i service elasticsearch start
* Starting Elasticsearch Server [ OK ]
ysq@ubuntu:~$ sudo -i service elasticsearch status
* elasticsearch is running
ysq@ubuntu:~$ sudo -i service elasticsearch stop
* Stopping Elasticsearch Server [ OK ]
ysq@ubuntu:~$ sudo -i service elasticsearch status
* elasticsearch is not running
ysq@ubuntu:~$ sudo -i service elasticsearch start
* Starting Elasticsearch Server [ OK ]
ysq@ubuntu:~$ sudo -i service elasticsearch restart
* Stopping Elasticsearch Server [ OK ]
* Starting Elasticsearch Server [ OK ]
ysq@ubuntu:~$ cd /usr/share/elasticsearch/
ysq@ubuntu:/usr/share/elasticsearch$ ls -l
total 220
drwxr-xr-x 2 root root 4096 Apr 18 16:12 bin
drwxr-xr-x 2 root root 4096 Apr 18 16:12 lib
drwxr-xr-x 13 root root 4096 Apr 18 16:12 modules
-rw-r--r-- 1 root root 194187 Mar 13 23:34 NOTICE.txt
drwxr-xr-x 2 root root 4096 Mar 13 23:34 plugins
-rw-r--r-- 1 root root 9491 Mar 13 23:34 README.textile
ysq@ubuntu:/usr/share/elasticsearch$ curl 127.0.0.1:9200
{
"name" : "MqEuKSl",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "D7vHrI6-QOuJLZKqgdEz4g",
"version" : {
"number" : "5.6.16",
"build_hash" : "3a740d1",
"build_date" : "2019-03-13T15:33:36.565Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
ysq@ubuntu:/usr/share/elasticsearch$ curl -X GET "127.0.0.1:9200"
{
"name" : "MqEuKSl",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "D7vHrI6-QOuJLZKqgdEz4g",
"version" : {
"number" : "5.6.16",
"build_hash" : "3a740d1",
"build_date" : "2019-03-13T15:33:36.565Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
ysq@ubuntu:/usr/share/elasticsearch$ curl -X GET "localhost:9200"
{
"name" : "MqEuKSl",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "D7vHrI6-QOuJLZKqgdEz4g",
"version" : {
"number" : "5.6.16",
"build_hash" : "3a740d1",
"build_date" : "2019-03-13T15:33:36.565Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
ysq@ubuntu:/usr/share/elasticsearch$
安装后Elasticsearch不会自动启动。如何启动和停止Elasticsearch取决于您的系统是使用SysV init
还是systemd
(由较新的发行版使用)。您可以通过运行此命令来判断正在使用哪个:
ps -p 1
可以使用以下service
命令启动和停止Elasticsearch :
sudo -i service elasticsearch start
sudo -i service elasticsearch stop
如果Elasticsearch因任何原因无法启动,它将打印STDOUT失败的原因。可以在中找到日志文件/var/log/elasticsearch/
。