Tag Archives: linux

yum install Transaction Check Error

Transaction Check Error occurs when using Yum Install because of software conflicts. The following red part is the conflicting software. If it is installed by RPM, you can directly uninstall it by RPM and re-install yum Install.
. Total 39 kB/s | 5.0 MB 02:11

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Check Error:

the file/usr/share/man/man3/Bundle: : DBD: : mysql. 3 PM. Gz from the install of perl – DBD – mysql 3.0007-2. El5. X86_64 conflicts with the file from the package
Perl – DBD – MySQL 3.0007-2. El5. I386

Error Summary

Errno in Linux Programming

The original reference: http://mylinuxbook.com/error-handling-in-c-programming-on-linux/
This article mainly introduces the use of the global variable errno and related functions: Strerror (), strerror_r(), perror(). We can check the value of errno after calling a function to see what happens during the execution of the function. Here’s a simple example of trying to open a file that doesn’t exist read-only:

#include<stdio.h>
#include<errno.h>

int main(void)
{
    FILE *fd = NULL;

    // Reset errno to zero before calling fopen().
    errno = 0;

    // Lets open a file that does not exist   
    fd = fopen("Linux.txt","r");
    if(errno)
    {
        printf("\n fopen() failed: errno = %d\n", errno);
    }

    return 0;
}

The value of errno is set to 0 before the call of Fopen. After the call of Fopen (), we can check the value of errno to determine whether the file was successfully opened. The following is the result of execution:

fopen() failed: errno = 2
You can see that the fopen() function sets the value of errno to 2 to indicate that the file was not successfully opened. Then, errno is a number, and many times we need to see a more intuitive error message, which is strerror(), which converts the value of errno into a readable string, as shown in the following example:

#include<stdio.h>
#include<errno.h>
#include<string.h>

int main(void)
{
    FILE *fd = NULL;

    // Reset errno to zero before calling fopen().
    errno = 0;

    // Lets open a file that does not exist   
    fd = fopen("Linux.txt","r");
    if(errno)
    {
        // Use strerror to display the error string
        printf("\nThe function fopen failed due to : [%s]\n",(char*)strerror(errno));  //#1
        return -1;
    }

    return 0;
}

The output results of the program are as follows:

The function fopen failed due to: [No to The file or directory]
so we can directly see what has gone wrong, but The strerror () there is a problem, is The strerror () returns The string stored in a public area, i.e., said that if other threads also calls The function, and introduced into a different errno values, The string will be overwritten. To solve this problem, with strerro_r(), the function takes a BUF as an argument and stores the string in that BUF. Perror () also appears to output a readable error message, except that it is printed out to Stderr, and perror() replaces the output statement #1 in the above code, as follows:

perror("The function fopen failed due to");

The output page is similar:

The function fopen failed due to: No such file or directory

One thing to note: Perror does not take errno as a parameter, but instead reads the value of errno internally.

Putty network error: software caused connection abort

After installing Putty today, open and run the general prompt for some time

This error is due to the fact that some network routers and firewalls need to track all connections through them. Typically, these firewalls assume that the connection has failed if no data is moving in either direction after an interval. If there is no traffic for a period of time in the session, this can cause the PuTTY session to be unexpectedly shut down by a firewall. To solve this problem, you can configure PuTTY to send empty packets every few seconds and keep TCP active.
The methods are as follows:
Now, click Open to leave the SSH connection idle for a while and see if it remains the same. If you’re using a PuTTY session profile, don’t forget to save your profile with these new Settings. The Settings are as follows:

That will do.

What should be paid attention to in socket programming — bind socket error: address already in use

When programming Linux networks, you often encounter the following usage errors every time you modify the source code and compile it again:

Bind error: Address already in use

Although the process was forced to end with Ctrl+C, the error still exists. We can still see the process “forced to end” with Ctrl+C with netstat -an |grep 5120 and ps aux |grep 5120. The port is still in use, so we have to kill the process with kill every time, which is very troublesome. Last night, I happened to browse an article titled “5 Hidden Dangers in Linux Socket Programming” on THE IBM website. I suddenly realized that I had a try today and solved the problem as expected. I hereby express my thanks and hope that more coder can read this article and avoid making mistakes.

