Category Archives: Linux

Virtual machine failed to start network service error: ob for network.service failed because the control process exited with error code

About CentOS 7 virtual machine startup network service startup failure: ob for network service failed because the control process exited with error code

As shown in the following figure:

Question:

When using CentOS 7 system, after changing the static IP, it is found that the network service cannot be restarted, and after using the IP addr or ipconfig command, it is found that the changed static IP address is not displayed and mysteriously disappears. The connection to the external network is also different, and the Ping is blocked.

Error reason:

There is a conflict between NetworkManager and Network, there are two network management tools on CentOS system, NetworkManager and Network, if both of them are configured, it will cause a conflict between them. As we usually use Network to configure our virtual machine static ip address, but sometimes our improper operation will cause NetworkManager to configure automatically, so there is a conflict between the two. Possible reasons for this are: we shut down the virtual machine without shutting it down first or we don’t use the poweroff command to shut down the machine.

Solution:

Just turn off the NetworkManager service directly, that is, carry out the following steps:
solution 1:
①, service NetworkManager stop # turn off the NetworkManager service
②, chkconfig NetworkManager off # prohibit startup
③ restart the system

solution 2:
② Choose one of the following commands: (a temporary modification, a permanent modification)
systemctl stop networkmanager # temporarily close the service
systemctl disable networkmanager # permanently close the service
② restart the system

 

