简介:
安装 elasticsearch 版本是6.8.0 ,ubuntu环境
下载
到华为云镜像
https://repo.huaweicloud.com/elasticsearch/6.8.10/elasticsearch-6.8.10.tar.gz
首先安装java 环境
安装es
tar zxf elasticsearch-6.8.0.tar.gz -C /opt/services/es
修改配置文件
vim /opt/services/es/elasticsearch/config/elasticsearch.yml
cluster.name: ESCluster #修改集群的名字,以免在网络上混乱串门,加入别的集群里面。注释会随机生成集群名
node.name: node1 #自定义节点名字
path.data: /opt/services/es/elasticsearch/data #自定义节点名字
path.logs: /opt/services/es/elasticsearch/logs #自定义日志存储路径
bootstrap.memory_lock: true #锁定内存,防止用到 swap 分区
network.host: 0.0.0.0 #修改 ES 的监听地址,这样所有的机器都可以访问这部 ES
http.port: 9200
discovery.zen.minimum_master_nodes: 1
bootstrap.system_call_filter: false
#添加新的配置项,允许跨域访问,这样 head 插件方可对 ES 进行访问
http.cors.enabled: true #开启跨域访问支持,默认为false
http.cors.allow-origin: "*" #跨域访问允许的域名地址,使用正则表达式
vim /opt/services/es/elasticsearch/config/jvm.options
- 优化内存大小,防止内存溢出导致进程奔溃,具体修改以下内容:
-Xms4g #默认为 1g
-Xmx4g #默认为 1g
修改系统的参数
vim /etc/security/limits.conf
- 添加
* soft nofile 100000
* hard nofile 100000
* soft nproc 100000
* hard nproc 100000
* soft memlock unlimited
* hard memlock unlimited
# 解决启动报错:
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
sudo vim /etc/sysctl.conf
fs.file-max = 1645037
vm.max_map_count = 655360
#即时生效:
sudo sysctl -p
#也可以重启
启动
cd es
./bin/elasticsearch -d
添加systemd 守护进程
# 添加 elasticsearch.service 到 /lib/systemd/system/
[Unit]
Description=elasticsearch-6.8.0
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment=JAVA_HOME=/opt/services/jdk
##为systmed 进程加文件限制数量
LimitCORE=infinity
LimitNOFILE=65536
LimitNPROC=65536
ExecStart=/opt/services/es/bin/elasticsearch -d
User=op
Group=op
[Install]
WantedBy=multi-user.target
方法二:
全局的配置,放在文件 /etc/systemd/system.conf 和 /etc/systemd/user.conf。 同时,也会加载两个对应的目录中的所有.conf文件 /etc/systemd/system.conf.d/.conf 和 /etc/systemd/user.conf.d/.conf
其中,system.conf 是系统实例使用的,user.conf用户实例使用的。一般的sevice,使用system.conf中的配置即可。systemd.conf.d/*.conf中配置会覆盖system.conf。
DefaultLimitCORE=infinity
DefaultLimitNOFILE=100000
DefaultLimitNPROC=100000