The main codes are:

int on;

on = 1;
ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, & on, sizeof(on) );
now every time I force the process to end with Ctrl+C, I can still see the port in use with netstat and ps, but the running program will not have the error of “Address already in use”, so the port is reused.

 

Here is the third pitfall in this article — incorrect address usage

Address usage error (EADDRINUSE)

You can use the Bind API function to bind an address (an interface and a port) to a socket endpoint. You can use this function in your server Settings to limit the interfaces that may have a connection coming. You can also use this function in client Settings to limit the interfaces that should be used for outgoing connections. The most common use of BIND is to associate a port number with a server and use a wildcard address (INADDR_ANY), which allows any interface to be used for incoming connections.

A common problem with BIND is trying to bind to a port that is already in use. The trap is that no active socket may exist, but the binding port is still disabled (bind returns EADDRINUSE), which is caused by the TCP socket state TIME_WAIT. This state remains for about 2 to 4 minutes after the socket is closed. After the TIME_WAIT state exits, the socket is deleted and the address can be rebound without problems.

Waiting for TIME_WAIT to end can be annoying, especially if you’re developing a socket server and need to stop the server to make some changes, and then restart. Fortunately, there is a way to get around the TIME_WAIT state. You can apply the SO_REUSEADDR socket option to the socket so that the port can be reused immediately.

Consider the example in Listing 3. Before binding the address, I call setsockopt with the SO_REUSEADDR option. To allow address reuse, I set the integer parameter (on) to 1 (otherwise, I can set it to 0 to prohibit address reuse).

use the SO_REUSEADDR socket option to avoid address usage errors

 

int sock, ret, on;
struct sockaddr_in servaddr;
/* Create a new stream (TCP) socket */
sock = socket( AF_INET, SOCK_STREAM, 0 ):
/* Enable address reuse */
on = 1;
ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, & on, sizeof(on) );
/* Allow connections to port 8080 from any available interface */
memset( & servaddr, 0, sizeof(servaddr) );
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl( INADDR_ANY );
servaddr.sin_port = htons( 45000 );
/* Bind to the address (interface/port) */
ret = bind( sock, (struct sockaddr *)& servaddr, sizeof(servaddr) );
after the SO_REUSEADDR option is applied, the bind API function allows immediate reuse of the address.

 

Five pitfalls in Linux socket programming
http://www.ibm.com/developerworks/cn/linux/l-sockpit/

Putty prompt network error: software caused connection abort solution

Cause Connection Abort. Network error software causes Connection abort
Here’s how to resolve a puTTY connection outage:
1. Setting on the Linux server:
vi /etc/ssh/sshd_config
Find TCPKeepAlive Yes and remove the previous #
Find the ClientAliveInterval parameter and remove the previous #
ClientAliveInterval 60 Changes the following 0 to 60
ClientAliveInterval specifies how long it takes the server to request a message from the client. The default is 0 and no message is sent. ClientAliveInterval 60 means once a minute and then the client responds, which keeps the connection long. The oddity here is that instead of the client initiating the request to stay connected (FTerm, CTerm, etc.), the server is required to initiate the request first.
In addition, for ClientAliveCountMax, the default value is 3. ClientAliveCountMax means that when the server makes a request and the client does not respond to it a certain number of times, the client automatically disconnects. Under normal circumstances, the client will not fail to respond.
2. Putty client Settings:
In the Connection, there are Seconds between Keepaliaves, in which an empty packet is sent to the server to keep the Connection alive. In case the logged in host does not receive the data for a long time, it will automatically disconnect the SSH connection

In the figure above, the default input 0 is to disable keeping a connection, in this case I’m used to setting 60. Both check boxes remain selected by default.
From: https://blog.csdn.net/xiaobaoroy/article/details/51556320

CHECK_NRPE: Error – Could not complete SSL handshake.

