Author Archives: Robins

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 ".*" ".*" ".*"

postgresql FATAL:no pg_hba.conf entry for host “192….“

In PG_ Add the IP to hbaconf and restart postgreql
as follows:[ https://blog.csdn.net/qq_ 36434219/article/details/118277681]

Note: there are many IP addresses added, one by one… You can directly configure the fixed network segment. For example, the above figure can be configured as follows:
192.168.3.0/24 represents having 254 IP addresses: from 192.168.1.1 to 192.168.1.254

User defined height of layeui carousel

Layui’s official definition of carousel height is placed in

carousel.render({height:''...})

In the method   Pixels and percentages are supported. But the author has a demand, the carousel chart needs the background to return to the front according to the data permission control

And you need to set the height dynamically, not the fixed number of pixels and the proportion, and the height needs to be adjusted according to the current height

Adjust the pixels of the computer, such as how high is 1024 pixels, how high is normal pixels.

No more nonsense, just go to JS code:

Register global time filter in main.js in Vue

In main.js, define a global time filter through: Vue. Filter().
the first parameter is the name of the filter, such as: dataform,
the second parameter is the processing function of the time filter: function(), which needs to specify a formal parameter: originval, which is to process the time data
to get the originval time, first update the date and pass the originval to you, that is, to get a date object of the time according to the local time

Get four digit year through getfullyear()

Get the month through getmonth(). The month starts from 1, so make it + 1
if the month is less than two digits, fill in 0 in the front by calling. Padstart (2, ‘0’). The first parameter represents the total length of the number of digits, and the second parameter is a string. If the number of digits is less than two, which string should be filled in

Get the current date through: getdate()

Get the current hour through: gethours()

Get the current minutes through: getminutes()

Get the current seconds by: getseconds()

Let the obtained date, time, minute and second be spliced into a complete date string
return ${y} - ${m} - ${D} - ${HH}: ${mm}: ${SS}

//Format time filter
vue.filter (‘dataform ‘, function (originval) {
const DT = new date (originval)

const y = dt.getFullYear()
const m = (dt.getMonth() + 1 + ‘’).padStart(2, ‘0’)
const d = (dt.getDate() + ‘’).padStart(2, ‘0’)

const hh = (dt.getHours() + ‘’).padStart(2, ‘0’)
const mm = (dt.getMinutes() + ‘’).padStart(2, ‘0’)
const ss = (dt.getSeconds() + ‘’).padStart(2, ‘0’)

return ${y}-${m}-${d} ${hh}:${mm}:${ss}

RabbitMQ Startup Script (How to Set)

Create a new rabbitmq server script in the/etc/init. D directory

In the script, you need to modify Erlang path, daemon, control, init in path_LOG_Dir and PID_File parameter

#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#

### BEGIN INIT INFO
# Provides:          rabbitmq-server
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Description:       RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO

# Source function library.
. /etc/init.d/functions
export HOME=/root
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/erlang/bin
NAME=rabbitmq-server
#DAEMON=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/${NAME}
#CONTROL=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/rabbitmqctl
DAEMON=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/${NAME}
CONTROL=/usr/local/rabbitmq/rabbitmq_server-3.8.17/sbin/rabbitmqctl
DESC=rabbitmq-server
USER=root
ROTATE_SUFFIX=
INIT_LOG_DIR=/usr/local/rabbitmq/rabbitmq_server-3.8.17/var/log/rabbitmq
PID_FILE=/usr/local/rabbitmq/rabbitmq_server-3.8.17/var/run/rabbitmq/pid

START_PROG="daemon"
LOCK_FILE=/var/lock/subsys/$NAME

test -x $DAEMON || exit 0
test -x $CONTROL || exit 0

RETVAL=0
set -e

[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}

ensure_pid_dir () {
    PID_DIR=`dirname ${PID_FILE}`
    if [ ! -d ${PID_DIR} ] ; then
        mkdir -p ${PID_DIR}
        chown -R ${USER}:${USER} ${PID_DIR}
        chmod 755 ${PID_DIR}
    fi
}

remove_pid () {
    rm -f ${PID_FILE}
    rmdir `dirname ${PID_FILE}` || :
}

start_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        echo RabbitMQ is currently running
    else
        RETVAL=0
        ensure_pid_dir
        set +e
        RABBITMQ_PID_FILE=$PID_FILE $START_PROG $DAEMON \
            > "${INIT_LOG_DIR}/startup_log" \
            2> "${INIT_LOG_DIR}/startup_err" \
            0<&- &
        $CONTROL wait $PID_FILE >/dev/null 2>&1
        RETVAL=$?
        set -e
        case "$RETVAL" in
            0)
                echo SUCCESS
                if [ -n "$LOCK_FILE" ] ; then
                    touch $LOCK_FILE
                fi
                ;;
            *)
                remove_pid
                echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
                RETVAL=1
                ;;
        esac
    fi
}

