Elasticsearch7.4.2 单实例安装

环境:操作系统 centos 6.10 内核2.6

下载地址https://www.elastic.co/cn/downloads/elasticsearch

elasticsearch下载页面

一、安装步骤

这里本人选择的Linux版本的 elasticsearch-7.4.2-linux-x86_64.tar.gz

  • 解压: tar -zxf elasticsearch-7.4.2-linux-x86_64.tar.gz
  • 重命名文件夹: mv elasticsearch-7.4.2 elasticsearch
  • 进入解压目录并查看目录结构:cd elasticsearch && ll
  • 进入config目录并查看目录信息:cd config && ll
  • 修改jvm配置信息: vim jvm.options
  • 修改elastic配置文件: vim elasticsearch.yml
  • 修改数据和日志存放路径:(请根据实际情况进行设置)

path.data: /usr/local/program/elasticsearch/data # 数据目录位置
path.logs: /usr/local/program/elasticsearch/logs # 日志目录位置

  • 设置node名称: node.name: node-1
  • 设置访问地址(这里设置为允许任何ip访问,可以根据实际情况设置为指定ip访问): network.host: 0.0.0.0
  • 设置访问端口: http.port: 9200

二、运行elasticsearch (请确定jdk 1.8以上)

第一次运行./bin/elasticsearch

future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_192-amd64/jre] does not meet this requirement
[2019-11-18T10:53:37,510][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.4.2.jar:7.4.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.4.2.jar:7.4.2]
… 6 more

原因elasticsearch 不能使用 root 用户启动

解决方案:

  • 创建用户组:groupadd elasticsearch
  • 创建用户: useradd es -p elasticsearch
  • 分配权限: chown -R es:elasticsearch /usr/local/program/elasticsearch

第二次运行

  • 切换用户: su es
  • 启动命令: ./bin/elasticsearch

future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_192-amd64/jre] does not meet this requirement
[2019-11-18T11:16:06,182][WARN ][o.e.b.JNANatives ] [node-1] unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:342) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:617) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:260) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:110) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) [elasticsearch-cli-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) [elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-7.4.2.jar:7.4.2]

原因: 因为Centos6不支持SecComp(centos6,其linux内核版本为2.6。而Elasticsearch的插件要求至少3.5以上版本)而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动 。

解决方案:修改配置文件 vim elasticsearch.yml

  • bootstrap.memory_lock: false
  • bootstrap.system_call_filter: false

第三次运行

  • 切换用户: su es
  • 启动命令: ./bin/elasticsearch

[2019-11-18T12:29:17,957][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [3] bootstrap checks failed
[1]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2019-11-18T12:29:17,965][INFO ][o.e.n.Node ] [node-1] stopping …
[2019-11-18T12:29:17,984][INFO ][o.e.n.Node ] [node-1] stopped
[2019-11-18T12:29:17,984][INFO ][o.e.n.Node ] [node-1] closing …
[2019-11-18T12:29:17,997][INFO ][o.e.n.Node ] [node-1] closed
[2019-11-18T12:29:17,999][INFO ][o.e.x.m.p.NativeController] [node-1] Native controller process has stopped – no new native processes can be started

错误原因: 启动检查未通过

  1. 用户的最大线程数太低
  2. 进程虚拟内存太低
  3. 配置项 cluster.initial_master_nodes 没有配置

解决方案:

  1. 修改vim /etc/security/limits.d/90-nproc.conf 将默认值改为4096或更大
  2. 修改vim /etc/sysctl.conf,追加以下内容:vm.max_map_count=655360保存后,执行:sysctl -p
  3. 修改配置文件 vim elasticsearch.yml 取消注释保留一个节点 cluster.initial_master_nodes: [“node-1”]

第四次运行

  • 切换用户: su es
  • 启动命令: ./bin/elasticsearch

终于启动成功!输入测试命令:curl http://127.0.0.1:9200 返回以下信息

kibana 7.4.2 安装

环境:操作系统 centos 6.10 内核2.6

下载地址: https://www.elastic.co/cn/downloads/kibana

这里我选择的linux 64 bit,下载后解压压缩包

  • 解压: tar -zxvf kibana-7.4.2-linux-x86_64.tar.gz
  • 重命名文件夹: mv kibana-7.4.2-linux-x86_64 kibana
  • 进入解压目录并查看:cd kibana && ll
  • 分配所属用户: chown -R es /usr/local/kibana/
kibana目录结构

修改kibana配置文件:vim ./config/kibana.yml

  • server.port: 5601 kibana 端口
  • server.host: “0.0.0.0” 远程访问
  • elasticsearch.hosts: [“http://127.0.0.1:9200”] elasticsearch 服务地址
  • 启动: ./bin/kibana
  • 后台启动: nohup bin/kibana & 
  • 停止:ps -ef|grep node 或者 netstat -anltp|grep 5601 查看进程
  • kill -9 pid

Maven package executable jar with dependencies

I found three ways to do it from stackoverflow.com

https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven

<!– package all dependencies with app into one jar –>
    <pluginRepositories>
        <pluginRepository>
            <id>onejar-maven-plugin</id>
            <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.dstovall</groupId>
                <artifactId>onejar-maven-plugin</artifactId>
                <version>1.4.4</version>
                <executions>
                    <execution>
                        <configuration>
                            <mainClass>org.junit.runner.JUnitCore</mainClass>
                        </configuration>
                        <goals>
                            <goal>one-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

<!– package app only, copy dependencies to specified lib folder and auto-configure classpath for your jar –>
  <build>
    <plugins>
      <plugin>
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
             <manifest>
               <addClasspath>true</addClasspath>
               <classpathPrefix>lib/</classpathPrefix>
               <mainClass>org.junit.runner.JUnitCore</mainClass>
             </manifest>
           </archive>
         </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.1</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>false</overWriteSnapshots>
              <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

<!– all dependencies will be unpacked, then package with app together –>
<!– might have problem while dealing with duplicate folder and file (already added, skipping) –>
    <build>
      <plugins>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <configuration>
            <descriptorRefs>
              <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
            <archive>
              <manifest>
                <mainClass>org.junit.runner.JUnitCore</mainClass>
              </manifest>
            </archive>
          </configuration>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>

微信开发

微信公众号发送客服消息提示errcode”:45015,”errmsg”:”response out of time limit or subscription is canceled hint:解决办法【已解决】

问题原因:由于长时间用户OpenId未和微信公众号做互动消息,微信公众号会停止对用户进行消息推送。

解决办法:以用户的身份随机向微信公众号对话框内输入任意文字已达到激活和微信公众号的互动,再次发送客服消息就会成功!

MySQL 5.7.26 解压版安装

step: 1 配置MySQL环境变量

配置MySQL环境变量,系统变量—>新建—->变量名为MYSQL_HOME,变量值为你的路径名

我的变量名是:C:\MySQL\mysql-5.7.26-winx64

然后更改Path环境变量,新增量为:%MYSQL_HOME%\bin

step: 2 配置MySQL my.ini文件

你解压下来的文件夹里面没有data文件夹以及my.ini文件,所以新增一个data空文件夹,以及my.ini文件。

my.ini文件内容如下

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
[mysqld]
#设置3306端口
port = 3306 
# 设置mysql的安装目录
basedir=D:\mysql\mysql-5.7.26-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql\mysql-5.7.26-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 设置sql_mode
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
# max allowed packet = 255M

注意 my.ini 文件格式必须为 ANSI

step: 3 安装MySQL服务以及初始化

  • 执行安装mysql服务 mysqld install
  • 执行mysql初始化 mysqld –initialize
  • 启动mysql服务 net start mysql
  • mysql -u root -p
  • 修改默认密码 alter user root@localhost identified by ‘root’;

linux centos 6.10 操作防火墙

一、iptables防火墙
1、基本操作

# 查看防火墙状态

service iptables status  

# 停止防火墙

service iptables stop  

# 启动防火墙

service iptables start  

# 重启防火墙

service iptables restart  

# 永久关闭防火墙

chkconfig iptables off  

# 永久关闭后重启

chkconfig iptables on  

2、开启80端口

vim /etc/sysconfig/iptables
# 加入如下代码
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
保存退出后重启防火墙

service iptables restart
二、firewall防火墙
1、查看firewall服务状态

systemctl status firewalld

出现Active: active (running)切高亮显示则表示是启动状态。

出现 Active: inactive (dead)灰色表示停止,看单词也行。
2、查看firewall的状态

firewall-cmd –state
3、开启、重启、关闭、firewalld.service服务

# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
4、查看防火墙规则

firewall-cmd –list-all 
5、查询、开放、关闭端口

# 查询端口是否开放
firewall-cmd –query-port=8080/tcp
# 开放80端口
firewall-cmd –permanent –add-port=80/tcp
# 移除端口
firewall-cmd –permanent –remove-port=8080/tcp
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd –reload

# 参数解释
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、–permanent:表示设置为持久;
3、–add-port:标识添加的端口;

原文:https://blog.csdn.net/bbwangj/article/details/74502967

标签: firwal防火墙状态查看linux防火墙查看状态

linux 部署项目常用命令

  • Linux服务器里面查看Tomcat是否启动: ps -ef |grep tomcat
  • 杀死tomcat 进程 kill -9 pid eg: kill -9 7089 这里的7089 就是进程pid
  • 启动tomcat sh startup.sh
  • 关闭tomcat sh shutdown.sh
  • 查看tomcat日志输出 tail -f catalina.out
  • 查看端口占用情况 netstat -ano

tomcat启动项目方式 分为内部启动和外部挂载方式

内部启动 修改server.xml

maven 打包常见错误

[ERROR] COMPILATION ERROR :
[INFO] ————————————————————-
[ERROR] /D:/GitWorkSpace/CodeUtil/src/main/java/com/nuoyun/ui/FileReplaceUI.java:[38,24] 编码GBK的不可映射字符

[ERROR] /D:/GitWorkSpace/CodeUtil/src/main/java/com/nuoyun/ui/FileReplaceUI.java:[39,60] -source 1.5 中不支持 diamond 运算符
(请使用 -source 7 或更高版本以启用 diamond 运算符)