Tag Archives: linux

Memory error: cannot allocate memory [How to Solve]

1. Problem background

Start a process, and the process reports an error: cannot allocate memory

2. Cause of problem

Check the script of this process. It is found that the script needs to call the memory of the system kernel to start, but the current kernel memory is not allocated.

3. Troubleshooting

1. View the remaining memory of the current physical machine

free -m

2. View the number of processes in the current system

# The maximum number of processes allowed in the system
sysctl kernel.pid_max

# The maximum number of processes on the current host
ps -eLf | wc -l

3. View memory application and availability

cat /proc/meminfo | grep Commit

4. Solution

Unable to allocate kernel memory

sysctl overcommit_memory=1

[Solved] Springboot upload failed to find the temporary directory error

The springboot upload failed to find the temporary directory and reported an error

1. Problem description

According to the feedback of online users, the upload file function suddenly reported an error. After checking the log file, the error message is:
failed to parse multipart servlet request; nested exception is java.lang.RuntimeException: java.nio.file.NoSuchFileException: /tmp/undertow.8099.1610110889708131476/undertow1171565914461190366upload

2. Cause investigation

Originally, when launching the spring boot application through java - jar in the linux operating system, a temporary directory will be created by default in the /tmp directory (in Windows operating system, C:\users\default\appdata\ local\temp), and the temporary directory is generally in the format of undertow. Port.* (if the Tomcat container is Tomcat.Port.*, this article will take undertow as an example, and Tomcat is the same.) , files need to be converted into temporary files and stored here when uploading. However, if the files in the /tmp directory are not used for more than 10 days, they will be automatically cleaned up by the system. Therefore, the above problems do not occur in the directory when uploading again.

3. Problem recurrence

Since the temporary directory will be created automatically when the service is started, restart the service in the local or test environment, delete the undertow.Port.* (if Tomcat, it is Tomcat.Port.*) directory generated under /tmp , and upload the file again.

4. Solution

1. Manually create the temporary directory (not recommended)

mkdir -p /tmp/undertow.8099.1610110889708131476/undertow1171565914461190366upload

PS: if the file is not uploaded for more than 10 days again, the same problem will occur. The symptoms are not the root cause.

2. Modify Linux system configuration (not recommended)

vim /usr/lib/tmpfiles.d/tmp.con
# Add at the end of the file, which means that the folder at the beginning of undertow will not be cleaned up
x /tmp/undertow*

PS: if multiple servers are deployed, each server needs to be modified.

3. Modify spring boot configuration file (recommended)

spring:
  servlet:
    multipart:
      # Specify a custom upload directory
      location: /mnt/tmp

PS: when using this method, you must ensure that /MNT/tmp exists. If it does not exist, the same error will occur. Therefore, it needs to be judged every time the service is started. If the directory exists, it will be ignored, and if it does not exist, it will be created. The code is as follows:

@Slf4j
@Configuration
public class MultipartConfig {

    @Value("${spring.servlet.multipart.location}")
    private String fileTempDir;

    @Bean
    MultipartConfigElement multipartConfigElement() {
        String os = System.getProperty("os.name");
        // windows
        if(os.toLowerCase().startsWith("win")){
            fileTempDir = "C:" + fileTempDir;
        }
        log.info("fileTempDir:{}", fileTempDir);
        MultipartConfigFactory factory = new MultipartConfigFactory();
        File tmpDirFile = new File(fileTempDir);
        // Determine whether the folder exists
         if (!tmpDirFile.exists()) {
             //Create folder
            boolean mkdirSuccess = tmpDirFile.mkdirs();
            log.info("create temp dir,result:{}", mkdirSuccess);
        }
        factory.setLocation(fileTempDir);
        return factory.createMultipartConfig();
    }

}

Euopenler 21.09 sudo Yum Update Error: Errors during downloading metadata for repository ‘EPOL’

openEuler
openEuler-21.09-everything-x86_64-dvd.iso
sudo yum update error

EPOL
Errors during downloading metadata for repository 'EPOL':
	-Status code: 404 for htpp://repo.openeuler.org/openEuler-21.09/EPOL/repomd.xml

Please note that:

sudo vi/etc/yum.rest.d/openeuler.repo

Please note that