stop_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        set +e
        $CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
        RETVAL=$?
        set -e
        if [ $RETVAL = 0 ] ; then
            remove_pid
            if [ -n "$LOCK_FILE" ] ; then
                rm -f $LOCK_FILE
            fi
        else
            echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
        fi
    else
        echo RabbitMQ is not running
        RETVAL=0
    fi
}

status_rabbitmq() {
    set +e
    if [ "$1" != "quiet" ] ; then
        $CONTROL status 2>&1
    else
        $CONTROL status > /dev/null 2>&1
    fi
    if [ $?!= 0 ] ; then
        RETVAL=3
    fi
    set -e
}

rotate_logs_rabbitmq() {
    set +e
    $CONTROL rotate_logs ${ROTATE_SUFFIX}
    if [ $?!= 0 ] ; then
        RETVAL=1
    fi
    set -e
}

restart_running_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        restart_rabbitmq
    else
        echo RabbitMQ is not runnning
        RETVAL=0
    fi
}

restart_rabbitmq() {
    stop_rabbitmq
    start_rabbitmq
}

case "$1" in
    start)
        echo -n "Starting $DESC: "
        start_rabbitmq
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        stop_rabbitmq
        echo "$NAME."
        ;;
    status)
        status_rabbitmq
        ;;
    rotate-logs)
        echo -n "Rotating log files for $DESC: "
        rotate_logs_rabbitmq
        ;;
    force-reload|reload|restart)
        echo -n "Restarting $DESC: "
        restart_rabbitmq
        echo "$NAME."
        ;;
    try-restart)
        echo -n "Restarting $DESC: "
        restart_running_rabbitmq
        echo "$NAME."
        ;;
    *)
        echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
        RETVAL=1
        ;;
esac

exit $RETVAL

Set permissions

chmod a+x /etc/init.d/rabbitmq-server

StartUp Actions Manager

chkconfig --add /etc/init.d/rabbitmq-server

Rabbitmq Sweatshirt: https://blog.csdn.net/qq_39135287/article/details/95725385

ZABBIX agent failed to start

1. Journalctl – Xe print job for zabbix-agent.service failed because a configured resource limit was exceeded

2. Journal CTL – Xe print PID… Not runnable

resolvent:

Check whether there is a folder named ZABBIX in the/run directory. If not, create a new one

# mkdir zabbix

Then start ZABBIX  
# systemctl start   zabbix-agent

# systemctl status zabbix-agent

Vscode compiles multiple files, compiles files in subfolders

Shame to say, in fact, for vscode configuration, the writer of C/C + + only referred to the tutorial, and then copied several JSON files, but did not understand the meaning.

For this problem, we need to solve the compilation problem, so in task.json, my configuration file is as follows

in which two parameters are command and args

Command: compiler for compilation args: command for compilation

As a matter of fact, it can be seen from the familiar partners of GCC. Here we post the parameter

so we need to connect our file names. The workspace in front represents the workspace, so we only need to write our own directory name at the back, as shown in the figure of linear_ List, connect them.

The Java command could not find or load the main class

1. First of all, to determine whether it is an environmental variable

If you input javac command and Java command in the command line, you can output a lot of things, which means that there is no problem in the configuration of environment variables. Otherwise, you need to configure environment variables

First, create a new Java_ The value of the home variable is the installation path of JDK. For example, my value is “D:// developtools/Java/JDK”. The contents in quotation marks, excluding quotation marks, are the same below.

Then add% Java after the path variable_ Home% \ bin “and% Java_ HOME%\jre\bin”

Create a new classpath variable with the value of “.”,% JAVA_ HOME%\lib;% JAVA_ HOME%\lib\tools.jar;”

The environment variables are configured.

2. If the path of the java file is correct, it is still reported that Java cannot find or load the main class, that is the problem of the package name. CMD locates in the SRC folder of the module, calls the Java command, and the bytecode file name is with the package name

That’s it