3-18 5,762 views
centos 7 安装 elasticsearch
1.打开网址 https://www.elastic.co/downloads/elasticsearch
2.复制 RPM 包的下载地址: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.rpm
3.如果没有java环境,先
yum install java
4.命令行输入
rpm ivh https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.rpm
5.安装成功
Retrieving https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.rpm
warning: /var/tmp/rpm-tmp.cIwOhR: Header V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
Preparing... ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Updating / installing...
1:elasticsearch-0:6.6.2-1 ################################# [100%]
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch
启动 关闭命令
重载
systemctl restart elasticsearch.service
开机启动
sudo systemctl enable elasticsearch.service
启动
systemctl start elasticsearch.service
配置文件
vim /etc/elasticsearch/elasticsearch.yml
安装php对应扩展 https://www.elastic.co/guide/cn/elasticsearch/php/current/_installation_2.html#_installation_2
安装 Kibana
- 选择RPM方式,输入命令
rpm -ivh https://artifacts.elastic.co/downloads/kibana/kibana-6.6.2-x86_64.rpm
2.启动
#启动 systemctl start kibana.service #开机启动 systemctl enable kibana.service #停止 systemctl stop kibana.service
3.配置文件
vim /etc/kibana/kibana.yml
HTTP访问 elasticsearch 和 kibana
通过nginx反向代理访问 elasticsearch 和 kibana
1 配置 kibana
vim /etc/kibana/kibana.yml
server.port: 5601
server.host: "localhost"
elasticsearch.hosts: ["http://127.0.0.1:9200"]
启动 systemctl restart kibana.service
2 配置elasticsearch
vim /etc/elasticsearch/elasticsearch.yml
network.host: 127.0.0.1
http.port: 9200
cluster.name: elasticsearch #集群名称
node.name: node-1 #节点名
path.data: /apps/elasticsearch/datas #数据文件存放位置,记得给自己创建的目录elasticsearch 组合用户
path.logs: /apps/elasticsearch/logs
network.host: 127.0.0.1
http.port: 9200
启动 systemctl restart elasticsearch.service
3 配置nginx
upstream kibanaserver {
server 127.0.0.1:5601;
}
server{
listen 80;
server_name abc.com;
location / {
proxy_pass http://kibanaserver;
index index.html index.htm;
}
}
server{
listen 80;
server_name abc.com;
location / {
proxy_pass http://localhost:9200/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
rewrite /(.*)$ /$1 break;
}
}
#注意php连接ES用 地址 :www.abc.com:80
kibana文档 https://www.elastic.co/guide/cn/kibana/current/index.html
生成kibana 访问用户和密码
-
yum install httpd-tools
2.mkdir -p /etc/nginx/passwd
3.htpasswd -c -b /etc/nginx/passwd/kibana.passwd admin admin888$
4.配置Nginxupstream kibanaserver { server 127.0.0.1:5601; } server{ listen 80; server_name abc.com; auth_basic "Kibana Auth"; auth_basic_user_file /etc/nginx/passwd/kibana.passwd; location / { proxy_pass http://kibanaserver; index index.html index.htm; } } upstream elasticsearchserver { server 127.0.0.1:9200; } server{ listen 80; server_name abc.com; location / { proxy_pass http://elasticsearchserver; index index.html index.htm; } }