Django-DRF used Elasticsearch, using IK word

A. Installation depends

django-haystack==2.8.1
drf-haystack==1.8.6
Django==2.0.5
djangrestframework==3.8.2

II. Installation JAVA SDK

First official website to download the installation package:

Download link: https: //www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Elasticsearch because the version I installed is 2.4.1, the installation of JDK == 1.8, the version 2.x ES will use haystack incompatibility.

installation steps:

# First: 
cd / usr / local /
mkdir javajdk
# upload the downloaded file to:
/ usr / local / javajdk
# extract the files to this folder
tar-xzvf the JDK-8u231-Linux-i586.tar.gz 
mv jdk1. the Java 8.0_231
# configuration environment variable:
vim / etc / Profile

# in the file add the following lines:

export JAVA_HOME=/usr/local/javajdk/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

 Then #

 source /etc/profile

The following message appears represents a successful installation:

III. Installation Elasticsearch

Download: https: //www.elastic.co/cn/downloads/past-releases#elasticsearch

Note that Elasticsearch start is being given under the root user!

You must first create a new user:

the useradd - G elastic elastic 
# in / home new user directory 
mkdir elastic
# installation package downloaded directory elastic uploaded to
the tar-2.4.1.tar.gz -C -xzvf elasticsearch / home / elastic /
# authorization to this directory
chown Elastic -R & lt: Elastic Elastic
# switch user
SU - Elastic
# modify the configuration file:
Vim /home/elastic/elasticsearch-2.4.1/config/elasticsearch.yml
# content
path.data: /home/elastic/elasticsearch-2.4.1/data path.logs: /home/elastic/elasticsearch-2.4.1/logs network.host: 172.xxx.xxx.xxx http.cors.allow-origin: "*"
# 如果没有data与logs在相关目录下建立

# 启动ES,在elasticsearch的bin目录下:
./elasticsearch

If you see the contents of the above in a browser, it means that the installation was successful!

If an error Solution:

1.最大文件描述符太少了,至少要65536,修改/etc/security/limits.conf文件
命令:vim /etc/security/limits.conf
内容修改为:* hard nofile 65536

2.一个进程可以拥有的VMA(虚拟内存区域)的数量太少了,至少要262144,修改文件  
命令:vim /etc/sysctl.conf
增加内容为:vm.max_map_count=262144

3.最大线程太少了,至少要4096,修改/etc/security/limits.conf文件
命令:vim /etc/security/limits.conf
增加内容为:* hard nproc 65536


未完待续......
在Django中配置
安装IK分词插件

Guess you like

Origin www.cnblogs.com/zhaijihai/p/12167923.html