准备工作
1、创建一个用于启动Elasticsearch的用户(elasticSearch不能使用root启动)
# 新增用户
useradd elastic
2、安装jdk
# 下载
wget https://download.oracle.com/otn/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/jdk-8u202-linux-x64.tar.gz?AuthParam=1591339121_67708d355c97bec3d5b8fb0e8ec7ff33
# 解压
tar xf jdk-8u202-linux-x64.tar.gz -C /usr/local/ && mv /usr/local/jdk-8u202-linux-x64 /usr/local/jdk
# 写入环境变量
cat<<'EOF' >> /etc/profile
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=$CLASS_PATH::$JAVA_HOME/lib:$JAVA_HOME/jre/lib
EOF
# 使环境变量生效
source /etc/profile
# 验证
java -version
ElasticSearch 安装
1、安装elasticsearch和配置
# 创建ELK 的安装目录
mkdir /usr/local/elk
# 下载 ElasticSearch 7.7.1
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.7.1-linux-x86_64.tar.gz
# 解压
tar xf elasticsearch-7.7.1-linux-x86_64.tar.gz -C /usr/local/elk/
mv /usr/local/elk/elasticsearch-7.7.1-linux-x86_64 mv /usr/local/elk/elasticsearch-7.7.1
# 修改elasticsearch配置文件
[root@manager-1 config]# cat elasticsearch.yml | grep -v "^#"
node.name: node-1
path.data: /data/es-data
path.logs: /data/logs/es
bootstrap.memory_lock: true
network.host: 172.16.2.155 # 本机的IP
http.port: 9200
discovery.seed_hosts: ["172.16.2.155"]
cluster.initial_master_nodes: ["172.16.2.155"]
2、 为ES准备系统配置
# 创建elastic存储数据的目录
mkdir -p /data/es-data
mkdir -p /data/logs/es
# ES要要求vm.max_map_count的值至少为262144
echo vm.max_map_count= 262144 >> /etc/sysctl.conf
sysctl -p
# 配置文件打开数
cat <<'EOF' >> /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
* soft memlock unlimited
* hard memlock unlimited
EOF
3、 后台启动
/usr/local/elk/elasticsearch-7.7.1/bin/elasticsearch -d
日志路径在/data/logs/es/elasticsearch.log
4、 访问9200端口测试是否正常
[root@manager-1 config]# curl 172.16.2.155:9200
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "0EvqtzYsSYaSCkhnWYzVGg",
"version" : {
"number" : "7.7.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "ad56dce891c901a492bb1ee393f12dfff473a423",
"build_date" : "2020-05-28T16:30:01.040088Z",
"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"
}