修改虚拟机设置,防止 IP经常变动影响开发效率:https://www.cnblogs.com/wangyusu/p/11405086.html
创建Linux虚拟机,这里我使用 Ubuntu Server 18.04 版本
配置Java环境
传输下载好的Linux环境下的压缩包
创建/usr/local/java
目录,将压缩包拷贝到java目录下
解压压缩包:tar -zxvf jdk-8u231-linux-x64.tar.gz
配置系统环境变量:vim /etc/environment
#set java environment
export JAVA_HOME=/usr/local/java/jdk1.8.0_231
export JRE_HOME=/usr/local/java/jdk1.8.0_231/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
配置用户变量:
#set java environment
export JAVA_HOME=/usr/local/java/jdk1.8.0_231
export JRE_HOME=/usr/local/java/jdk1.8.0_231/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
使用户环境变量生效:source /etc/profile
检查是否安装成功:java -version
maven环境配置
docker环境配置
前言:
ES的安装使用需要Java环境
因为安全问题elasticsearch 不让用root用户直接运行,所以要创建新用户。
下载传输Linux下的压缩包,版本:5.5.3
虚拟机中创建/usr/local/elasticsearch
目录
将压缩包拷贝到目录,并解压:tar -zxvf elasticsearch-5.5.3.tar.gz
修改elasticsearch.yml
配置,vim elasticsearch.yml
添加如下配置
# 允许插件
http.cors.enabled: true
# 允许远程访问
http.cors.allow-origin: "*"
# 必须为本机的IP地址
network.host: 0.0.0.0
修改jvm.options
配置,vim jvm.options
# 最小堆大小
-Xms128m #根据自己机器情况修改(刷数据的时候可能就会出现:java.lang.OutOfMemoryError: Java heap space)
# 最大堆大小
-Xmx128m
elasticsearch 出现“java.lang.OutOfMemoryError: Java heap space”
默认情况下,Elasticsearch JVM默认使用最小和最大大小为2 GB的堆。迁移到生产环境时,配置堆大小以确保Elasticsearch堆足够的大很重要的。Elasticsearch将通过Xms(最小堆大小)和Xmx(最大堆大小)设置分配jvm.options中指定的整个堆。
设置的值取决于服务器上可用的RAM(随机存取存储器,其实就是内存)量。建议的配置如下:
将最小堆大小(Xms)和最大堆大小(Xmx)设置为彼此相等。
Elasticsearch可用的堆越多,它可用于缓存的内存就越多。但请注意,过多的堆可能会陷入长时间的垃圾收集暂停。所以设置的堆不能太大, 尽量设置到内存的50%。
将Xmx设置为不超过物理RAM的50%,以确保有足够的物理内存给内核文件系统缓存。
内存heap size配置不要超过32G, 基本上大多数系统最多只配置到26G,超过32G不生效。
修改sysctl.conf
配置文件:vim /etc/sysctl.conf
,添加如下片段,之后设置生效sysctl -p
vm.max_map_count=655360
创建用户,赋权限,启动ES
# 1.创建用户:elasticsearch,输入用户密码,需要输入两次,然后一路回车
adduser es
# 2.将对应的文件夹权限赋给该用户
chown -R es:es elasticsearch-5.5.3
# 3.切换至es用户
su es
# 4.进入启动目录启动 /usr/local/elasticsearch/elasticsearch-5.5.3/bin,使用后台启动方式启动ES
./elasticsearch -d
# 5. 使用Chrome擦elasticsearch-head插件,查看链接
安装分词器
其他
停止服务
root@itcast:~# jps
68709 Jps
68072 Elasticsearch
kill 68072 #通过kill结束进程
官网下载Redis(下载稳定版本-Stable)压缩包
创建/usr/local/redis
目录,拷贝下载的压缩包到此目录
解压redis压缩包: tar -zxvf redis-6.0.5.tar.gz
进入解压后的目录,执行make
命令进行编译
注意如果提示没有安装make
工具,则需进行安装:
##先后执行下面命令
apt-get update
apt-get install gcc
编译成功后,执行make install
进行Redis安装
安装完成后启动redis,以下命令是以默认配置启动:redis-server
root@ubuntu:/usr/local/redis/redis-6.0.5# redis-server
11443:C 14 Jul 2020 06:55:49.760 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11443:C 14 Jul 2020 06:55:49.760 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=11443, just started
11443:C 14 Jul 2020 06:55:49.760 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
11443:M 14 Jul 2020 06:55:49.761 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 11443
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
11443:M 14 Jul 2020 06:55:49.762 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
11443:M 14 Jul 2020 06:55:49.762 # Server initialized
11443:M 14 Jul 2020 06:55:49.762 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
11443:M 14 Jul 2020 06:55:49.762 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
11443:M 14 Jul 2020 06:55:49.762 * Ready to accept connections
redis默认安装的路径是/usr/local/bin
目录下,我们将自己Redis解压目录下的 redis 配置文件redis.conf
复制到/usr/local/bin/config
下
root@ubuntu:/usr/local/bin# mkdir config
root@ubuntu:/usr/local/bin# cp /usr/local/redis/redis-6.0.5/redis.conf ./config/
root@ubuntu:/usr/local/bin# ll
total 38384
drwxr-xr-x 3 root root 4096 Jul 14 07:07 ./
drwxr-xr-x 13 root root 4096 Jul 14 02:00 ../
drwxr-xr-x 2 root root 4096 Jul 14 07:07 config/
-rwxr-xr-x 1 root root 5451864 Jul 14 06:54 redis-benchmark*
-rwxr-xr-x 1 root root 9486160 Jul 14 06:54 redis-check-aof*
-rwxr-xr-x 1 root root 9486160 Jul 14 06:54 redis-check-rdb*
-rwxr-xr-x 1 root root 5375136 Jul 14 06:54 redis-cli*
lrwxrwxrwx 1 root root 12 Jul 14 06:54 redis-sentinel -> redis-server*
-rwxr-xr-x 1 root root 9486160 Jul 14 06:54 redis-server*
root@ubuntu:/usr/local/bin# cd config/
root@ubuntu:/usr/local/bin/config# ll
total 92
drwxr-xr-x 2 root root 4096 Jul 14 07:07 ./
drwxr-xr-x 3 root root 4096 Jul 14 07:07 ../
-rw-r--r-- 1 root root 82645 Jul 14 07:07 redis.conf
root@ubuntu:/usr/local/bin/config#
redis默认不是后台启动的,所以需要设置后台启动,并且还需要远程链接,修改配置文件:vim redis.conf
,修改 daemonize 为 yes
# 设置为后台启动
daemonize yes
# 设置远程访,或者直接注释,取消本机绑定
bind 0.0.0.0
# bind 127.0.0.1
设置密码
# 设置Redis访问密码
requirepass liuhao
启动Redis服务(指定自已更改过的配置文件)
root@ubuntu:/usr/local/bin# redis-server config/redis.conf
11835:C 14 Jul 2020 07:32:13.580 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11835:C 14 Jul 2020 07:32:13.580 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=11835, just started
11835:C 14 Jul 2020 07:32:13.580 # Configuration loaded
root@ubuntu:/usr/local/bin#
使用redis-cli客户端链接测试
root@ubuntu:~# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
root@ubuntu:~#
关闭redis服务
方法一,查看进程关闭进程
root@ubuntu:~# ps -ef|grep redis
root 11836 1 0 07:32 ? 00:00:01 redis-server 127.0.0.1:6379
root 11995 11536 0 07:54 pts/1 00:00:00 grep --color=auto redis
root@ubuntu:~# kill 11836
root@ubuntu:~#
方法二,客户端链接后关闭服务端(推荐)
root@ubuntu:~# ps -ef|grep redis
root 12008 1 0 07:55 ? 00:00:00 redis-server 0.0.0.0:6379
root 12018 11536 0 08:01 pts/1 00:00:00 grep --color=auto redis
root@ubuntu:~# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> shutdown
not connected> exit
root@ubuntu:~# ps -ef|grep redis
root 12023 11536 0 08:02 pts/1 00:00:00 grep --color=auto redis
root@ubuntu:~#
设置分片(拷贝配置文件,更改端口 ,分别进行启动)
root@ubuntu:/usr/local/ela
sticsearch/elasticsearch-5.5.3# redis-server /usr/local/bin/config/redis-6380.conf
12387:C 14 Jul 2020 08:34:59.091 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12387:C 14 Jul 2020 08:34:59.091 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=12387, just started
12387:C 14 Jul 2020 08:34:59.091 # Configuration loaded
root@ubuntu:/usr/local/elasticsearch/elasticsearch-5.5.3# redis-server /usr/local/bin/config/redis-6381.conf
12393:C 14 Jul 2020 08:35:04.962 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12393:C 14 Jul 2020 08:35:04.962 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=12393, just started
12393:C 14 Jul 2020 08:35:04.962 # Configuration loaded
root@ubuntu:/usr/local/elasticsearch/elasticsearch-5.5.3# redis-server /usr/local/bin/config/redis-6382.conf
12399:C 14 Jul 2020 08:35:09.880 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12399:C 14 Jul 2020 08:35:09.880 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=12399, just started
12399:C 14 Jul 2020 08:35:09.880 # Configuration loaded
root@ubuntu:/usr/local/elasticsearch/elasticsearch-5.5.3#
官网下载Kibana,打开历史发行版本,选择你需要的版本进行下载
创建目录/usr/local/kibana
,将下载的压缩包拷贝到此目录
解压:tar -zxvf kibana-5.5.3-linux-x86_64.tar.gz
修改配置文件
# 添加如下配置
server.port: 5601
server.host: "0.0.0.0"
#192.168.xxx.xxx:9200为elasticsearch服务器IP:port
elasticsearch.url: "http://192.168.44.131:9200"
kibana.index: ".kibana"
汉化(5.5.3就别汉化了,学习点单词不好吗)
从6.7版本开始,
Kibana
支持中文,无需再像之前那样下载汉化包,甚至自己进行翻译。# 英文 i18n.locale: "en" # 中文 i18n.locale: "zh-CN"
配置用户变量,并设置生效:source /etc/profile
#set kibana environment
export KIBANA_HOME=/usr/local/kibana/kibana-5.5.3-linux-x86_64
# export environment
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$KIBANA_HOME/bin:$PATH
运行Kibana
root@ubuntu:/usr/local/kibana/kibana-5.5.3-linux-x86_64/config# kibana
log [14:26:34.970] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready
log [14:26:35.034] [info][status][plugin:[email protected]] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [14:26:35.067] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready
log [14:26:35.099] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready
log [14:26:35.271] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready
log [14:26:35.278] [info][listening] Server running at http://0.0.0.0:5601
log [14:26:35.281] [info][status][ui settings] Status changed from uninitialized to yellow - Elasticsearch plugin is yellow
log [14:26:35.286] [info][status][plugin:[email protected]] Status changed from yellow to green - Kibana index ready
log [14:26:35.287] [info][status][ui settings] Status changed from yellow to green - Ready
kibana &