从git上下载源码,把_site部署到容器中运行
下载地址:https://github.com/mobz/elasticsearch-head
访问: http://ip:9100/
拉取镜像:
[root@starseaing9228 ~]# docker pull elasticsearch:2.4.5
2.4.5: Pulling from library/elasticsearch
06b22ddb1913: Pull complete
336c28b408ed: Pull complete
1f3e6b8d80c3: Pull complete
aeac59510475: Pull complete
b01db8bd8540: Pull complete
f7f398af5fea: Pull complete
2e542fdaf109: Pull complete
c2f213d11280: Pull complete
2fd1cc621951: Pull complete
bdb4e2eca779: Pull complete
5b2ac3186d68: Pull complete
150d74a5354f: Pull complete
52db74c6e3a4: Pull complete
9dedf2f8d11f: Pull complete
34254b4cf7a2: Pull complete
Digest: sha256:f7f3d09083d8d21ce48fcd49392335e1eb0782f69f619dd4413a698a3318ab90
Status: Downloaded newer image for elasticsearch:2.4.5
[root@starseaing9228 ~]#
[root@starseaing9228 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7.26 2f52e94d8acb 9 days ago 373MB
tomcat 8.5.40 5a069ba3df4d 3 weeks ago 465MB
redis 5.0.4 a55fbf438dfd 5 weeks ago 95MB
elasticsearch 2.4.5 cd8905f85529 21 months ago 309MB
[root@starseaing9228 ~]# vi /usr/local/elasticsearch245/conf/elasticsearch.yml
elasticsearch.yml内容如下:
# ======================== Elasticsearch Configuration =========================
cluster.name: my-test
node.name: node-test
#path.data: D:/es-data-test/data
#path.logs: D:/es-data-test/logs
# 如果要开启远程访问需要设置为0.0.0.0,意思是允许任意IP连接
# network.host: 127.0.0.1
network.host: 0.0.0.0
http.port: 9200
#后面的两个配置项目需要添加,用于elasticsearch head连接es。
# http.cors.enabled true 如果启用了 HTTP 端口,那么此属性会指定是否允许跨源 REST 请求。
# http.cors.allowed.origin localhost 如果 http.cors.enabled 的值为 true,那么该属性会指定允许 REST 请求来自何处。
http.cors.enabled: true
http.cors.allow-origin: "*"
目录挂载:
配置文件:/usr/local/elasticsearch245/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
数据目录:/usr/local/elasticsearch245/data/:/usr/share/elasticsearch/data
docker运行命令为:
docker run --name elasticsearch245 -p 9200:9200 -p 9300:9300 -v /usr/local/elasticsearch245/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch245/data/:/usr/share/elasticsearch/data -d elasticsearch:2.4.5
[root@starseaing9228 ~]# docker run --name elasticsearch245 -p 9200:9200 -p 9300:9300 -v /usr/local/elasticsearch245/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch245/data/:/usr/share/elasticsearch/data -d elasticsearch:2.4.5
6dbc2c38e2b72d7aa673cecaae0fdbbd90ede9323926f4e434b9e27f2d394460
查看容器进程:
[root@starseaing9228 ~]#
[root@starseaing9228 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6dbc2c38e2b7 elasticsearch:2.4.5 "/docker-entrypoint.…" 4 seconds ago Up 2 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp elasticsearch245
查看运行的容器日志:
[root@starseaing9228 ~]# docker logs 6dbc2c38e2b7
[2019-05-04 03:18:50,630][WARN ][bootstrap ] unable to install syscall filter: seccomp unavailable: your kernel is buggy and you should upgrade
[2019-05-04 03:18:50,995][INFO ][node ] [node-test] version[2.4.5], pid[1], build[c849dd1/2017-04-24T16:18:17Z]
[2019-05-04 03:18:50,995][INFO ][node ] [node-test] initializing ...
[2019-05-04 03:18:52,010][INFO ][plugins ] [node-test] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2019-05-04 03:18:52,141][INFO ][env ] [node-test] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/vda1)]], net usable_space [42.4gb], net total_space [49gb], spins? [possibly], types [ext4]
[2019-05-04 03:18:52,141][INFO ][env ] [node-test] heap size [1015.6mb], compressed ordinary object pointers [true]
[2019-05-04 03:18:55,725][INFO ][node ] [node-test] initialized
[2019-05-04 03:18:55,725][INFO ][node ] [node-test] starting ...
[2019-05-04 03:18:55,907][INFO ][transport ] [node-test] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
[2019-05-04 03:18:55,922][INFO ][discovery ] [node-test] my-test/8NOtfO0EQZGAEn3KnLaY7Q
[2019-05-04 03:18:59,049][INFO ][cluster.service ] [node-test] new_master {node-test}{8NOtfO0EQZGAEn3KnLaY7Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2019-05-04 03:18:59,122][INFO ][http ] [node-test] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}
[2019-05-04 03:18:59,122][INFO ][node ] [node-test] started
[2019-05-04 03:18:59,195][INFO ][gateway ] [node-test] recovered [0] indices into cluster_state
进入容器:
[root@starseaing9228 ~]# docker exec -it 6dbc2c38e2b7 /bin/bash
root@6dbc2c38e2b7:/usr/share/elasticsearch# ls
NOTICE.txt README.textile bin config data lib logs modules plugins
root@6dbc2c38e2b7:/usr/share/elasticsearch# cd config/
root@6dbc2c38e2b7:/usr/share/elasticsearch/config# ls
elasticsearch.yml logging.yml scripts
查看配置文件:
root@6dbc2c38e2b7:/usr/share/elasticsearch/config# cat elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
cluster.name: my-test
node.name: node-test
#path.data: D:/es-data-test/data
#path.logs: D:/es-data-test/logs
# 如果要开启远程访问需要设置为0.0.0.0,意思是允许任意IP连接
# network.host: 127.0.0.1
network.host: 0.0.0.0
http.port: 9200
#后面的两个配置项目需要添加,用于elasticsearch head连接es。
# http.cors.enabled true 如果启用了 HTTP 端口,那么此属性会指定是否允许跨源 REST 请求。
# http.cors.allowed.origin localhost 如果 http.cors.enabled 的值为 true,那么该属性会指定允许 REST 请求来自何处。
http.cors.enabled: true
http.cors.allow-origin: "*"
使用elasticsearch-head连接: