| [root@singlenode ~]# | rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch #导入源的GPG |
|---|---|
| [root@singlenode ~]# | vi /etc/yum.repos.d/elasticsearch.repo |
| [elasticsearch]name=Elasticsearch repository for 7.x packagesbaseurl=https://artifacts.elastic.co/packages/7.x/yumgpgcheck=1gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearchenabled=1autorefresh=1type=rpm-md | |
| [root@singlenode ~]# | yum -y install elasticsearch #安装ES服务 |
| [root@singlenode ~]# | systemctl enable elasticsearch.service |
| [root@singlenode ~]# | curl -X GET “localhost:9200/” #等待几秒后运行可以获取反馈 |
| [root@singlenode ~]# | vi /etc/elasticsearch/elasticsearch.yml |
| network.host: 0.0.0.0 #允许外部ip访问,有可能无法使用http.port: 9200discovery.seed_hosts: [“singlenode”] | |
| [root@singlenode ~]# | systemctl restart elasticsearch.service |
| http://singlenode:9200/ | |
| [root@singlenode ~]# | wget https://artifacts.elastic.co/downloads/elasticsearch-hadoop/elasticsearch-hadoop-7.12.1.zip |
| [root@singlenode ~]# | yum -y install zip unzip |
| [root@singlenode ~]# | unzip elasticsearch-hadoop-7.12.1.zip -d /opt/ |
| maven | |
| commons-httpclient commons-httpclient 3.1 | |
| hive> | add jar /opt/elasticsearch-hadoop-7.12.1/dist/elasticsearch-hadoop-hive-7.12.1.jar; |
| hive> | add jar /opt/maven_repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar; |
如果不能创建主题重新安装就好
2.rm -rf /etc/elasticsearch
3.yum install elasticsearch
4.systemctl enable elasticsearch.service
5.reboot --重启
hive继承ElasticSearch
1.案列
curl -XPUT http://localhost:9200/es_student/?pretty --创建索引
2.hive 中创建表
CREATE EXTERNAL TABLE es_student(
s_id string,
s_name string,
s_birth string,
s_sex string
)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES('es.nodes' = 'localhost:9200', --注意这里使用localhost
'es.index.auto.create' = 'true',
'es.resource' = 'es_student/person_info',
'es.read.metadata' = 'true',
'es.mapping.names' = 's_id:s_id,s_name:s_name,s_birth:s_birth,s_sex:s_sex'); --和表的字段映射
INSERT INTO es_student
SELECT
*
FROM school.student
;
curl -XGET 'http://localhost:9200/es_student/_search?pretty' #查询所有数据
SELECT * FROM es_student;
本文详细介绍了如何在Linux系统上安装Elasticsearch,配置其对外访问,并通过Hadoop集成。步骤包括导入源GPG密钥、配置Yum源、安装ES、启用服务、设置网络参数,以及将Elasticsearch与Hive集成,演示了创建索引、数据迁移和查询操作。
1371

被折叠的 条评论
为什么被折叠?