[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-21.09/EPOL/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.09/OS/$basearch/RPM-GPG-KEY-openEuler

The correct address is:

name=EPOL
baseurl= http://repo.openeuler.org/openEuler-21.09/EPOL/main/ $basearch/

Save, exit and execute again.

SCP path contains special characters Error [How to Solve]

Question

From a file on the local copy server, use the following command:

scp [email protected]:/home/test/files(202110~202111).xls .

Error reporting:
bash: – C: line 0: syntax error near unexpected token ` (‘

Solution:

    1. enclose the entire path in single quotation marks;
  1. before the parentheses, add the escape character
scp [email protected]:'/home/test/files\(202110~202111\).xls' .

The semget function error: errno is set to 28 [How to Solve]

When running semget under Linux to create semaphores, it returns – 1 and the creation fails;

1. This function is a system function. You can only confirm the actual error code with errno, print errno through strError, and return no space left on device. Is the system space insufficient? Insufficient space to create semaphores?

2. Go to errno. H to check the error message enospc corresponding to the actual error code. What does this field mean?

3. Does the semget function have its own error field? Check the function manual: check the man Manual of semget function: a semaphore set has to be created but the system limit for the maximum number of semaphore sets (semmni), or the system-wide maximum number of semaphores. Semaphore exceeds system limit.

It is basically determined that it is caused by the system semaphore. First, temporarily modify the kernel semaphore parameters and run again to see whether it has been solved.

4. The following commands are used in viewing semaphores

#1)The sysctl command can view and set system kernel parameters
# The 4 corresponding values from left to right are SEMMSL, SEMMNS, SEMOPM and SEMMNI.
sysctl -a | grep sem #View the setting value of the system semaphore
kernel.sem = 250 32000 32 128


#2) There are three ways to modify: the numbers are for reference only
echo 610 86620 100 142 > /proc/sys/kernel/sem

sysctl -w kernel.sem="610 86620 100 142"

echo "kernel.sem=610 86620 100 142" >> /etc/sysctl.conf`


#3) View the current semaphore and pid of the system as well as user information, view more information and check --help
ipcs -s -p -c


#4) Delete the semaphore method of the specified semid, and check more usage --help
ipcrm -s semid


#5) Delete all semid semaphore methods
ipcrm  -asem

5. Here, in the process of finding semaphore resource leakage, in order to facilitate real-time viewing of semaphore information, the semaphore output is written into the script and printed circularly

#ipcs.sh
echo “ipcs -s loop”

while [ 1 ]
do
	sleep 1
	ipcs -s
done

6. Note: the final problem here is to see why the semaphore in the code exceeds the limit. Normally, the semaphore will not exceed the system limit.

Apex library Install Error: amp not installed error [How to Solve]

Problem Description:

the apex library is missing and needs to be installed! Note: do not use PIP install apex. Although it can be installed successfully, it will still be found that there are errors when running the program in the end. It can’t be used

The specific installation steps are as follows:

# When you execute git to download the apex folder, if the download is too slow, you can manually enter the URL https://github.com/NVIDIA/apex to download and unzip and perform subsequent operations
git clone https://github.com/NVIDIA/apex
cd apex
python setup.py install

After execution, if the results shown in the figure below appear, the installation is successful

Remember to collect, in case you can’t find it next time
for my sake, please give me a compliment before you leave

[Solved] Win 10 VS Code Connect to the container of the server error: Cannot connect to the Docker daemon at … Is the docker daemon running

Background

After solving the installation of docker desktop above, I continue to operate according to the instructions of vs code plug-in remote container, in order to connect and edit the files in the container on the remote server (Linux) on the PC (Windows).

After everything is completed, the container is connected, but an error is reported. The log content is cannot connect to the docker daemon at http://docker.example.com. Is the docker daemon running. However, the docker desktop of my PC has already started docker, no problem.

After searching, I found that my account on the server is not in the docker group, that is, I need sudo to execute the docker instruction every time. The solution is to add my account to the docker group.

Solution:

Add according to the instructions on the official website, and then everything goes well and the problem is solved. The following code is a simple version, you can go directly to the official website.

cat /etc/group | grep docker # Print group information and filter with grep to view onlydocker
# If there are no results, run the following command to create a new docker group 
sudo groupadd docker 
# If the cat command yields results, then instead of creating a new group, just run the following command
sudo usermod -aG docker $USER # where $USER is replaced by your account name
newgrp docker # In Linux environment, make the group update take effect; other environments see the official website link
docker run hello-world # Check if docker can be executed without sudo

Post-installation steps for Linux | Docker Documentation

 

To access files in a remote server’s container with vs Code
1. Install VS code on PC
2. Connect to the server remotely: Find the Remote-SSH plug-in in the extension of VS code, configure the ssh file after installation, and connect to the server successfully
3. Find Remote-Container in the extension of VS code, install it, and then install docker and WSL2 software according to the extension’s introduction ( the link where the problem occurred above )
4. Connect to the server according to the introduction of Remote-Container (the problematic link in this article)

[Solved] Ubuntu 20.04 install MATLAB and toolbox permissions Error

1. Prompt for no access during installation
open the install file with sudo command, and remember to CD to the install directory

 sudo ./install

if the program is stuck and cannot be opened after entering the password, open the terminal and enter the following command

xhost +SI:localuser:root

2. Prompt for no access when installing the toolbox using the built-in add on
use Chmod to adjust file access rights

sudo chmod -R o+rw /usr/local/MATLAB/RXXXXx

after adjusting the permissions, you can download it, but an unexpected error appears at the end, which makes it impossible to install it
download the MATLAB installer again and reinstall it. Note that you don’t need to reinstall it all. Just select the toolbox you want

How to Solve insufficent privileges error: Ora-01031

For Oracle database in remote multi instance linux environment, an error is reported when executing conn/as SYSDBA: ora-01031: insufficient privileges. The solution process is as follows:

Step 1: find the sqlnet.ora file. Add the following two

SQLNET.AUTHENTICATION_SERVICES=(ALL)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)