[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 kernel load driver Error: module verification failed: signature and/or required key missing – tainting kernel

#insmod xx. ko

The following error reports

Cause of problem:

Since the 3.7 kernel, there has been a kernel signature mechanism.

When compiling the kernel, The options related to kernel signature in .config are as follows:

CONFIG_MODULE_SIG=y
CONFIG_MODULE_SIG_ALL=y

1. There is a method to sign Ko

/usr/src/linux-4.9.61/scripts/sign-file sha512 /usr/src/linux-4.9.61/certs/signing_key.pem /usr/src/linux-4.9.61/certs/signing_key.x509 hello.ko

 

2. The second method is to disable signing

Add it to your Makefile:

CONFIG_MODULE_SIG=n

[Solved] fatal error: jemalloc/jemalloc.h: No such file or directory

In the Linux system, sometimes when compiling and installing software, it will prompt: /bin/sh: cc: command not found, indicating that there is no gcc environment for compiling the code. Generally, we will install gcc first. The command is as follows:

yum -y install gcc gcc-c++

After installing gcc, continue to compile and install the original software, the error is as follows:

In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
#include <jemalloc/jemalloc.h>
^
compilation terminated.

The reason for the error is because the last compilation failed, there are residual files, we need to clean it up, and then recompile it.

Solution:

make distclean && make

[Solved] Fluent error: invalid command [initialize-flow

Fluent error reporting record

1. invalid command [initialize-flow

. Two files are needed to calculate fluent on the cluster, *.jou and *.cas;
In *.jou, you can input and output file information and execute commands

/file/read-case *.cas
/solve/initialize/initialize-flow 
/solve/iterate 10000
/file/write-data out.dat
exit
yes

Job script, take LSF as an example *.lsf:

#!/bin/sh
APP_NAME=fluent
NP=12
NP_PER_NODE=12
RUN="fluent 3d -g -i input.jou"

Error 1 after submission:

Solution: Check the format of input.jou file, type: set ff after vim, see whether the file is in dos format or unix format, the problem I encountered on my side was caused by the wrong format, and the calculation was normal after changing to unix format.

[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.

How to Solve dyn_small_obs_avoidance Compile Error (eigen version Issue)

Problem description

While Compiling dyn_small_obs_avoidance, catkin_make report an error:

/home/xcs/catkin_ws_dyn/src/dyn_small_obs_avoidance/path_searching/src/kinodynamic_astar.cpp:919:61: error: ‘const class Eigen::ArrayWrapper<const Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<double>, const Eigen::Matrix<double, 3, 1>, const Eigen::Matrix<double, 3, 1> > > >’ has no member named ‘floor’
   Vector3i idx = ((pt - origin_) * inv_resolution_).array().floor().cast<int>();
                                                             ^~~~~
/home/xcs/catkin_ws_dyn/src/dyn_small_obs_avoidance/path_searching/src/kinodynamic_astar.cpp:919:74: error: expected primary-expression before ‘int’
   Vector3i idx = ((pt - origin_) * inv_resolution_).array().floor().cast<int>();
   dyn_small_obs_avoidance/path_searching/CMakeFiles/path_searching.dir/build.make:62: recipe for target 'dyn_small_obs_avoidance/path_searching/CMakeFiles/path_searching.dir/src/kinodynamic_astar.cpp.o' failed
make[2]: *** [dyn_small_obs_avoidance/path_searching/CMakeFiles/path_searching.dir/src/kinodynamic_astar.cpp.o] Error 1
CMakeFiles/Makefile2:1260: recipe for target 'dyn_small_obs_avoidance/path_searching/CMakeFiles/path_searching.dir/all' failed
make[1]: *** [dyn_small_obs_avoidance/path_searching/CMakeFiles/path_searching.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed                                                 

Cause analysis:

By modifying the location where the error occurs, it is found that the error still exists, and the judgment error has nothing to do with the code itself
referring to other posts, I found that the previously installed version of eigen is eigen3.2.1, which may be too low
try upgrading the eigen version.


Solution:

1. Uninstall the  eigen

sudo updatedb  
locate eigen3 
sudo rm -rf /usr/include/eigen3 /usr/lib/cmake/eigen3 /usr/share/doc/libeigen3-dev /usr/share/pkgconfig/eigen3.pc /var/lib/dpkg/info/libeigen3-dev.list /var/lib/dpkg/info/libeigen3-dev.md5sums

2. Installation dependency

sudo apt-get install libopenblas-dev
sudo apt-get install --no-install-recommends libboost1.58-all-dev
sudo apt-get install libx11-dev
sudo apt-get install libgl1-mesa-dev 
sudo apt-get install libglu1-mesa-dev 
sudo apt-get install freeglut3-dev
sudo apt-get install doxygen
sudo apt-get install cmake
sudo wget https://nchc.dl.sourceforge.net/project/glew/glew/2.1.0/glew-2.1.0.tgz --no-check-certificate
sudo tar -xzvf glew-2.1.0.tgz
cd glew-2.1.0/
sudo make 
sudo make install
sudo ldconfig -v

Some may not be installed. I will ignore them and continue with the following steps.

3. Download eigen3.3.7, and extract it to the home directory
download address: eigen3.3.7

4. Installing eigen3.3.7

mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig -v

5. Map the path of eigen3 to the /usr/include path.

sudo cp -r /usr/local/include/eigen3 /usr/include/eigen3 
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen

6. Re-enter dyn_small_obs_avoidance workspace catkin_make, compiled successfully.

[ 79%] Building CXX object dyn_small_obs_avoidance/path_planning/CMakeFiles/goal_transform.dir/src/goalpoint_transformer.cpp.o
[ 81%] Building CXX object dyn_small_obs_avoidance/path_planning/CMakeFiles/path_planning_node.dir/src/path_planning.cpp.o
[ 93%] Built target livox_ros_driver_node
[ 95%] Linking CXX executable /home/xcs/catkin_ws_dyn/devel/lib/path_planning/goal_transform
[ 95%] Built target goal_transform
[ 97%] Linking CXX executable /home/xcs/catkin_ws_dyn/devel/lib/path_planning/path_planning_node
[ 97%] Built target path_planning_node
[100%] Linking CXX executable /home/xcs/catkin_ws_dyn/devel/lib/fast_lio/loam_laserMapping

[Solved] Ubuntu18.04 Px4 (xtdrone) gazebo joint simulate error

Ubuntu 18.04 installs gazebo9.0 by default and starts indoor1 of Px4 Launch will report an error:

gzserver: symbol lookup error: /usr/lib/x86_64-linux-gnu/libsdformat.so.4: undefined symbol: _ZN8igniti

The reason is that the version of gazebo 9.0 is too low and needs to be upgraded to 9.13, 9.14 or 9.15 (I can use it when upgrading to 9.19) Upgrade method:

1 Uninstall the original gazebo
sudo apt-get remove gazebo* 
sudo apt-get remove libgazebo*
sudo apt-get remove ros-melodic-gazebo* #kinetic noetic Corresponding changes
2 Set up the computer to accept software from package.osrfoundation.org
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
cat /etc/apt/sources.list.d/gazebo-stable.list
#If deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main appears, it means no problem
xenial should be 20.04 18.04 for bio
3 Set the key
wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update
4 Install gazebo9.1 command.
sudo apt-get install gazebo9=9.1*
//If after executing the commands sudo apt install ros-melodic-gazebo9-* sudo apt install ros-melodic-gazebo-*, gazebo starts with an error like symbol (e.g. gzserver: symbol lookup error: /usr/lib/x86_64-linux-gnu/libsdformat.so.4: undefined symbol: _ZN8igniti). You can solve this problem by running sudo apt upgrade libignition-math2 first
5 sudo apt upgrade libignition-math2
If you type gazebo in the terminal after installation, Gazebo will open and the installation will be successful.
6 Gazebo itself is independent of ROS, so you need to install the Gazebo plugin for ROS
sudo apt install ros-melodic-gazebo9-*
sudo apt install ros-melodic-gazebo-*

[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

 

[ERROR SystemVerification]: failed to parse kernel config: unable to load kernel module: “configs“

[ERROR SystemVerification]: failed to parse kernel config: unable to load kernel module: “configs“

[error systemverification]: failed to parse kernel config: unable to load kernel module: “configs”.

When installing kubernetes cluster, the above error is reported.

 

Solution:

Method 1: ignore the error

Add the –ignore-preflight-errors=SystemVerification option to ignore the error. It is not possible to tell if other problems will occur subsequently with this option.

Method 2: Upgrade kernel version

I installed the kubernetes cluster using kernel version 4.19.12, and the problem did not occur after upgrading the kernel to 5.13.7. I am not sure if it is a kernel version problem.

Method 3:

Manually compile the config kernel module

 

Failed to Initialize Error: error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR Port-6443]

[root@k8s-master01 ~]# kubeadm init --config=kubeadm-config.yaml --experimental-upload-certs | tee kubeadm-init.log
Flag --experimental-upload-certs has been deprecated, use --upload-certs instead
[init] Using Kubernetes version: v1.15.1
[preflight] Running pre-flight checks
    [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.11. Latest validated version: 18.09
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR Port-6443]: Port 6443 is in use
    [ERROR Port-10251]: Port 10251 is in use
    [ERROR Port-10252]: Port 10252 is in use
    [ERROR FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml]: /etc/kubernetes/manifests/kube-apiserver.yaml already exists
    [ERROR FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml]: /etc/kubernetes/manifests/kube-controller-manager.yaml already exists
    [ERROR FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml]: /etc/kubernetes/manifests/kube-scheduler.yaml already exists
    [ERROR FileAvailable--etc-kubernetes-manifests-etcd.yaml]: /etc/kubernetes/manifests/etcd.yaml already exists
    [ERROR Port-10250]: Port 10250 is in use
    [ERROR Port-2379]: Port 2379 is in use
    [ERROR Port-2380]: Port 2380 is in use
    [ERROR DirAvailable--var-lib-etcd]: /var/lib/etcd is not empty
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
Reason:
Restart kubeadm after modifying the kubeadm-config.yaml file, otherwise the port from the previous startup is occupied.
Solution:
Result test:
The k8s cluster was initialized successfully.
[root@master1 ~]# kubeadm init –config kubeadm-config.yaml –ignore-preflight-errors=SystemVerific