Tag Archives: Middleware

How to Solve elasticsearch root user start Error

Question: Java lang.RuntimeException: can not run elasticsearch as root

Solution:

Elaticsearch cannot be started by root by default, so it will report Java.Lang.runtimeException: can not run elasticsearch as root.

There are two types of solutions:

1. Modify the elaticsearch configuration to allow the root user to start (not recommended)

#Add the parameter -Des.insecure.allow.root=true when executing elasticSearch, the complete command is as follows

./elasticsearch -Des.insecure.allow.root=true

#Or open the elasticsearch executable file with vi, and add the following command before the variable ES_JAVA_OPTS is used

ES_JAVA_OPTS="-Des.insecure.allow.root=true"

2. Create users for elaticsearch and grant corresponding permissions

adduser es

passwd es

chown -R es:es elasticsearch-6.3.2/

chmod 770 elasticsearch-6.3.2/

[Solved] Maven compile error: Blocked mirror for repositories

1. The following error is reported when compiling with Maven. The developer uses the same setting locally XML file compilation is OK

Could not resolve dependencies for project
Could not transfer artifact
Blocked mirror for repositories

2. The solution is to find the data because it is found in 3.8.1. In later versions, all HTTP protocol repositories are lost in the block, which can be solved by setting the values of mirror of and blocked attributes in the mirror to false. In consideration of setting XML is a general-purpose file, so we do not intend to modify it, but reduce the Maven version to 3.6 three

3. After reducing the version, rebuild and solve the problem

[Solved] Redis—-(error) MISCONF Redis is configured to save RDB snapshots

Error

Just after installing redis, I saw that the error reporting people below were stupid

(error) MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
127.0.0.1:6379[1]> config set stop-writes-on-bgsave-error no

A very simple set operation

127.0.0.1:6379[1]> Configure the stop writing error number on bgsave

I checked some related solutions on the Internet
this problem can be avoided by setting the stop writes on bgsave error value to No
solution 1:
one is to modify through the redis command line. This method is convenient and direct. The change takes effect directly to solve the problem.

Example of command line modification method:

127.0.0.1:6379[1]> config set stop-writes-on-bgsave-error no

Solution 2:
modify the redis.conf configuration file directly, but restart redis after the change
modify the redis.conf file:
(1) VIM opens the redis.conf file configured for redis server,
(2) use the quick matching mode:
/stop writes on bgsave error to locate the stop writes on bgsave error string,
(3) set the following yes to No.

The problem of inconsistent host names in building rabbitmq on Linux

1. Environment:

centos 7.3

2. Problem description

Today, the following error occurred in the process of deploying rabbitmq as a front-end and back-end message push

$ rabbitmqctl set_permissions -p/duni ".*" ".*" ".*"

Error: unable to connect to node rabbit@bbbbdddd: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@bbbbdddd]

rabbit@bbbbdddd:
  * connected to epmd (port 4369) on bbbbdddd
  * epmd reports node 'rabbit' running on port 25672
  * TCP connection succeeded but Erlang distribution failed

  * Hostname mismatch: node "rabbit@localhost" believes its host is different. Please ensure that hostnames resolve the same way locally and on "rabbit@localhost"


current node details:
- node name: 'rabbitmq-cli-92@bbbbdddd'
- home dir: /var/lib/rabbitmq
- cookie hash: h6TDjQ+DgPaVGJLMjcG4TA==

I can’t connect to the host where I deployed rabbitmq bbbbdddd

3. Google

Google found the corresponding problem in stack overflow

Here we say to give rabbitmq command permission, delete the service and then re install it. After trying, I found that I can’t do it…

Continue with Google, and some people say to correct Erlang’s Cookie:

Erlang will generate two cookie files: C: windows. Erlang. Cookie and C: user. Erlang. Cookie. Check whether the contents of the two files are consistent. If not, replace one with the other.

Windows platform, er… My environment is Linux, and I didn’t find two . Erlang. Cookie files in the root directory

$ find/--name .erlang.cookie
/var/lib/rabbitmq/.erlang.cookie

So I gave up.

4. Solutions

The final solution is to set the host name and restart the rabbitmq service

# Kill the rabbitmq process first
$ ps -ef | grep rabbitmq | grep -v grep | awk '{print $2}' | xargs kill -9

# set hostname (assume host ip is: 192.168.1.1, hostname set to: mq)
$ echo 192.168.1.1 mq > /etc/hosts
$ echo rabbitmq > /etc/hostname
$ export HOSTNAME=mq

