Tag Archives: The server

[Solved] Xshelln Connect to Local VM linux Error: Could not connect to ‘XXX.168.122.1‘ (port 22): Connection failed

The error is shown in the following picture:

Solution:

Method 1:

Restart VMware, xsehell!

The second method:

1. Start SSH

service sshd start

2. Set SSH to start automatically

chkconfigsshd on

Note: if there is no SSH, install SSH first, and then perform the previous steps 1 and 2

yum install openssh-server

Finally, we go to xshell to test the connection

nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) This is because port 80 can only be started by the root user, so just let the non-root user use port 80.

The solution is as follows:

# Set CAP_NET_BIND_SERVICE capability for the specified program
$ setcap cap_net_bind_service=+eip /path/to/application
The tests are as follows:
# sudo setcap cap_net_bind_service=+eip /usr/local/nginx/sbin/nginx

It’s OK to start nginx again.

/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf

[Solved] pymysql.err.OperationalError: (1045, “Access denied for user ‘root‘@‘192.168.118.44‘

Error: pymysql.err OperationalError: (1045, “Access denied for user ‘root’@‘192.168.118.44’ (using password: YES)”)

Possible problems:
1. Firewall blocking,
Solution: log in to the server and turn off the firewall

systemctl stop firewalld.service

2. User empowerment (the root user I use here)
Solution: log in to the MySQL database for empowerment

grant all privileges on *.* to 'root'@'%' identified by 'password';
flush privileges;

3. Check whether the password is entered incorrectly

[Solved] Nginx Restart Error: /run/nginx.pid failed (2: No such file or directory)

Nginx重启失败/run/nginx.pid failed (2: No such file or directory)

When deploying the project, an error is reported when restarting the nginx server after configuring the open port configuration

Go to the /run directory and find that there is no nginx.pid file.

Solution: enter etc/nginx/conf/nginx.conf file and modify the location of pid as below:

Disk Extended Error: WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

Error:

when formatting the partition of the Linux extended disk, if an error is reported:
warning: failed to re read the partition table, error 16: the device or resource is busy.

[root@ly host0]# fdisk /dev/sda -l

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

Solution:

Sync.
centos6
[root@ly ~]# partprobe /dev/sdb # centos6 has bugs that don't work well
[root@ly ~]# partx -a /dev/sdb # Add partition
[root@ly ~]# partx -d --nr 5-7 /dev/sdb # -d delete partition, --nr 6 specify range

centos5,7:
partprobe

 

[Solved] Linux Calls mmap Error: mmap: Invalid argument

Background

When using shared memory on Linux, the most common way is to use MMAP mapping file: a few days ago, when writing a program, there was an error in the execution of MMAP:

./test_mmap tmp.txt
mmap: Invalid argument

The procedure is as follows:

#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char **argv)
{
    int fd;
    struct stat sb;
    char *mmapped;

    if (argc != 2) {
        return -1;
    }

    fd = open(argv[1], O_RDWR);
    if(fd < 0) {
        perror("open");
        return -1;
    }

    if(fstat(fd, &sb) == -1) {
        perror("fstat");
        return -1;
    }

    mmapped = mmap(NULL, sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    if (mmapped == MAP_FAILED) {
        perror("mmap");
        return -1;
    }

    close(fd);

    mmapped[0] = '1';

    if(msync((void*)mmapped, sb.st_size, MS_SYNC) == -1) {
        perror("msync");
        return -1;
    }

    munmap((void *)mmapped, sb.st_size);

    return 0;
}

I have encountered this problem before, but I forgot what happened and took a little time to find the reason. In order to avoid repeating the mistakes, write an article and record it.

reason

On my environment, the reason for this error is that the mmap mapped file is not on the local machine! My Ubuntu is in a virtual machine, and the host is macOS. A folder on the host is shared to the virtual machine, and it is in this shared folder that the mmap file is in when I execute the program, so this strange error is reported.

[Solved] Internal error XFS_WANT_CORRUPTED_GOTO at line 1635 of file fs/xfs/libxfs/xfs_alloc.c.

Error Messages:

Internal error XFS_WANT_CORRUPTED_GOTO at line 1635 of file fs/xfs/libxfs/xfs_alloc.c. Caller xfs_free_extent

Internal error xfs_trans_cancel at line 990 of flie fs/xfs/xfs_trans.c.

xfs_repair: /dev/mapper/cl-root contains a mounted filesystem
xfs_repair: /dev/mapper/cl-root contains a mounted writable filesystem
fatal error – couldn’t initialize XFS library

 

Reason description:

I found that most of the solutions found on the Internet do not explain why, so we don’t know why, but just follow them. Some people may actually solve the problem of the partition of the system directory mount, while some people can’t solve the problem because it’s not the directory of the system mount.

The above error is mainly due to the problem of the file in the disk partition, so it needs to be repaired. But please check which partition of the attached directory has a problem first, and then repair the corresponding disk partition.

 

Solution:

1. First, after reporting the following errors, please check the information in the red box

You can see that you are asked to enter the root password, and then press enter to see that you have entered the root user, and you can enter the command

First, enter the following command first. df is to view the partition of the mounted directory, and cat /etc/fstab is to view the directory information of the previously persistent mounted partition. It can be seen (in the red box) that the directory attached to /book is gone, so it can be inferred that the partition /dev/sdb1 has a problem and needs to be repaired.

df -h
cat /etc/fstab

2. Next, you can repair it. Use the following command to repair it. If you do not add the L parameter, the following error will be reported:

Function of L parameter:

Add the L parameter to complete the execution

xfs_repair -L /dev/sdb1

Finally, restart with the following command to solve the problem

 init 6

Note: if you repair some partitions that are not damaged, the following error will be reported, so be sure to find the damaged partition that you need to repair, and then go to XFS_ repair

 

[Solved] MSYS2+ fatal error: zlib.h: There is no such file or directory

Operating environment: windows+msys2+vscode

A brief introduction to msys2

MSYS2 (Minimal SYStem 2) is a standalone rewrite of MSYS, mainly for shell command line development environments. It is also a Windows software that builds on Cygwin (POSIX compatibility layer) and MinGW-w64 (from “MinGW-generation”) for better interoperability.

Problem Description: fatal error: zlib.h: There is no such file or directory

There is an error message when executing the makefile file.

Fatal error: zlib.h: There is no such file or directory

After carefully checking the header file library, it is clear that this header file exists. And I ruled out the possibility of incorrect environment configuration.

Therefore, I open the GUI of msys2. Try other possible solutions.

Enter at the command line

pacman -Ss zlib

The explanation of this command is to find related resources with the keyword “zlib”.

The search result is

At first, the only modules that showed up as installed were msys/zlib 1.2.12-2 (libraries) and msys/perl 5.32.1-2 (base-devel).

I found that the last one felt quite like what I needed, after all, it was installed and not used at best, so I gave it a try, just in case it worked. So I’m going to install msys/zlib-devel 1.2.12-2 (development) as well!

Solution

The command to install msys/zlib-devel 1.2.12-2 (development) is:

pacman -S zlib-devel

Successfully solved the problem!

[Solved] prometheus Startup Error: opening storage failed

Modify prometheus.yml file and failed to start:

1. Configuring prometheus + node_exporter monitoring, the solution to the failure to start after modifying the prometheus.yml file.
2. Error message 1: err=”opening storage failed: lock DB directory: resource temporarily unavailable”

Solution: Check whether the current directory has generated files plus data/lock, need to delete the lock file: rm -rf lock
Delete and restart again

error message 2:err= “error starting web server: listen TCP 0.0.0:9090: bind: address ready in use”
installation command: yum install lsof -y
view command: lsof -i:9090
end command: kill -9 2878
restart command: ./prometheus
restart succeeded after operation

 

[Solved] Linux ECDSA key Error: Host key verification failed

Project scenario:

Under Linux Ubuntu system, use SCP command to transfer files from another server to this server.


Problem description

tips: describe the problems encountered in the project here:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:'A string of characters'.
Please contact your system administrator.
Add correct host key in /home/tonnn/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/tonnn/.ssh/known_hosts:12
ECDSA host key for 'External Server IP' has changed and you have requested strict checking.
Host key verification failed.

Cause analysis:

Tip: fill in the problem analysis here:

I found out after Google that the ECDSA key of the cloud server was changed because I reinstalled my Aliyun server system, and the ECDSA key left in /home/tonnn/.ssh/known_hosts on the target server was still the original ECDSA key, resulting in failed Host key verification.


Solution:

Clear the ECDSA key corresponding to the IP address in the target server /home/tonnn/.ssh/known_hosts, and then add a new one.
Use the ssh-keygen -R ip-address command, and go to the official website https://www.ssh.com/academy/ssh/keygen#command-and-option-summary to check out how-to-use, which means that the known_hosts file belongs to a host all the keys of the hostname are cleared.

After clearing, reconnect the corresponding host, and the server will record the new ecdsa key.

[Solved] ssh secure shell: server responded algorithm negotiation failed

ssh secure shell:server responded algorithm negotiation failed

This problem is usually solved as follows:
enter
1. cd /etc/ssh
2.vim /etc/ssh/sshd_config

# Add the following to the configuration file (except the last one of the third is gray plus purple, the others are blue, if it is gray means it is not right!)
Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc
 
MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,hmac-sha1-96,hmac-md5-96
 
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,[email protected]

Then restart sshd with this statement and you’re done
systemctl restart sshd

Because the error page can not be selected, so I did not directly check the error, but with their own understanding of the error to check, but wasted a lot of time, so if such an error, or hand typing in the future, it is very fast.

[Solved] svn: OPTIONS of ‘https://xxx/svn/xxx’: SSL handshake failed: SSL error: Key usage violation in certificate has been detected.

svn SSL handshake failed: SSL error

Use the SVN server for version management, and suddenly use the version browser to report an error. svn: OPTIONS of ‘ https://xxx/svn/xxx ’: SSL handshake failed: SSL error: Key usage violation in certificate has been detected. (https://xxx), Then you cannot export or import files

 

Solution:

1. My is win2012 32-bit English version system. First modify the registry and add a value
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VisualSVN\VisualSVN Server] "CreateGnuTLSCompatibleCertificate"=dword:00000001

2. VisualSVN Server Manager

Action -> Properties -> Certificate-> Change certificate, and then go to the next step

if it still doesn’t work, change the login method, check HTTPS and then http. Then log in and you can solve the problem