技术标签: 1024程序员节
注意我们的环境要求,jdk至少需要在1.8.0_73以上版本。
需要安装JDK环境。
Centos7下安装与卸载和安装JDK
Ubuntu20.04安装JDK
Elasticsearch提供了多种安装方式供我们选择,往往我们开始学习使用Elasticsearch的时候,都会选择使用.zip、.tar等解压缩的安装方式进行安装使用,方便快捷。但在生产环境部署中,通常需要将Elasticsearch作为服务器的系统服务,可以随系统启动而启动,这就需要用RPM。
根据自己是使用的习惯,创建安装工具的位置。
#创建tool文件夹和elasticsearch
cd /usr/local/
mkdir tool
cd tool
mkdir elasticsearch
cd elasticsearch
在创建的elasticsearch文件夹内下载Elasticsearch
版本根据自己的需求,下载方式根据自己的习惯。
官方稳定最新版:https://www.elastic.co/cn/downloads/elasticsearch
选择其他版本:https://www.elastic.co/cn/downloads/past-releases#elasticsearch
版本功能
basic版本也是开源版本,只要去注册了,就可以把开源版本变成basic,区别就是多了功能。
wget方式:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.0.tar.gz
#解包
tar -xvf elasticsearch-7.4.0.tar.gz
#修改elasticsearch-7.4.0为elasticsearch,可以不操作,使用原始的文件名
mv elasticsearch-7.4.0 elasticsearch
vim config/elasticsearch.yml
//配置文件修改
network.host: 0.0.0.0 //主要是为了让外网访问
http.port: 9200 //设置es的端口
#创建elsearch用户组及elsearch用户
groupadd elsearch
useradd elsearch -g elsearch -p 123456
#更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch
chown -R elsearch:elsearch /usr/local/tool/elasticsearch/elasticsearch-7.4.0
#进入es/bin包
cd elasticsearch-7.4.0/bin
#启动es
./elasticsearch &
[[email protected] ~]# curl 'http://localhost:9200/?pretty'
{
"name" : "node-1",
"cluster_name" : "vm-cluster",
"cluster_uuid" : "QCwy-1vTqQA",
"version" : {
"number" : "7.4.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "22e83e61a66e3f11ab9910",
"build_date" : "2019-09-27T08:36:48.569419Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
问题一:
如果使用root账户启动会报错:
这是因为我们当前的用户权限不够,但是es又不允许使用root启动,所以我们需要创建一个用户组。创建es用户.
问题二:
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
用于弹性搜索过程的最大文件描述符[65535]太低,至少增加到[65536]
使用root用户打开如下文件:
vi /etc/security/limits.conf
编辑 /etc/security/limits.conf,追加以下内容;
#*代表所有用户,或者直接更换为已经创建的用户elsearch
* soft nofile 65536
* hard nofile 65536
此文件修改后需要重新登录用户,才会生效
2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
这是因为最大虚拟内存区域vm.max_map_count [65530]太低,至少增加到[262144]
vim /etc/sysctl.conf
编辑 /etc/sysctl.conf,追加以下内容:
vm.max_map_count=655360
保存后,执行:
sysctl -p
复制代码然后使用es用户启动Elasticsearch,这次可以成功启动了,如果需要后台启动的话,在启动命令后加&,如下所示:
./elasticsearch &
问题三:
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
默认发现设置不适合生产使用;必须配置[discovery.seed_hosts,discovery.seed_providers,cluster.initial_master_nodes]中的至少一个。
d
编辑配置文件
vi /usr/share/elasticsearch/config/elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
# custom config
node.name: "node-1"
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
cluster.initial_master_nodes: ["node-1"]
# 开启跨域访问支持,默认为false
http.cors.enabled: true
# 跨域访问允许的域名地址,(允许所有域名)以上使用正则
http.cors.allow-origin: /.*/
重点是 node.name 和 cluster.initial_master_nodes,其他的配置根据自己的需求。
常用命令:
#es后台启动
./elasticsearch -d
#查看集群健康
http://101.10.12.30:9201/_cat/health?v
获取节点列表
http://101.10.12.30:9201/_cat/nodes?v
查看集群属性
http://101.10.12.30:9201/_cat/indices?v
查看所有节点
http://101.10.12.30:9201/_nodes
在/etc/yum.repos.d/目录下,新建一个名为elasticsearch.repo的文件;若找不到该目录,则在/etc/zypp/repos.d/目录下新建。(这是系统基于RedHat的发行版和基于OpenSuSE的发行版的区别)
文件elasticsearch.repo的内容如下:
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
现在可以使用以下命令之一安装Elasticsearch:
yum install elasticsearch
dnf install elasticsearch
zypper install elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.0-x86_64.rpm
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
rpm --install elasticsearch-7.4.0.rpm
Elasticsearch安装后不会自动启动。如何启动和停止Elasticsearch取决于您的系统是使用SysV init还是 systemd(由较新的发行版使用)。你可以通过运行这个命令来判断哪个被使用:
ps -p 1
使用 SysV 启动 Elasticsearch
将Elasticsearch配置为在系统启动时自动启动,请运行以下命令:
sudo chkconfig --add elasticsearch
启动或停止
sudo -i service elasticsearch start
sudo -i service elasticsearch stop
使用 systemd 启动 Elasticsearch
将Elasticsearch配置为在系统启动时自动启动,请运行以下命令:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
启动或停止
sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service
四、检查Elasticsearch是否正在运行
curl -XGET 'localhost:9200/?pretty'
会得到以下的反馈,说明已经启动成功
{
“name” : “Cp8oag6”,
“cluster_name” : “elasticsearch”,
“cluster_uuid” : “AT69_T_DTp-1qgIJlatQqA”,
“version” : {
“number” : “6.1.2”,
“build_hash” : “f27399d”,
“build_date” : “2016-03-30T09:51:41.449Z”,
“build_snapshot” : false,
“lucene_version” : “7.1.0”,
“minimum_wire_compatibility_version” : >“1.2.3”,
“minimum_index_compatibility_version” : >“1.2.3”
},
“tagline” : “You Know, for Search”
}
如果Elasticsearch无法启动,则日志文件/var/log/elasticsearchelasticsearch.log/中会打印失败的原因。
我在安装过程中出现的一个错误是找不到JAVA_HOME的系统路径,RPM有一个系统配置文件(/etc/sysconfig/elasticsearch),它允许设置参数JAVA_HOME,通过设置正确的JAVA_HOME路径,重新启动Elasticsearch,问题就可以解决了。
<br />在OAF中,存在标准的查询面板,但是标准的查询只能实现基础、简单的查询,所以在真正的项目当中,一般情况下都是使用自己开发的客户化查询,开发客户化查询的一般步骤如下:<br /> <br />1. 建立页面PG,修改Region<br /><br />ID<br />PageLayoutRN<br />Region Style<br />PageLayout<br />AM Definition<br />RootAM<br />Window Title<br />xxx <br />Title<
一、测试与正确性论证差异对比测试,顾名思义,就是用一些有意义或无意义的输入去检测程序的正确性或鲁棒性,因其直观明了所以在写简单的程序时我们能迅速找出bug并加以解决。并且,这种方式是绝对客观的,只要和正确结果不匹配那么程序就一定存在一些问题。测试最大的缺点便是无法完全覆盖所有情况,即使很大的测试数据也可能跑不出来某些细微的bug,但这种bug有可能是致命的。正确性论证则是从代码逻辑角度去分...
安装npm install [email protected] -D配置//使用node.js中的导出语法 向外到处一个webpack的配置对象const path = require('path')//导入 html-webpack-plugin 插件 得到插件的构造函数const HtmlPlugin = require('html-webpack-plugin')const htmlPlugin = new HtmlPlugin({ template:'./
为什么我们要阅读源码?大家都知道,我们做这行的基本每天都要和代码打交道,但其实大部分程序员都会‘写’代码,或者至少会抄代码和改代码。但是,会读代码的并不在多数,会读会写代码又真正读懂一些大项目的源码的,少之又少。如何提升自己的读/写代码能力?其实写代码就像写作,我们的写作能力,是建立在大量基础阅读的基础上的,而我们现在写代码一般是直接CV人家的,跳过了大量阅读名家作品的过程,前辈们踩过的坑,总结的经验教训,我们很少有人去吸收,也就不能自己的技术水平得到全面提升。这样无疑对我们自己的发展是很受限的
在linux家族中,vim编辑器是系统自带的文本编辑器。转载:https://www.cnblogs.com/crazylqy/p/5649860.html进入编辑:1、 VIM编辑器,可以新建文件也可以修改文件,命令为:vim /usr/local/con.cfgvim testing1.txt 或者 vi testing1.txt如果这个文件,以前是没有的,则为新建,则下方有提示为新文件,如...
想必大家在学 Python 的过程中, 在 用 pyinstaller 打包后, 再运行 exe 都有报错:failed to execute script ****.exe 的现象本文为本人趟过的坑, 希望能给你带来帮助......^_^趟坑过程:打包命令:( 在Windows的CMD命令窗口输入以下命令 )pyinstaller -i .\images\camera...
在Fedora 7 下建立 ARM-Linux 交叉编译环境 这几天忙着在Fedora 7下建立ARM-Linux的交叉编译环境。一开始参考了《构建嵌入式Linux系统》,这是一本很经典的书。上面介绍了建立ARM-Linux的交叉编译环境的许多知识,建立的原则和方法。我一开始想按照上面的一般方法,建立一个自己的、最新的交叉编译环境。但是 ,试了才知道这个过程是一个繁琐、耗时的工作。
在使用vncviewer连接vmware中的red hat linux server时,提示如下错误:“连接失败,套接字操作尝试一个无法连接的主机。(10065)”问题在于配置redhat的vncserver时,没有将默...
python3 for和if一行写法d = [x for x in range(10) if x > 3]print(d)
1. Vue-用户登录、export function login(data) { return request({ url: '/user/login', method: 'post', data })}2. Vue-用户注册export function register(data) { return request({ url: '/user/regist', method: 'post', data })}3.
#include "stdafx.h"#include#includeusing namespace std;struct binaryTreeNode{ binaryTreeNode *leftNode; binaryTreeNode *rightNode; int value;};void findPath(binaryTreeNode *t
(一) 2011-12-08 [原文链接] 今天有同事恭喜我,我才知道自己在淘宝已经七周年了。很多人第一句话就是七年痒不痒,老实说,也曾经痒过,但往往都是一痒而过,又投入到水深火热的工作中去。回家之后就想这七年我到底收获了什么,且不论成败与否,这7年的经历,是我人生的宝贵财富。 第一年: '正牌七公'曾经说过,要是写一本淘宝的历史书,一定很多人感兴趣,其实我也很想写...