# Restart rabbitmq
$ rabbitmq-server -detached
# Start the web socket service
$ rabbitmq-plugins enable rabbitmq_management rabbitmq_web_stomp
# Set up users and give them administrator privileges
$ rabbitmqctl add_user duni duni
$ rabbitmqctl set_user_tags duni administrator
# set user directory
$ rabbitmqctl set_permissions -p/duni ".*" ".*" ".*"

After Nacos started, the client worker log was printed all the time

After Nacos started, the client worker log was printed all the time

Phenomenon

Print the clientworker log all the time

2020-08-24 00:57:30.977 INFO  [12932] --- [.cn_8848-public] c.a.n.client.config.impl.ClientWorker    : [fixed-nacos.itlym.cn_8848-public] [data-received] dataId=common.yml, group=DEFAULT_GROUP, tenant=public, md5=8c191cace81179b01fb745b5d027c1c8, content=xxx
2020-08-24 00:57:30.989 INFO  [12932] --- [.cn_8848-public] c.a.n.client.config.impl.ClientWorker    : [fixed-nacos.itlym.cn_8848-public] [data-received] dataId=sms-center.yml, group=DEFAULT_GROUP, tenant=public, md5=f12bc945ba0c1d39f3dea2e0977db712, content=xxx
...

Cause analysis

Root cause

Having seen the source code of Nacos before, Nacos will check whether the configuration items are consistent with the server configuration items every 10ms. If not, it will pull the latest configuration from the server therefore, if the MD5 algorithms of Nacos client and Nacos server are different, it will lead to misjudgment, thus constantly refreshing and printing the client worker logs.

Direct cause

My Nacos server is 1.3, and the client uses spring cloud Alibaba. Version . Click to find that the Nacos client version is 1.2

			<dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>2.2.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

Here, the spring-cloud-alibaba-dependencies‘s official website and warehouse have not been updated for a long time, which is easy to make complaints about users and waste a lot of investigation time.

Other possible reasons

The public is set in the namespace. See the Nacos GitHub

At this time, the best way to solve this problem is not to set the namespace. Otherwise, when Nacos releases a new version, it may be 1.4

Solution

Method 1:

Change the version of client and Nacos server to the same, as follows

client:
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
    <version>${spring-cloud-alibaba.version}</version>
    <type>pom</type>
    <scope>import</scope>
    <exclusions>
    <exclusion>
        <artifactId>com.alibaba.nacos</artifactId>
        <groupId>nacos-client</groupId>
    </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.alibaba.nacos</groupId>
    <artifactId>nacos-client</artifactId>
    <version>1.3.2</version>
</dependency>

Method 2:

Because spring cloud Alibaba dependencies leaves the gap of properties specified version (default < nacos.client.version> 1.2.1)
so you only need to add

<properties>
	<nacos.client.version>1.2.1</nacos.client.version>
</properties>

Note: if spring cloud starter Nacos config is introduced, it can’t be avoided by this scheme, because ‘spring cloud Alibaba dependencies’ has hard coding problems. When importing, you should actively specify the version.

			 <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
                <version>1.3.0</version>
            </dependency>

Method 3 (middleware upgrade scheme suitable for existing system):

Download the Nacos client Version 1.2.1 code, modify its md5util package path to a new one, and then re publish it to the local or private warehouse.

RabbitMQ login failed

rabbitMQ logon failure

check log found error

tail /var/log/rabbitmq/rabbit\@VM-OR-rabbit-MQ.log

=ERROR REPORT==== 12-Mar-2019::10:13:56 ===

webmachine error: path=”/api/whoami”

“Unauthorized”

solution:

look at the list of users

[root@VM-OR-rabbit-MQ ~]# rabbitmqctl list_users

Listing users …

guest (administrator)
Create an admin user with a password of admin

[root@VM-OR-rabbit-MQ ~]# rabbitmqctl add_user admin admin

Creating user “admin” …

is set to administrator

[root@VM-OR-rabbit-MQ ~]# rabbitmqctl set_user_tags admin administrator

Setting tags for user “admin” to [administrator] …

[root@VM-OR-rabbit-MQ ~]# rabbitmqctl list_users

Listing users …

admin/administrator

guest (administrator)
Restart the rabbitmq service:

[root@VM-OR-rabbit-MQ ~]# service rabbitmq-server restart

Restarting rabbitmq-server: SUCCESS

rabbitmq-server.

retest rabbitMQ login success