docker 安装开发环境 - (6)安装elasticsearch

安装 java

官网查看需要的版本
javahttps://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
(现在下载居然要注册账号了 。。。。)

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn/java/jdk/8u212-b10/59066701cf1a433da9770636fbc4c9aa/jdk-8u212-linux-x64.rpm?AuthParam=1556432487_688100c71155d0af4d21e06035a8d74a"

安装rpm包
rpm -ivh jdk-8u212-linux-x64.rpm?AuthParam=1556432487_688100c71155d0af4d21e06035a8d74a

查看 java 版本

[root@b6250d32c91a penglai]# java -version
java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)

环境变量修改

vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_212-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

使能环境变量

source /etc/profile

安装elasticsearch

下载 es 2.4.0(这个版本太老了)

wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.4.0/elasticsearch-2.4.0.rpm

安装

 rpm -ivh elasticsearch-2.4.0.rpm
[root@b6250d32c91a penglai]# systemctl enable elasticsearch
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.
[root@b6250d32c91a penglai]# 
[root@b6250d32c91a penglai]# 
[root@b6250d32c91a penglai]# systemctl start elasticsearch
[root@b6250d32c91a penglai]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-04-28 15:04:33 UTC; 6s ago
     Docs: http://www.elastic.co
  Process: 6494 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
 Main PID: 6495 (java)
   CGroup: /docker/b6250d32c91aca5f67087217f80b245f4ed56ffb9308c4f418337528870e58fc/system.slice/elasticsearch.service
           └─6495 /bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancy...
           ‣ 6495 /bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancy...

设置外网可以访问
vi /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0

生成自己的镜像

sudo docker commit -m="has mysql" -a="river" b6250d32c91a river/centos6
sudo docker run -itd --privileged=true -p 3306:3306 -p 6379:6379 -p 5672:5672 -p 15672:15672 -p 27017:27017 -p 9200:9200 -p 9300:9300 -p 10022:22 -p 10021:21 river/centos6 init

测试下

[penglai@bogon ~]$ curl -XGET 'http://192.168.130.31:9200'
{
  "name" : "Ion",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.4.0",
    "build_hash" : "ce9f0c7394dee074091dd1bc4e9469251181fc55",
    "build_timestamp" : "2016-08-29T09:14:17Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

至此 es 就安装好了。

参考地址
java 安装 https://www.jianshu.com/p/848b06dd19aa
es安装 https://www.jianshu.com/p/527a474bb6eb

你可能感兴趣的:(docker 安装开发环境 - (6)安装elasticsearch)