# 如何搭建 es


# 一、下载Linux版本的Elasticsearch

# 1:最新版的下载地址:

最新版 (opens new window)

# 2:Elasticsearch7.1.0版的下载地址:

Elasticsearch7.1.0版 (opens new window)

# 3:Elasticsearch 历史版本下载地址:

历史版本 (opens new window)

# 二、上传服务器,并解压

 tar -zxvf elasticsearch-7.1.0-linux-x86_64.tar.gz

# 三:创建ES用户,并赋予权限

# 1、创建一个esroot用户并设置初始密码

useradd -c 'ES user' -d /home/esroot esroot

passwd esroot2022

# 2.将elasticsearch安装目录属主权限改为 esroot 用户

chown -R esroot:esroot /data0/es/elasticsearch-7.1.0/

groupadd elasticsearch

# 3.切换用户到 esroot

su esroot

# 四:启动 Elasticsearch

# 进入Elasticsearch 的bin 目录

cd /data0/es/elasticsearch-7.1.0/bin/

# 启动

#当前进程启动

./elasticsearch

#后台进程启动

./elasticsearch -d

# 五:常见错误以及解决方式

# 1:elasticsearch 已经正常启动了,浏览器访问localhost:9200,无法出现版本信息?

1:首先查看一下服务器对应的端口9200 9300 是否被防火墙拦截了

2:如果是阿里云的服务器,安全组是否设置了允许9200,9300端口的请求

3:在elasticsearch的config目录下,修改elasticsearch.yml配置文件

node.name: node-1

network.host: 0.0.0.0

cluster.initial_master_nodes: ["node-1"]

# 2:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]?(注意:切换到root用户,否则提示没有权限)

1:打开 /etc/sysctl.conf 文件最后添加一行 vm.max_map_count=262144

 2:执行 /sbin/sysctl -p 立即生效

 3:重启启动 elasticsearch

# 3:the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured


1:在elasticsearch的config目录下,修改elasticsearch.yml配置文件

2:cluster.initial_master_nodes: ["node-1"] #这里的node-1为node-name配置的值 

参考文档 (opens new window)

PUT  /co_order_main
{
  "mappings":{
    "properties":{"orderType":{"type":"text"},"financeAuditUserId":{"type":"text"},"referOrderCode":{"type":"text"},"departmentId":{"type":"text"},"accpetanceLevel":{"type":"text"},"startBidtime":{"type":"date"},"deliverPlace":{"type":"text"},"readCount":{"type":"integer"},"isDxCollege":{"type":"text"},"payedConfirm":{"type":"text"},"isAdvanceEndbid":{"type":"text"},"isPublishBidresult":{"type":"text"},"deliverType":{"type":"text"},"bidAmountRenminbi":{"type":"double"},"orderTime":{"type":"date"},"agentRealName":{"type":"text"},"payType":{"type":"text"},"officePhone":{"type":"text"},"exchangeRate":{"type":"double"},"bidFinished":{"type":"text"},"currentProceeTime":{"type":"date"},"supplierReqs":{"type":"text"},"invoiceType":{"type":"text"},"budget":{"type":"double"},"deviceType":{"type":"text"},"isReaudit":{"type":"text"},"compusId":{"type":"text"},"createUserid":{"type":"text"},"isResearch":{"type":"text"},"bidAmount":{"type":"double"},"payedStatus":{"type":"text"},"packLevel":{"type":"text"},"contractLimit":{"type":"text"},"foundsSubject":{"type":"text"},"contractReqs":{"type":"text"},"waitingEvaluate":{"type":"text"},"collegeName":{"type":"text"},"isExtend":{"type":"text"},"currentProcee":{"type":"text"},"sourceType":{"type":"text"},"bidCount":{"type":"integer"},"projectName":{"type":"text"},"dataSource":{"type":"text"},"purchaseDesc":{"type":"text"},"lastUpdateTime":{"type":"date"},"orderMainId":{"type":"text"},"minDetailBidCount":{"type":"integer"},"agentUserName":{"type":"text"},"isDeliver":{"type":"text"},"lastUpdateUserid":{"type":"text"},"installations":{"type":"text"},"winningPrinciple":{"type":"text"},"orderStatus":{"type":"text"},"remark":{"type":"text"},"budgetIsOpen":{"type":"text"},"referOrderType":{"type":"text"},"personPhone":{"type":"text"},"itemNum":{"type":"integer"},"isAutoSubmit":{"type":"text"},"createUsername":{"type":"text"},"projectCode":{"type":"text"},"orderTotalAmount":{"type":"double"},"collegeId":{"type":"text"},"transportType":{"type":"text"},"currentProceeName":{"type":"text"},"orderUnit":{"type":"text"},"isExchequer":{"type":"text"},"orderTitle":{"type":"text"},"isTax":{"type":"text"},"lastUpdateUsername":{"type":"text"},"installationgSite":{"type":"text"},"adviceExpiredTime":{"type":"date"},"foundsCode":{"type":"text"},"deliverTime":{"type":"text"},"isDxCenter":{"type":"text"},"isInvoice":{"type":"text"},"otherId":{"type":"text"},"financeAuditUserName":{"type":"text"},"responseTime":{"type":"text"},"priceType":{"type":"text"},"publishBidresultTime":{"type":"date"},"publicityTime":{"type":"date"},"deviceType2":{"type":"text"},"confNum":{"type":"text"},"agentUserId":{"type":"text"},"createTime":{"type":"date"},"isImplemented":{"type":"text"},"endBidtime":{"type":"date"},"orderCode":{"type":"text"},"usingCorrency":{"type":"text"},"institueId":{"type":"text"},"orderPerson":{"type":"text"},"procurementType":{"type":"text"}}
  }
}


Last Updated: 1/9/2023, 6:34:40 PM