CentOS安装openjdk

一、yum

1.1search

yum search java | grep jdk

CentOS安装openjdk和elasticsearch-LMLPHP

1.2安装openjdk

[root@test ~]# yum install java-1.8.0-openjdk -y
查看openjdk版本
[root@test ~]# java -version
CentOS安装openjdk和elasticsearch-LMLPHP

二、elasticsearch的启动和关闭

2.1启动

切换到elasticsearch安装目录的bin目录下,执行如下命令即可
切换es的用户

./elasticsearch -d

CentOS安装openjdk和elasticsearch-LMLPHP

2.2关闭

查询java进程

[elasticsearch@localhost bin]$ ps -ef|grep java

CentOS安装openjdk和elasticsearch-LMLPHP
kill -9 进程号 即可关闭

2.3添加服务

[elasticsearch@localhost system]$ pwd
/etc/systemd/system
vim es.service

[Unit]
Description=es.service
After=network.target
[Service]
LimitNOFILE=infinity
User=elasticsearch
Group=elasticsearch
Type=forking
ExecStart=/data/elasticsearch/bin/elasticsearch -d
PrivateTmp=True
[Install]
WantedBy=multi-user.target
重载系统服务
systemctl daemon-reload
加入开机自启
systemctl enable es.service
# 启动redis服务
systemctl start es.service 
# 停止redis服务
systemctl stop es.service
# 查看redis服务状态
systemctl status es.service

CentOS安装openjdk和elasticsearch-LMLPHP

09-22 01:01