安装nc
yum install nmap-ncat.x86_64
cat 123 |nc 192.168.1.10 8888
将标准输入转发到192.168.1.10的8888端口,并将返回输出到标准输出
可以直接发送HTTP请求
$nc 192.168.1.10 80 <<EOF
GET / HTTP/1.0
EOF
即可显示首页内容
收发文件
发送方,读file文件,监听8888端口,等待连接后发送文件
cat file|nc -l -p 8888
接收方,连接11主机8888端口,将收到内容保存到file
nc 192.168.1.11 8888 >file
-------------------------------------------------
ssh免登入配置
ssh-keygen -t rsa
ssh-keygen -t rsa
ssh-keygen -t rsa
ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h201
ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h202
ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h203
-------------------------------------------------------------------
max file descriptors [65535] for elasticsearch process is too low
方案一:
elasticsearch安装后启动时候,遇到此问题
问题翻译过来就是:elasticsearch用户拥有的可创建文件描述的权限太低,至少需要65536;
解决办法:
#切换到root用户修改
vim /etc/security/limits.conf
在最后面追加下面内容
*hard nofile 65536
*soft nofile 65536
是启动ES的用户
方案二:
ulimit -n 65535
使用 ulimit -Hn 查看当前值,果然是65535,
ulimit -Hn
65535
也就是说每次更新环境变量的时候limits.conf的hard nofile 131072设置被覆盖掉了
这就好办了,vi /etc/profile 将 ulimit -n 65535 行注释掉,退出重新进入当前用户,再使用 ulimit -Hn 查看当前值,已经是131072了,设置成功!
执行
ulimit -Hn 65536
验证
ulimit -Hn
65536
再去启动elasticsearch,OK!
方案三:确保非root账号打开文件数量也增大
1.打开/etc/security/limits.conf,在里面添加如下内容
- soft nofile 65536
- hard nofile 65536
其中*表示所有用户 nofile表示最大文件句柄数,表示能够打开的最大文件数目
2.编辑/etc/pam.d/common-session,添加如下内容
vi /etc/pam.d/common-session
session required pam_limits.so
3.编辑/etc/profile,添加如下内容
ulimit -SHn 65536
然后重新启动机器,再利用ulimit -n查看文件句柄数,发现文件句柄数变为65536
--------------------------------------------------
下载ES
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz、
./bin/elasticsearch -d
------------------------------------------------
yum install npm
npm intall -g grunt
npm install -g grunt-cli
在head中执行
cnpm install
nohup grunt server > /dev/null 2>&1 &
head插件的使用
连接ES集群
http://192.168.43.37:9100/
----------------------------
bigdesk插件的使用
python3 -m SimpleTHHPServer
python -m http.server
开启 8000端口
----------------------------------
集群安装ES
bigdesk插件的使用8000端口
head插件的使用9100端口
ES的核心概念cluster
代表一个集群,其中有一个主节点,它是通过选举产生的。
对于集群外部来说,ES是 去中心化的,你访问集群中的任何一个节点,与访问集群是等价的。
默认情况下,ES会自动的发现同一网段的ES节点,来形成ES集群 。
集群的健康情况:
green:集群状态好,主副分区都可以使用
yellow:主可以使用, 副分区不可以使用(单节点)
red: 主副分区都不一定可以使用
ES核心概念shards(分片)
代表索引的分片( ES中 索引与mysql中的表概念类似,就是表太大了,进行了分片的处理。)
分片得好处就是把一个大的索引拆分多个索引,分布到不同的节点 上,构成分布式的搜索,
默认的一个 索引库有5个分片
分片的数量在创建完索引后是不能改了。
在创建索引的时候指定相应的分片的数量。
curl -XPUT 'locahost:9200/test1/' -d '{"setings":{"number_of_shard":3}}'
ES的核心概念replicas(索引副本)
1:索引副本是用来提高系统的容错性的。当某个节点的分片数据损坏的时候,可以进行恢复。
2:提高查询效率,ES会自动对搜索引擎进行负载
均衡。
默认情况下是一个副本
curl -XPUT 'localhost:9200/test2/' -d '{ "setings":{"number_of_replicas":2}}'
ES的核心概念recovery & gateway(数据恢复或数据重新分布)
ES在有节点加入(节点退出) 的 情况下会根据节点的负载情况,重新分配索引分片。在挂掉的节点重新启动时对它进行数据的 恢复。
索引的持久化存储,一开是存储在内存中 ,内存不够的时候,到磁盘。
数据恢复支持从本地文件 ,分布式文件系统,云 存储服务中恢复数据。
ES中discovery.zen
自动发现节点机制-
ES是一个p2p的系统
先通过广播寻找存在的节点。在通过多番的 协议进行通信。支持点对点的操作
可以配置不在同一网段的ES集群,但是要注释 掉自动发现节点机制.而且要 手动的配置集群的ip,即可!
ES Transport
通讯口
----------------------------------------------------------
head下载
git clone git://github.com/mobz/elasticsearch-head.git
查看grunt
head是使用grunt来开启的
grunt --version
bigdesk的下载地址
git clone https://github.com/hlstudio/bigdesk
在es中配置可以使用插件来访问这个es集群、
http.cors.enabled: true
http.cors.allow-origin: “*”
head的启动命令:
nohup grunt server > /dev/null 2>&1 &
bigdesk的启动命令
python3 -m http.server
-------------------------------
在java中配置maven 的相关的jar包
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DemoES</groupId>
<artifactId>DemoES</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-high-level-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
maven 中提速的配置
修改这个setings.xml的配置
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>