Question:
[root @ mode objects] #/usr/local/nagios/libexec/172.30.71.238 check_nrpe – H – c check_load check_nrpe: Error – Could not complete the SSL handshake.

Solutions:
There are many reasons for this problem, and the aspects to consider are very broad
First of all:
Troubleshooting client:
First: VI NRPE.cfg

command[check_load]=/usr/local/nagios/libexec/check_load -w 15.10.5 -c 30.25.20
command[check_mem]=/usr/local/nagios/libexec/check_mem.pl -w 10% -c 3%
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 15% -c 7% -p /
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_iostat]=/usr/local/nagios/libexec/check_iostat -w 6 -c 10

Using these commands on the client side to monitor the information on the client side,

If successful, this means that there is no problem with the client configuration. Generally speaking, there is no problem here, but there is no exception. The following two are client-side
If the client problem is fixed and not fixed, the next step is to troubleshoot
Information about the server that is contained in the client configuration file
Such as: vi nrpe. CFG
Allowed_hosts = 172.30.71.20, 172.30.71.238
Add server IP, separated by English commas, no Spaces left or right of equal sign

Also, the check_NRPE plugin is not defined causing, of course, the Nagios server syntax check to error if it is not defined

Check grammar:
/etc/init.d/nagios checkconfig
Error message will be found:
Checking services…
Error: Service check Command ‘check_NRpe’ specified in Service ‘Swap Useage’ for host ‘197-etiantian-1-1’ not
defined anywhere!
Omit some.
Total Warnings: 0
Total Errors: 5
Check_nrpe’s plug-in configuration (server side) needs to be added to commands.cfg
CFG enters and shifts +g to the end to add the following.
# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
At this point, re-execute the syntax check command:
Check grammar:
/etc/init.d/nagios checkconfig
Total Warnings: 0
Total Errors: 0
There are also some screening sites

1. Make sure that the versions of check_NRpe and nrPE daemon are the same.
RPMS — qa|grep openssl view
2. Verify that the check_nrpe and nrpe deamon sides enable or disable SSL support at the same time.
/ usr/local/nagios/bin/nrpe c/usr/local/nagios/etc/nrpe. The CFG – d – n
-n stands for not using SSL. To start SSL, start both sides; If you don’t start it, both sides will close; You cannot start and close at the same time
In this way

Linux GCC compilation error: “collect2: LD returned 1 exit status”

bmeta_info.cpp:4280: undefined reference to ‘crypt’
collect2: ld returned 1 exit status
Information found online shows:

Undefined reference to error: this type of error is in the process of connection, there may be two reasons: one is the user to define a function or global variable in a source code file that is not compile, link, or simply has not been defined, it requires the user to modify source program according to the practical situation, presents the definition of a global variable or function body; The second is that the undefined symbol is a standard library function, which is used in the source program, and the corresponding library name is not given during the connection process, or the directory name of the archive has a problem

Use the Man crypt command to find the following information:

GNU EXTENSION
       The glibc2 version of this function has the following additional features.  If salt is a character string starting with the three characters "$1$" followed by at most eight characters, and optionally terminated by "$", then instead of using  the  DES  machine, the  glibc crypt function uses an MD5-based algorithm, and outputs up to 34 bytes, namely "$1$<string>$", where "<string>" stands for the up to 8 characters following "$1$" in the salt, followed by 22 bytes chosen from the set [a–zA–Z0–9./].  The entire key is significant here (instead of only the first 8 bytes).
       Programs using this function must be linked with -lcrypt.

Program using this function must be linked with -lcrypt. The program must be linked with -lcrypt
Reference: [http://blog.sina.com.cn/s/blog_64c238860100wzoo.html]

Solution to prompt “error opening terminal: xterm.” when making menuconfig

The solution to make Menuconfig is to prompt “Error opening terminal: xterm.

Under Linux environment, make menuconfig or make config commands are used when compiling embedded systems. These commands usually use the ncurses library. If the ncurses library is not installed and set correctly, the following Error message may appear:
Error opening terminal: xterm

Solutions:

1. First make sure that the ncurses library is installed correctly. On debian, Ubuntu, you can use dpkg-l | grep ncurses to see if the ncurses library is installed.
2. If ncurses is already installed, check to see if the TERM and TERMINFO environment variables have been set correctly. If it is not set correctly, you need to set it to the correct value.
$ echo $TERM
$ echo $TERMINFO

For TERMINFO, the path to TERMINFO should be set, such as /usr/share/ TERMINFO or /lib/ TERMINFO. To view Terminfo's storage location with the following instruction:

$whereis terminfo
terminfo: /etc/terminfo /lib/terminfo /usr/share/terminfo /usr/share/man/man5/terminfo.5.gz

See if the terminal information file is saved in the Terminfo directory: It is usually divided into A, B, C, D... Z these alphabetic directories, each containing term information beginning with that letter. For example, vT100 is placed in the "V" directory. The term we need must have the term information in the corresponding directory. Once you have identified this information, you can set the TERM and TERMINFO information:

export TERM=xterm
export TERMINFO=/lib/terminfo

The Settings above, must ensure that the/usr/share/terminfo term existing in the information, and/usr/share/terminfo/v/vt100 exists.
Regarding the setting of terms, it may need to be set to different terms such as Linux, VT100-putty, etc. Linux is commonly used for the Linux console, and vT100-putty is, as the name implies, a VT100 terminal that USES PuTTY to log in remotely.
The following are the values of the TERM and TERMINFO environment variables in the Ubuntu12.10 environment after the problem is resolved.

$ echo $TERM
xterm
$ echo $TERMINFO
/lib/terminfo/

The solution to the error of / etc / sudoers: syntax error in sudoer file under mac

In recent days, I tried to configure sudo for passwordless operation, which smashed the sudoers file and reported the following error

/etc/sudoers: syntax error near line 59 <<<
sudo: parse error in /etc/sudoers near line 59
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Search the Internet and jot down solutions

pkexec visudo

pkexec function is to execute the command as root, it doesn't seem to work on MAC, but ~ ~, I will update the solution later
 
MAC solution:
open /etc directory with folder, right-click -> Show introduction

Undid the bottom right?”, and then change the everyone permission to read and write to be able to modify the sudoers file freely

Cannot connect to MySQL server on “host” (113)

Connection to remote MySQL error:
ERROR 2003 (HY000): Can’t connect to MySQL Server ‘IP’ (113)
View error types (Linux system)

perror 113

The results are as follows:
OS error code 113: No route to host
The reason for this error is that the server-side firewall does not open the port used by the MySQL program. By default, it is 3306 and the open port is ok

/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT 

Save the Settings and restart the firewall

service iptables save
service iptables restart

Error 1364 (HY000): field ‘SSL_ cipher’ doesn’t have a default value

When creating a user in mysql today, you can see how to insert data directly into the User table when someone is using it, as follows:

mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));

So I also tried to create users with this method in the database, but got the following error:

mysql> insert into mysql.user(Host,User,Password) values('localhost','siu',password('siu'));       
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

The reason for this error is that mysql’s default configuration is strict mode, which prohibits adding new users by directly modifying the USER table in the mysql library by INSERT.
solution is to modify my. Ini (Windows system) or my. Conf (Linux system) configuration file, taking Linux system as an example:

sql-mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Modified to:

sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Then restart the mysql service

service mysql restart

Create the user again and it will be successful

mysql> insert into mysql.user(Host,User,Password) values("localhost","joey",password("1234"));    
Query OK, 1 row affected, 3 warnings (0.00 sec)

It is important to note, however, that since mysql by default forbids this method to create users for database security, we should also avoid creating users by inserting. The correct way to create a user is:

mysql> create user 'joey'@'localhost' identified by 'joey';
Query OK, 0 rows affected (0.00 sec)

This user is then authorized for certain databases:

grant all privileges on joey.* to 'joey'@'localhost' identified by 'joey'; 
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)