elasticsearch-6.6.0 설치와 설정 방법을 설명합니다.
시스템 요구 사항
| 운영 체제 | IP 주소 | 소프트웨어 버전 |
|---|---|---|
| CentOS Linux release 7.2.1511 (Core) | 192.168.192.100 | elasticsearch-6.6.0 |
| CentOS Linux release 7.2.1511 (Core) | 192.168.192.101 | elasticsearch-6.6.0 |
| CentOS Linux release 7.2.1511 (Core) | 192.168.192.102 | elasticsearch-6.6.0 |
| CentOS Linux release 7.2.1511 (Core) | 192.168.192.112 | logstash-6.6.0.rpm |
시스템 파라미터 조정
[root@esnode ~]# sysctl -p
vm.max_map_count = 262144
vm.swappiness = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_max_tw_buckets = 2000
파일 핸들 제한 조정
[root@esnode ~]# cat /etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
elastic soft nofile 65535
elastic hard nofile 65535
elastic - memlock unlimited
elastic - nproc 4096
다음 명령으로 Elasticsearch 다운로드 및 사용자 생성:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz
useradd elastic_user
Elasticsearch의 기본 메모리 설정은 1GB입니다. 메모리가 부족하면 JVM 옵션을 수정해야 합니다:
[root@esnode config]# egrep -v '^#|^$' jvm.options
-Xms5g
-Xmx5g
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-Djava.awt.headless=true
-Dfile.encoding=UTF-8
-Djna.nosys=true
-XX:-OmitStackTraceInFastThrow
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/var/lib/es_data
-XX:ErrorFile=/var/log/es_logs/hs_err_pid%p.log
Elasticsearch 설정 파일 예시:
[root@esnode config]# cat elasticsearch.yml
cluster.name: es_cluster_1
node.name: node_100
path.data: /data/es_data
path.logs: /logs/es_logs
network.host: 192.168.192.100
http.port: 9200
transport.tcp.port: 9300
node.master: true
node.data: true
discovery.seed_hosts: ["192.168.192.100", "192.168.192.101", "192.168.192.102"]
gateway.recover_after_nodes: 2
gateway.expected_nodes: 3
http.cors.enabled: true
http.cors.allow-origin: "*"
서비스 시작
su elastic_user
cd /opt/es/bin/
./elasticsearch -d
Elasticsearch-head 플러그인 설치
Node.js 설치:
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
yum install gcc-c++ make -y && yum install nodejs git -y
head 플러그인 설치:
git clone https://github.com/mobz/elasticsearch-head.git
cd ~/elasticsearch-head
npm install .
Gruntfile.js 수정:
module.exports = function(grunt) {
grunt.initConfig({
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['connect:server']);
};
app.js에서 기본 URL 변경:
this.base_uri = this.config.base_uri || this.prefs.get("base_uri") || "http://192.168.192.100:9200";
Head 서버 실행:
npm run start &