- UID
- 6
- 注册
- 2017/09/10
- 消息
- 17
- 黄金
- 11,213G
事前准备 卸载自带java
1.检查一下系统中的jdk版本
java version "1.7.0_"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
2.检测JDK安装包
下面版本号各异
avapackages-tools-3.4.1-6.el7_0.noarch
tzdata-java-2014i-1.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
python-javapackages-3.4.1-6.el7_0.noarch
3.卸载OpenJDK
下面版本号各异
nodeps 后边的版本根据上边输出的信息复制粘贴过来
还有一些其他的命令:
如果出现找不到openjdk source的话,那么还可以这样卸载
一、安装配置jdk1.8
1、去官网下载JDK:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
注意:要先进入以上网址,同意条款后,点击jdk-8u151-linux-x64.rpm下载,取得真实下载地址,再用wget下载到服务器
重命名为jdk-8u151-linux-x64.rpm
2.安装JDK
3.检查jdk
java -version
二、在CentOS 7上安装Elasticsearch 2.4.6
1、我这里用的是2.4.6版如需其它版本请查看官网根据自己服务器内存和网站需求
下载
2、安装rpm包
随着系统运行Elasticsearch,运行下面的命令:
3、启动Elasticsearch
4、测试Elasticsearch
5、停止
6、配置ES文件
创建/var/bbb备用
elasticsearch.yml配置如下
7、启动Elasticsearch
8、安装分词插件
分词插件介绍:https://github.com/medcl/elasticsearch-analysis-ik
安装方法:进入cd /usr/share/elasticsearch/bin
---------------------------------------------
重启Elasticsearch
9、CentOS 7上卸载 elsticsearch
10.在es所在服务器进行防火墙设置(以及阿里云安全组端口设置),限制只能由web服务器ip才能访问es端口。
1.检查一下系统中的jdk版本
代码:
java -version
java version "1.7.0_"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
2.检测JDK安装包
代码:
rpm -qa | grep java
下面版本号各异
avapackages-tools-3.4.1-6.el7_0.noarch
tzdata-java-2014i-1.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
python-javapackages-3.4.1-6.el7_0.noarch
3.卸载OpenJDK
下面版本号各异
代码:
rpm -e --nodeps tzdata-java-2014i-1.el7.noarch
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
nodeps 后边的版本根据上边输出的信息复制粘贴过来
还有一些其他的命令:
代码:
rpm -qa | grep gcj
rpm -qa | grep jdk
如果出现找不到openjdk source的话,那么还可以这样卸载
代码:
yum -y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
yum -y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
一、安装配置jdk1.8
1、去官网下载JDK:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
注意:要先进入以上网址,同意条款后,点击jdk-8u151-linux-x64.rpm下载,取得真实下载地址,再用wget下载到服务器
代码:
cd /
mkdir aaa
cd aaa
wget http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm?AuthParam=1511629557_d36ca0347a53775abacda19ad792f191
重命名为jdk-8u151-linux-x64.rpm
2.安装JDK
代码:
rpm -ivh jdk-8u151-linux-x64.rpm
3.检查jdk
java -version
代码:
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
二、在CentOS 7上安装Elasticsearch 2.4.6
1、我这里用的是2.4.6版如需其它版本请查看官网根据自己服务器内存和网站需求
下载
代码:
cd /aaa
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.4.6/elasticsearch-2.4.6.rpm
2、安装rpm包
代码:
rpm -ivh elasticsearch-2.4.6.rpm
随着系统运行Elasticsearch,运行下面的命令:
代码:
sudo systemctl daemon-reload
代码:
sudo systemctl enable elasticsearch.service
3、启动Elasticsearch
代码:
sudo systemctl start elasticsearch.service
4、测试Elasticsearch
代码:
curl -XGET 'http://localhost:9200'
5、停止
代码:
sudo systemctl stop elasticsearch.service
6、配置ES文件
创建/var/bbb备用
代码:
cd /var
mkdir bbb
chmod -R 777 bbb
代码:
/etc/elasticsearch/elasticsearch.yml
elasticsearch.yml配置如下
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: ccc
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# node.name: node-1
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/elasticsearch
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
#
# Make sure that the
# available on the system and that the owner of the process is allowed to use this limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
# discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: ccc
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# node.name: node-1
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/elasticsearch
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
#
# Make sure that the
ES_HEAP_SIZE
environment variable is set to about half the memory# available on the system and that the owner of the process is allowed to use this limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
# discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true
7、启动Elasticsearch
代码:
sudo systemctl start elasticsearch.service
8、安装分词插件
分词插件介绍:https://github.com/medcl/elasticsearch-analysis-ik
安装方法:进入cd /usr/share/elasticsearch/bin
代码:
./plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v1.10.6/elasticsearch-analysis-ik-1.10.6.zip
---------------------------------------------
重启Elasticsearch
代码:
sudo systemctl stop elasticsearch.service
代码:
sudo systemctl start elasticsearch.service
9、CentOS 7上卸载 elsticsearch
代码:
yum remove elasticsearch
10.在es所在服务器进行防火墙设置(以及阿里云安全组端口设置),限制只能由web服务器ip才能访问es端口。