查看centos7内核版本,需要大于3.10
uname -r
3.10.0-957.el7.x86_64
elasticsearch需要安装jdk
sudo yum -y install java-11-openjdk-devel
sudo yum -y install java-11-openjdk(只安装Java运行环境)
移除老版本docker(如果有)
sudo yum remove docker docker-common docker-selinux dockesr-engine
安装需要的依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
添加repo源
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
列出docker现有版本
yum list docker-ce --showduplicates | sort -r
安装docker
sudo yum install docker-ce -- 直接安装最新
sudo yum install docker-ce-17.12.0.ce
查看版本
docker version
开机自启,启动docker
sudo systemctl start docker -- 启动
sudo systemctl enable docker --开机自启
创建elasticsearch用户
groupadd elasticsearch创建ela组
useradd -g elasticsearch elasticsearch 创建elasticsearch用户,并且加入elasticsearch组
passwd elasticsearch为elasticsearch用户设定登录密码
visudo(或者vim /etc/sudoers)
添加一行:elasticsearchALL=(ALL) ALL 是得elasticsearch用户拥有执行权限
docker安装es(一下均在root用户下进行)
docker pull elasticsearch:7.7.0
su elasticsearch(切换到elasticearch用户)
mkdir -p /home/elasticsearch/config
mkdir -p /home/elasticsearch/data
mkdir -p /home/elasticsearch/plugins
cd /home
cd /home/elasticsearch/
chmod 777 config
chmod 777 data
chmod 777 plugins
cd config
vi elasticsearch.yml
添加以下内容:
cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: ["node-1"]
加大最大进程数和虚拟内存数
编辑 /etc/security/limits.conf,再配置文件下面追加以下内容;
soft nofile 65536
hard nofile 65536
2编辑 /etc/sysctl.conf,追加以下内容:
vm.max_map_count=655360
保存后,执行:
sysctl -p
or
查看max_map_count的值 默认是65530
cat /proc/sys/vm/max_map_count
重新设置max_map_count的值
sysctl -w vm.max_map_count=262144
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” -e ES_JAVA_OPTS="-Xms512m -Xmx512m" --volume /home/ela/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml --volume /home/ela/data:/usr/share/elasticsearch/data --volume /home/ela/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.7.0
docker ps --查看是否启动 启动成功以后测试一下 curl http://127.0.0.1:9200 { “name” : “314e2f262dfa”, “cluster_name” : “docker-cluster”, “cluster_uuid” : “na”, “version” : { “number” : “7.7.0”, “build_flavor” : “default”, “build_type” : “docker”, “build_hash” : “81a1e9eda8e6183f5237786246f6dced26a10eaf”, “build_date” : “2020-05-12T02:01:37.602180Z”, “build_snapshot” : false, “lucene_version” : “8.5.1”, “minimum_wire_compatibility_version” : “6.8.0”, “minimum_index_compatibility_version” : “6.0.0-beta1” }, “tagline” : “You Know, for Search” }
### 注意
elasticserach 不能用root用户,需要chown -R ela:ela elasticsearch/
elasticsearch 需要所有权限 设置挂载目录/1/logs和/1/data的权限,chmod 777 /1/logs和chmod 777 /1/data
其它错误参考:: [总结—elasticsearch启动失败的几种情况及解决](https://blog.51cto.com/u_10950710/2124131)
快速开始参考:[elasticsearch安装启动之后的快速使用](https://blog.csdn.net/u014073556/article/details/80654099)
|