我们在日常系统开发中,在做模糊搜索,数据量小的情况下会用到
(DB)去处理数据,然而当数据量到一个量级的时候通常这种前后端响应不是那么快,此时我们就要考虑优化,通常会将数据存放在Elasticsearch内进行快速查询
Elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-linux-x86_64.tar.gz
版本对应

如图所示为各个服务对应的版本信息!!
linux用户# 新建用户
[root@taozialiyun es]# useradd estz
#创建密码
[root@taozialiyun es]# passwd estz
[root@taozialiyun es]# tar -zxvf elasticsearch-7.3.1-linux-x86_64.tar.gz
config
[root@taozialiyun config]# cd /home/es/elasticsearch-7.3.1/config
[root@taozialiyun config]# ll
total 36
# es配置
-rw-rw---- 1 root root 2831 Aug 20 2019 elasticsearch.yml
# jvm配置
-rw-rw---- 1 root root 3524 Aug 20 2019 jvm.options
# 日志配置
-rw-rw---- 1 root root 17222 Aug 20 2019 log4j2.properties
-rw-rw---- 1 root root 473 Aug 20 2019 role_mapping.yml
-rw-rw---- 1 root root 197 Aug 20 2019 roles.yml
-rw-rw---- 1 root root 0 Aug 20 2019 users
-rw-rw---- 1 root root 0 Aug 20 2019 users_roles
[root@taozialiyun config]#
vim jvm.options
-Xms512M
-Xmx512M
注意:这个根据自己服务器大小做修改,因为我的服务器内存只有2G所有,修改jvm为512M
elasticsearch.yml配置vim elasticsearch.yml
#当前的集群名(改成一个有意义的名字)
cluster.name: es-aliyun-tz
#配置当前es节点名称(改成一个有意义的名字)
node.name: es-tz-1
# 数据目录位置
path.data: /home/es/data
# 日志目录位置
path.logs: /home/es/logs
#绑定的ip:默认只允许本机访问,修改为0.0.0.0后则可以远程访问
network.host: 0.0.0.0
#设置master节点列表 用逗号分隔
cluster.initial_master_nodes: ["node-1"]
# http端口
http.port: 9200
cd /etc/securityvim /limits.conf
# End of file
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
#加入最后一句
vm.max_map_count=655360
#max_map_count文件包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量
sysctl -p 生效
[root@taozialiyun security]# cd /home
[root@taozialiyun home]# ll
total 0
drwxr-xr-x 3 root root 24 May 28 2021 adore
drwxr-xr-x 5 root root 104 Mar 7 10:04 es
drwx------ 2 estz estz 62 Mar 7 09:49 estz
[root@taozialiyun home]# chgrp -R estz ./es
[root@taozialiyun home]# chown -R estz ./es
[root@taozialiyun home]# chmod 777 es
[root@taozialiyun home]# ll
total 0
drwxr-xr-x 3 root root 24 May 28 2021 adore
drwxrwxrwx 5 estz estz 104 Mar 7 10:04 es
drwx------ 2 estz estz 62 Mar 7 09:49 estz
[root@taozialiyun home]#
如图可见,我们es目录的所属用户已经变为estz
切换用户 su estz
启动: ./bin/elasticsearch
启动不报错后,浏览器访问地址:服务器IP+9200
{
"name": "es-tz-1",
"cluster_name": "es-aliyun-tz",
"cluster_uuid": "9l6wUsXQRTSsGv_ocbrwuA",
"version": {
"number": "7.3.1",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "4749ba6",
"build_date": "2019-08-19T20:19:25.651794Z",
"build_snapshot": false,
"lucene_version": "8.1.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
[estz@taozialiyun elasticsearch-7.3.1]$ ./bin/elasticsearch
future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_281/jre] does not meet this requirement
Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
这个问题主要是,es本身自带了jdk如果服务器安装了jdk,会默认读取服务器jdk版本导致版本不一致
解决方案:
vim ./bin/elasticsearch
export JAVA_HOME=/home/es/elasticsearch-7.3.1/jdk
export PATH=$JAVA_HOME/bin:$PATH
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="/home/es/elasticsearch-7.3.1/jdk/bin/java"
else
JAVA=`which java`
fi
加入上面shell 指定读取elasticsearch下的jdk版本
(2)内存不足的问题
[2023-03-07T10:52:10,953][INFO ][o.e.b.BootstrapChecks ] [es-tz-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改jvm.options
-Xms256M
-Xmx256M
(3)解决vm.max_map_count [65530] is too low问题
[root@taozialiyun etc]# vim sysctl.conf
[root@taozialiyun etc]# systcl -p
-bash: systcl: command not found
[root@taozialiyun etc]# sysctl -p
vm.swappiness = 0
kernel.sysrq = 1
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_slow_start_after_idle = 0
vm.max_map_count = 262144添加这个配置
(4)再次启动

成功
综上则是我们安装elasticsearch单节点完整过程!
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我打算为ruby脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=