Step 2: after saving, exit and execute lsnrctl reload

Step 3: the following errors occur after I finish executing:

TNS-12555: TNS:permission denied
 TNS-12560: TNS:protocol adapter error
  TNS-00525: Insufficient privilege for operation
   Linux Error: 1: Operation not permitted```


To solve this problem, execute: Chmod 777/var/TMP/.Oracle

Step 4: specify the connection instance. The orcl here should fill in your own instance name.

export ORACLE_SID=orcl

Step 5: when reconnecting, an error is reported connected to an idle instance.
. Note that this only means that the instance is not started, which is not a big problem. First query the status select status from V $instance

Step 6: start

startup

Since then.

docker-compose -version Run Error [How to Fix]

Question:

Start downloading

curl -L ” https://github.com/docker/compose/releases/download/1.25.0/docker-compose- $(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose

function

docker-compose –version

report errors

Cannot open self /usr/local/bin/docker-compose or archive /usr/local/bin/docker-compose.pkg

reason:

Find out that the downloaded files are missing due to the network

Solution:

Download the source file from GitHub on the local machine, and then upload it to the Linux server

Dbeaver startup error and dbeaver installation configuration

About the error “version 1.8.0 301 of the JVM is not suitable for this product. Version: 11 or greater is required.”

1. Download Windows 64 bit (zip) under community from the official website of dbaver, and download and unzip it directly

2. After decompression, open the directory file, find dbeaver.exe and create a shortcut

3. Right click the shortcut and properties, add – VM D:/bigdata/software/JDK/bin/javaw.exe after the “target” path, and click apply and OK.

Generally, after performing the above operations, you can normally open the dbeaver shortcut. But some computers still can’t be turned on for some reasons. I checked many methods on the Internet. In the configuration file of dbaver, insert two lines above – vmargs:

-vm

D:/bigdata/software/jdk/bin/javaw.exe

However, the error version 1.8.0 is still reported when dbeaver is started on my computer_ 301 of the JVM is not suitable for this product. Version: 11 or greater is required.

I tried many methods on the Internet and still couldn’t solve it. Finally, I accidentally found that I put it in the dbeaver configuration file

-vm

D:/bigdata/software/jdk/bin/javaw.exe

Insert it into the next two lines of – vmargs. After saving, create a new shortcut and repeat step 3.

be careful!!! Be sure to add these two lines under – vmargs

Synchronous update: error from dbeaver startup ➕ Installation configuration – brief book (Jianshu. Com)

How to Sovle expdp/impdp Data Pump Error

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at “SYS.UTL_FILE”, line 536
ORA-29283: invalid file operation

Cause: Oracle failed to read the default backup directory

Solution:

1. Recreate the logical directory with an administrator such as system (if you want to have the same name as the original logical directory, you need to delete the directory and recreate it first)

Create directory mydata as’ logical directory path ‘;

For example: create directory mydata as’/data/Oracle/mydata ‘;

Delete directory:   drop directory   mydata

2. Check whether the logical directory is created successfully

select * from dba_directories

3. Re expdp export or impdp import data. If the default logical directory used before needs to specify the directory

impdp system/ ddddd@orcl remap_schema=mydb:testdb   directory=mydata DUMPFILE=data1.dmp table_exists_action=replace