Tag Archives: rabbitmq

[Solved] Rabbitmq startup Error: FAILED – check /var/log/rabbitmq/startup_{log, _err}

Report an error:
Starting rabbitmq-server: FAILED – check /var/log/rabbitmq/startup_{log, _err}
This way
Check the startup_log:
ERROR: epmd error for host 192: badarg (unknown POSIX error)
like this

Solution:
1. Turn off SELINUX:
Enter the command: vi /etc/selinux/config
Modify: SELINUX=disabled
2. Enter the command: vi /etc/rabbitmq/rabbitmq-env.conf
Add a line: NODENAME=rabbit@localhost
Start again successfully.
Enter the command: service rabbitmq-server start

[Solved] rabbitmq Error: Failed to start RabbitMQ broker

systemctl start rabbitmq-server


Error Messages:

Error: unable to connect to node rabbit@sf206152: nodedown
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {bad_return,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {{rabbit,start,[normal,[]]},
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {‘EXIT’,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {rabbit,failure_during_boot,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {error,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {schema_integrity_check_failed,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: [{table_attributes_mismatch,rabbit_user,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: [username,password_hash,tags],
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: [username,password_hash,tags,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: hashing_algorithm]}]}}}}}}}
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: Log files (may contain more information):
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: /var/log/rabbitmq/[email protected]
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: /var/log/rabbitmq/[email protected]
Jun 21 17:11:13 sf206152 rabbitmq-server[31112]: {“init terminating in do_boot”,{rabbit,failure_during_boot,{could_not_start,rabbit,{bad_return,{{rabbit,start,[normal,[]]},{‘EXIT’,{rabbit,failure_du
Jun 21 17:11:14 sf206152 rabbitmq-server[31112]: Crash dump was written to: erl_crash.dump
Jun 21 17:11:14 sf206152 rabbitmq-server[31112]: init terminating in do_boot ()
Jun 21 17:11:14 sf206152 systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: Stopping and halting node rabbit@sf206152 …
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: Error: unable to connect to node rabbit@sf206152: nodedown
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: DIAGNOSTICS
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: ===========
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: attempted to contact: [rabbit@sf206152]
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: rabbit@sf206152:
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: * connected to epmd (port 4369) on sf206152
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: * epmd reports: node ‘rabbit’ not running at all
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: no other nodes on sf206152
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: * suggestion: start the node
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: current node details:
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: – node name: rabbitmqctl31207@sf206152
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: – home dir: /var/lib/rabbitmq
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: – cookie hash: cmvEv4p7/gNkQVUvRdn10w==
Jun 21 17:11:14 sf206152 systemd[1]: rabbitmq-server.service: control process exited, code=exited status=2
Jun 21 17:11:14 sf206152 systemd[1]: Failed to start RabbitMQ broker.
— Subject: Unit rabbitmq-server.service has failed
— Defined-By: systemd
— Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

— Unit rabbitmq-server.service has failed.

— The result is failed.

solution:
[email protected], rabbit@localhost, rabbit@localhost-plugins-expand exist in the /var/lib/rabbitmq/mnesia directory. After deleting these 3 items, use systemctl start rabbitmq-server to start.

# Start stop restart
service rabbitmq-server start
service rabbitmq-server stop
service rabbitmq-server restart

# View status
rabbitmqctl cluster_status
rabbitmqctl status

Add a new user
[root@sf106212 etc]# rabbitmqctl add_user admin admin@2015
View current user list
[root@sf106212 etc]# rabbitmqctl list_users
Set user role super administrator (administrator)
[root@sf106212 etc]# rabbitmqctl set_user_tags admin administrator
Set user permissions
[root@sf106212 etc]# rabbitmqctl set_permissions -p/admin “.*” “.*” “.*”
View the authority information of the specified user
[root@sf106212 etc]# rabbitmqctl list_user_permissions admin
Listing permissions for user “admin” …
/ .* .* .*

# Start the configuration automatically start
rabbitmq-plugins enable rabbitmq_management
service rabbitmq-server start
chkconfig rabbitmq-server on
http://localhost:15672

Rabbitmq startup error kernel PID terminated [How to Solve]

Error Message:
Error executing ‘postInstallation’: Unable to start com.bitnami.rabbitmq: Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{bad_return,{{rabbit,start,[normal,[]]},{‘EXIT’,{error,{{shutdown,{failed_to_start_child,rabbit_memory_monitor,{badarg
Crash dump is being written to: /opt/bitnami/rabbitmq/var/log/rabbitmq/erl_crash.dump…done
: Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{bad_return,{{rabbit,start,[normal,[]]},{‘EXIT’,{error,{{shutdown,{failed_to_start_child,rabbit_memory_monitor,{badarg
Crash dump is being written to: /opt/bitnami/rabbitmq/var/log/rabbitmq/erl_crash.dump…done

 

It was found that it was caused by insufficient memory on the server.
Query server memory command: free – h

Rabbitmq error of connecting the native idea to Linux: java.net.connectexception: connection timed out: Connect [Solved]

The code is as follows:

        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("192.168.2.135");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("admin");
        connectionFactory.setPassword("admin");
        connectionFactory.setVirtualHost("/");

        Connection connection=null;
        Channel channel = null;

        try {
            //2.create linke Connection
            connection = connectionFactory.newConnection("Creator");

Error: Java. Net. Connectexception: connection timed out: connect

Cause analysis: first, the IP port account and password are excluded

Error reason: port 5672 is not open. I always thought that everything would be fine as long as the protective wall was closed

Solution:

1. Restart the firewall: systemctl start firewall

2. Open 5672 port: firewall CMD — zone = public — add port = 5672/TCP — permanent

3. Reload: firewall CMD — reload

Run debug:

success!!!

Error about exchange mode type in rabbitmq [How to Solve]

channel.exchange_declare(exchange='logs',
 type='fanout')

error:

Traceback (most recent call last):
File “D:/fanout_server.py”, line 12, in <module>
type=’fanout’)
TypeError: exchange_declare() got an unexpected keyword argument ‘type’

The reason is that the type parameter here must be specified as exchange_type

channel.exchange_declare(exchange='logs',
 exchange_type='fanout')

After the change, it runs normally, but strangely, some people have no problem specifying it with type. They don’t understand it

 

How to Solve Rabbitmq Error: Failed to start RabbitMQ broker

systemctl start rabbitmq-server

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

Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {bad_return,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {{rabbit,start,[normal,[]]},
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {‘EXIT’,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {rabbit,failure_during_boot,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {error,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: {schema_integrity_check_failed,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: [{table_attributes_mismatch,rabbit_user,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: [username,password_hash,tags],
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: [username,password_hash,tags,
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: hashing_algorithm]}]}}}}}}}
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: Log files (may contain more information):
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: /var/log/rabbitmq/[email protected]
Jun 21 17:11:12 sf206152 rabbitmq-server[31112]: /var/log/rabbitmq/[email protected]
Jun 21 17:11:13 sf206152 rabbitmq-server[31112]: {“init terminating in do_boot”,{rabbit,failure_during_boot,{could_not_start,rabbit,{bad_return,{{rabbit,start,[normal,[]]},{‘EXIT’,{rabbit,failure_du
Jun 21 17:11:14 sf206152 rabbitmq-server[31112]: Crash dump was written to: erl_crash.dump
Jun 21 17:11:14 sf206152 rabbitmq-server[31112]: init terminating in do_boot ()
Jun 21 17:11:14 sf206152 systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: Stopping and halting node rabbit@sf206152 …
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: Error: unable to connect to node rabbit@sf206152: nodedown
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: DIAGNOSTICS
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: ===========
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: attempted to contact: [rabbit@sf206152]
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: rabbit@sf206152:
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: * connected to epmd (port 4369) on sf206152
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: * epmd reports: node ‘rabbit’ not running at all
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: no other nodes on sf206152
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: * suggestion: start the node
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: current node details:
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: – node name: rabbitmqctl31207@sf206152
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: – home dir: /var/lib/rabbitmq
Jun 21 17:11:14 sf206152 rabbitmqctl[31207]: – cookie hash: cmvEv4p7/gNkQVUvRdn10w==
Jun 21 17:11:14 sf206152 systemd[1]: rabbitmq-server.service: control process exited, code=exited status=2
Jun 21 17:11:14 sf206152 systemd[1]: Failed to start RabbitMQ broker.
— Subject: Unit rabbitmq-server.service has failed
— Defined-By: systemd
— Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

— Unit rabbitmq-server.service has failed.

— The result is failed.

 

Solution:</strong

/var/lib/rabbitmq/mnesia 目录下存在[email protected], rabbit@localhost, rabbit@localhost-plugins-expand, delete these 3 items, and then use systemctl start rabbitmq-server to start.

# StartStopRestart

service rabbitmq-server start

service rabbitmq-server stop

service rabbitmq-server restart

# Check Status

rabbitmqctl cluster_status

rabbitmqctl status

Add a new user

[root@sf106212 etc]# rabbitmqctl add_user admin admin@2015

View the list of current users

[root@sf106212 etc]# rabbitmqctl list_users

Set the user role superadministrator

[root@sf106212 etc]# rabbitmqctl set_user_tags admin administrator

Set user permissions

[root@sf106212 etc]# rabbitmqctl set_permissions -p/admin “.*” “.*” “.*”

 

View permission information for the specified user

[root@sf106212 etc]# rabbitmqctl  list_user_permissions admin

Listing permissions for user “admin” …

/       .*      .*      .*

# StartConfigure Auto Start

rabbitmq-plugins enable rabbitmq_management

service rabbitmq-server start

chkconfig rabbitmq-server on

http://localhost:15672

[Solved] Reasons for error in rabbitmq when supervisor starts

Preface

Today, I rebooted the server and found that the rabbitmq process managed by supervisor failed to start. Looking at the log, I found that there were always errors and recorded the solution

Error: erlexec:HOME must be set

I found many people’s blogs on the Internet. Generally speaking, I added the following in the script of process startup:

export HOME=/usr/local/erlang
export PATH=$PATH:$HOME/bin  

The system’s default home is/root, which may result in the Erlang language environment not getting the home parameter; The above modifications can be used in chkconfig management and service management processes, but for supervisor management processes, because the startup name of the process is in supervisor.conf, the home parameter cannot be modified directly

method: add the above statements to the supervisor startup script

vi Ssupervisor.conf

#!/bin/sh
# chkconfig: 2345 70 90

export HOME=/usr/local/erlang
export PATH=$PATH:$HOME/bin
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf

This can ensure that the home is only changed temporarily, but it has no impact on the home of the system

Tracing back to the source

Why is there such a mistake

This error is not caused by rabbitmq, but by Erlang language environment; To view an ERL process:

ps aux | grep beam

# 结果:
root      1779  0.4  0.5 3863876 86060 ?      Sl   19:21   0:06 /usr/local/erlang/bin/x86_64-unknown-linux-gnu/beam.smp -W w -A 64 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true -B i -- -root /usr/local/erlang -progname erl -- -home /root 

You can see that the – Home parameter is added to the startup. Start an ERL instance, which calls the C file of erlexec

# erlexec.c The path to the file is /usr/local/erlang/erts/etc/common/erlexec.c

# part of codes
static char * home;
static char ** Eargsp = NULL;
static int EargsCnt = 0;
static char **argsp = NULL;

static void get_home( void )
{
    home = get_env("HOME");
    if (home == NULL)
        error("HOME must be set");
}

can see get_ The env function gets the home environment variable. If it fails, it outputs “home must be set”

at present, what we don’t understand is that the home parameter has a default value of/root, why get_ Env function cannot get it, but returns null; Further research is needed

Rabbitmq restart failed

it is found that after the process of manually killing rabbitmq, the supervisor will either fail or not restart rabbitmq

it’s OK to start and stop rabbitmq by using supervisor background process management, but it’s impossible to restart rabbitmq by manually killing it

reason:

rabbitmq after using rabbitmq server start or rabbitmq server start, there will be two processes, one is Erlang’s node service program; One is the application of rabbitmq; Rabbitmq applications run on Erlang nodes

if you forcibly kill rabbitmq’s application process, supervisor will try to start it. At this time, it will try to start Erlang’s node service program and rabbitmq’s application program. It is found that there is already an Erlang’s node service program, so the start will fail

if you forcibly kill Erlang’s node service program, Erlang’s node service program and rabbitmq’s application program will be stopped. If the configuration parameter is autorestart = unexpected, supervisor will not restart the process. If the parameter is set to autorestart = true, Then supervisor will restart Erlang’s node service program and rabbitmq’s application program

conclusion:

it is not appropriate for supervisor to manage rabbitmq process, because when rabbitmq application crashes and Erlang node service program is normal, restart will fail

If only nodes are running, but there is no application instance of rabbitmq, then the management background of rabbitmq cannot log in

[Solved] Rabbitmq Startup Error: (BOOT FAILED)

The normal rabbitmq was started before. When it was started again today, an error was reported. The error message is as follows:

$ rabbitmq-server

              RabbitMQ 3.6.6. Copyright (C) 2007-2016 Pivotal Software, Inc.
  ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
  ##  ##
  ##########  Logs: /Applications/Coding/rabbitmq/var/log/rabbitmq/[email protected]
  ######  ##        /Applications/Coding/rabbitmq/var/log/rabbitmq/[email protected]
  ##########
              Starting broker...


BOOT FAILED
===========

Error description:
   {could_not_start,rabbit,
       {undef,
           [{crypto,module_info,[attributes],[]},
            {rabbit_misc,module_attributes,1,
                [{file,"src/rabbit_misc.erl"},{line,798}]},
            {rabbit_misc,'-all_module_attributes/1-fun-0-',3,
                [{file,"src/rabbit_misc.erl"},{line,818}]},
            {lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
            {rabbit_boot_steps,find_steps,1,
                [{file,"src/rabbit_boot_steps.erl"},{line,40}]},
            {rabbit_boot_steps,run_boot_steps,1,
                [{file,"src/rabbit_boot_steps.erl"},{line,26}]},
            {rabbit,start,2,[{file,"src/rabbit.erl"},{line,687}]},
            {application_master,start_it_old,4,
                [{file,"application_master.erl"},{line,272}]}]}}

Log files (may contain more information):
   /Applications/Coding/rabbitmq/var/log/rabbitmq/[email protected]
   /Applications/Coding/rabbitmq/var/log/rabbitmq/[email protected]

{"init terminating in do_boot",{could_not_start,rabbit,{undef,[{crypto,module_info,[attributes],[]},{rabbit_misc,module_attributes,1,[{file,"src/rabbit_misc.erl"},{line,798}]},{rabbit_misc,'-all_module_attributes/1-fun-0-',3,[{file,"src/rabbit_misc.erl"},{line,818}]},{lists,foldl,3,[{file,"lists.erl"},{line,1261}]},{rabbit_boot_steps,find_steps,1,[{file,"src/rabbit_boot_steps.erl"},{line,40}]},{rabbit_boot_steps,run_boot_steps,1,[{file,"src/rabbit_boot_steps.erl"},{line,26}]},{rabbit,start,2,[{file,"src/rabbit.erl"},{line,687}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,272}]}]}}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

After a while, I found that Erlang had not been installed. I had previously re installed homebrew. I suspected that I had uninstalled it before

Re install Erlang

$ brew install erlang
Updating Homebrew...
==> Installing dependencies for erlang: openssl, jpeg, libpng, libtiff, wxmac
==> Installing erlang dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2k.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2k.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary

Rabbitmq simple configuration and oserror: [errno 9] bad file descriptor problem

Written in the front, due to the version problem of rabbitmq, the location of the parameters passed in may be different. You can check the source code and pass them in one by one

send.py

# encoding: utf-8
# Date: 2019/11/25 20:43


__author__ = 'ryan.liu'

import pika


def test(hash_value):
    # 1, Connect to RabbitMq server
    rabbit_username = 'admin'
    rabbit_password = 'admin'
    credentials = pika.PlainCredentials(rabbit_username, rabbit_password)
    connection = pika.BlockingConnection(
        pika.ConnectionParameters(host='127.0.0.1', port=5672, credentials=credentials))

    # channel is the channel for reading and writing messages
    channel = connection.channel()

    # 2, create a queue named queue
    channel.queue_declare(queue='queue')

    # 3, configure basic_pulish
    channel.basic_publish(
        '',
        'queue',
        hash_value)

    # 4,close connection
    connection.close()
    # return make_response({})

receive.py

# encoding: utf-8
# Date: 2019/11/25 20:43

__author__ = 'ryan.liu'

import pika

rabbit_username = 'admin'
rabbit_password = 'admin'
credentials = pika.PlainCredentials(rabbit_username, rabbit_password)
connection = pika.BlockingConnection(pika.ConnectionParameters(host='127.0.0.1', port=5672, credentials=credentials))
channel = connection.channel()

# Declare the queue
channel.queue_declare(queue='queue')


# 3, define a callback function that the Pika library calls when a message is obtained to process the message
def callback(ch, method, properties, body):
    print("receive.py: receive message", body)


# 4, receive message from queue
# channel.basic_consume(
#     queue='queue',
#     callback,
#     no_ack=True)

channel.basic_consume(
    "queue",
    callback,
    auto_ack=True
)

# 5,wait for message
channel.start_consuming()

I made a mistake today, which caused MQ to report an error all the time

OSError: [Errno 9] Bad file descriptor

The error code is as follows:

rabbit_username = 'admin'
rabbit_password = 'admin'
credentials = pika.PlainCredentials(rabbit_username, rabbit_password)
connection = pika.BlockingConnection(
  pika.ConnectionParameters(host='127.0.0.1', port=5672, credentials=credentials))

channel = connection.channel()

channel.queue_declare(queue='queue')

def test(hash_value):
    channel.basic_publish(
        '',
        'queue',
        hash_value)

    connection.close()
    # return make_response({})

This is a question of the scope of the python foundation

Rabbitmq error

pika.exceptions.IncompatibleProtocolError: StreamLostError: ('Transport indicated EOF',)

Because I started the rabbitmq service with docker, I mapped the port to port 8181, but in fact, when docker started MQ, port 5672 would be started automatically. Therefore, when configuring, port should be the default instead of 8181

Comparison of service registration models: Consult vs zookeeper vs etcd vs Eureka

Zookeeper is based on the simplified version of Zab of Paxos, etcd is based on raft algorithm, and consumer is also based on raft algorithm. Etcd and consumer, as rising stars, did not abandon themselves because they already had zookeeper, but adopted a more direct raft algorithm.

The number one goal of raft algorithm is to be easy to understand, which can be seen from the title of the paper. Of course, raft enhances comprehensibility, which is no less than Paxos in terms of performance, reliability and availability.

Raft more understandable than Paxos and also provides a better foundation for building practical systems

   in order to achieve the goal of being easy to understand, raft has made a lot of efforts, the most important of which are two things:

problem decomposition

State simplification

   problem decomposition is to divide the complex problem of “node consistency in replication set” into several subproblems that can be explained, understood and solved independently. In raft, subproblems include leader selection, log replication, safety and membership changes. The better understanding of state simplification is to make some restrictions on the algorithm, reduce the number of States to be considered, and make the algorithm clearer and less uncertain (for example, to ensure that the newly elected leader will contain all the commented log entries)

Raft implements consensus by first electing a distinguished leader, then giving the leader complete responsibility for managing the replicated log. The leader accepts log entries from clients, replicates them on other servers, and tells servers when it is safe to apply log entries to their state machines. A leader can fail or become disconnected from the other servers, in which case a new leader is elected.

   the above quotation highly summarizes the working principle of raft protocol: raft will select the leader first, and the leader is fully responsible for the management of replicated log. The leader is responsible for accepting all client update requests, copying them to the follower node, and executing them when “safe”. If the leader fails, followers will re elect a new leader.

   this involves two new subproblems of raft: Leader Selection and log replication

leader election

log replication

Here is a comparison of the following features of service discovery products that are often used. First of all, let’s look at the following conclusions:

Health check of service

Euraka needs to explicitly configure health check support when it is used; zookeeper and etcd are not healthy when they lose the connection with the service process, while consult is more detailed, such as whether the memory has been used by 90% and whether the file system is running out of space.

Multi data center support

Consul completes the synchronization across data centers through Wan’s gossip protocol, and other products need additional development work

KV storage service

In addition to Eureka, several other products can support K-V storage services externally, so we will talk about the important reasons why these products pursue high consistency later. And providing storage services can also be better transformed into dynamic configuration services.

The choice of cap theory in product design

Eureka’s typical AP is more suitable for service discovery in distributed scenarios. Service discovery scenarios have higher availability priority and consistency is not particularly fatal. Secondly, CA type scenario consul can also provide high availability and ensure consistency of K-V store service. Zookeeper and etcd are CP types, which sacrifice availability and have little advantage in service discovery scenarios

Multilingual capability and access protocol for external services

Zookeeper’s cross language support is weak, and other models support http11 to provide access. Euraka generally provides access support for multilingual clients through sidecar. Etcd also provides grpc support. In addition to the standard rest Service API, consul also provides DNS support.

Watch support (clients observe changes in service providers)

Zookeeper supports server-side push changes, and Eureka 2.0 (under development) also plans to support it. Eureka 1, consul and etcd all realize change perception through long polling

Monitoring of self cluster

In addition to zookeeper, other models support metrics by default. Operators can collect and alarm these metrics information to achieve the purpose of monitoring

Safety

Consul and zookeeper support ACL, and consul and etcd support secure channel HTTPS

Integration of spring cloud

At present, there are corresponding boot starters, which provide integration capabilities.

In general, the functions of consul and the support of spring cloud for its integration are relatively perfect, and the complexity of operation and maintenance is relatively simple (there is no detailed discussion). The design of Eureka is more in line with the scene, but it needs continuous improvement.

Etcd and zookeeper provide very similar capabilities, and their positions in the software ecosystem are almost the same, and they can replace each other.

They are universal consistent meta information storage

Both provide a watch mechanism for change notification and distribution

They are also used by distributed systems as shared information storage

In addition to the differences in implementation details, language, consistency and protocol, the biggest difference lies in the surrounding ecosystem.

Zookeeper is written in Java under Apache and provides RPC interface. It was first hatched from Hadoop project and widely used in distributed system (Hadoop, Solr, Kafka, mesos, etc.).

Etcd is an open source product of coreos company, which is relatively new. With its easy-to-use rest interface and active community, etcd has captured a group of users and has been used in some new clusters (such as kubernetes).

Although V3 is changed to binary RPC interface for performance, its usability is better than zookeeper.

While the goal of consul is more specific. Etcd and zookeeper provide distributed consistent storage capacity. Specific business scenarios need to be implemented by users themselves, such as service discovery and configuration change.

Consul aims at service discovery and configuration change, with kV storage.

In the software ecology, the more abstract the components are, the wider the scope of application is, but there must be some shortcomings in meeting the requirements of specific business scenarios.

——————-Message middleware rabbitmq

Message middleware rabbitmq (01)

Message middleware rabbitmq (02)
0

Message middleware rabbitmq (03)
0

Message middleware rabbitmq (04)
0

Message middleware rabbitmq (05)

Message middleware rabbitmq (06)
0

Message middleware rabbitmq (07)

———————- cloud computing————————————-

Cloud computing (1) — docker’s past and present life

Cloud computing (2) — Architecture

Cloud computing (3) — container applications

Cloud computing (4) — lamp

Cloud computing (5) — dockerfile
cloud computing (6) — harbor

Add wechat to the wechat communication group of wechat service, and note that wechat service enters the group for communication

pay attention to official account soft Zhang Sanfeng

this article is shared by WeChat official account – soft Zhang Sanfeng (aguzhangsanfeng).
In case of infringement, please contact [email protected] Delete.
This article participates in the “OSC source creation program”. You are welcome to join and share.