Tag Archives: Linux

Tomcat running under Linux reports an error broken pipe

linux tomcat run error Broken pipe

It is possible that linux’s threading mechanism can generate JVM errors, especially during connection peaks often appear such problems, tomcat in linux also appear similar situations.
The solution is to set: _JAVA_SR_SIGNUM = 12 in the environment variable and you can basically solve it.In WIN environment variable set: _JAVA_SR_SIGNUM=12, if Linux with export _JAVA_SR_SIGNUM=12, basically you can solve.
sun’s explanation.
--posted by: cooper
Below is a clipping from Sun on working around JVM crashes under high
thread counts in the JVM 1.3 for Linux
On Linux, use a larger signal number for hotspot thread
suspension/resumption handler. The signal number being used is
specified by environment variable _JAVA_SR_SIGNUM. Setting it to a
number larger than SIGSEGV (11) will solve the PRoblem. A good number
to use is 12, which is SIGUSR2. Using signal 16 to work around the
problem might have potential problems. So on tcsh, “setenv
_JAVA_SR_SIGNUM 12” can solve the problem.

 

Linux Error: missing argument to `-exec’ [How to Solve]

When using the find command under linux, an error is reported: find: missing argument to `-exec’

The specific execution command is:

Shell code Collection code
find /u03 -name server.xml -exec grep ‘9080’ {}\;
The purpose is to find the file named server.xml in the /u03 directory, perform a grep search according to the search results, and search for text containing 9080.

The syntax format of -exec is:

Shell code Collection code
-exec command {} \;
There must be a space between {} and \, otherwise the above error will be reported.

Re-execute the command after adding a space:

Shell code Collection code
find /u03 -name server.xml -exec grep ‘9080’ {} \;

Error in compiling APR util for Linux

Foreword

The version after Apache 2.4 no longer comes with its own APR Library (APACHE portable runtime), so you need to manually download and install the APR library before installing Apache

The complete APR actually contains three dependent packages: Apr, APR util, and APR icon v

 

Text

The APR util package is downloaded on the official website and executed after decompression   make   During compilation, the following errors are reported:

[root@mingc apr-util-1.6.0]# make
make[1]: Entering directory `/usr/local/src/apr-util-1.6.0'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/usr/local/src/apr-util-1.6.0/include -I/usr/local/src/apr-util-1.6.0/include/private  -I/usr/local/apr/include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: error: expat.h: No such file or directory
xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’
xml/apr_xml.c: In function ‘cleanup_parser’:
xml/apr_xml.c:364: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:365: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: At top level:
xml/apr_xml.c:384: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
xml/apr_xml.c: In function ‘apr_xml_parser_create’:
xml/apr_xml.c:401: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:402: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:410: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:411: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:412: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:424: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:424: error: ‘default_handler’ undeclared (first use in this function)
xml/apr_xml.c:424: error: (Each undeclared identifier is reported only once
xml/apr_xml.c:424: error: for each function it appears in.)
xml/apr_xml.c: In function ‘do_parse’:
xml/apr_xml.c:434: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:438: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: In function ‘apr_xml_parser_geterror’:
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/usr/local/src/apr-util-1.6.0'
make: *** [all-recursive] Error 1

Generally speaking, there is a lack of XML parser. After consulting the network data, we found a solution. Just install a expat devel package using Yum:

[root@mingc apr-util-1.6.0]# yum -y install expat-devel

  

Reference link: Lamp deployment

Related links: Apache installation, APR and APR util functions

Linux: How to Check the Status of Page

Recently, we encountered a problem of page release exception. The stack is as follows:

[ 1000.691858] BUG: Bad page state in process server.o  pfn:309d22
[ 1000.691859] page:ffffea000c274880 count:0 mapcount:0 mapping:ffff880279688308 index:0x0
[ 1000.691860] page flags: 0x2fffff00020000(mappedtodisk)
[ 1000.691862] page dumped because: non-NULL mapping
[ 1000.691863] Modules linked in: stap_11fa48f04897d7244c07086623507d9_14185(OE) xfs libcrc32c tcp_diag inet_diag xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter bridge stp llc dm_mirror dm_region_hash dm_log dm_mod intel_powerclamp snd_hda_intel coretemp ppdev kvm_intel snd_hda_codec snd_hda_core iTCO_wdt gpio_ich iTCO_vendor_support snd_hwdep ioatdma snd_seq parport_pc kvm shpchp parport nfsd snd_seq_device snd_pcm pcspkr sg irqbypass ntb i2c_i801 snd_timer intel_ips snd lpc_ich soundcore auth_rpcgss nfs_acl lockd grace sunrpc ip_tables ext4 mbcache jbd2 sd_mod crc_t10dif crct10dif_generic crct10dif_common
[ 1000.691895]  amdkfd amd_iommu_v2 radeon i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm ixgbe ahci libahci libata tg3 mdio crc32c_intel dca serio_raw ptp i2c_core pps_core fjes floppy [last unloaded: stap_be77ad5fa9d5c22c253e09b1d6390ba4__1921]
[ 1000.691908] CPU: 3 PID: 29178 Comm: server.o Tainted: G    B      OE  ------------   3.10.0+ #10
[ 1000.691910] Hardware name: To be filled by O.E.M. To be filled by O.E.M./To be filled by O.E.M., BIOS 4.6.3 01/14/2011
[ 1000.691911]  ffffea000c274880 000000001df7af73 ffff88050ee37d08 ffffffff81688527
[ 1000.691913]  ffff88050ee37d30 ffffffff81683751 ffffea000c274880 0000000000000000
[ 1000.691915]  000fffff00000000 ffff88050ee37d78 ffffffff81188d6d fff00000fe000000
[ 1000.691918] Call Trace:
[ 1000.691920]  [<ffffffff81688527>] dump_stack+0x19/0x1b
[ 1000.691922]  [<ffffffff81683751>] bad_page.part.75+0xdf/0xfc
[ 1000.691925]  [<ffffffff81188d6d>] free_pages_prepare+0x16d/0x190
[ 1000.691927]  [<ffffffff811897e4>] free_hot_cold_page+0x74/0x160
[ 1000.691930]  [<ffffffff8118e6a3>] __put_single_page+0x23/0x30
[ 1000.691932]  [<ffffffff8118e6f5>] put_page+0x45/0x60
[ 1000.691934]  [<ffffffff8122cd25>] page_cache_pipe_buf_release+0x15/0x20
[ 1000.691937]  [<ffffffff8122d7a4>] splice_direct_to_actor+0x134/0x200
[ 1000.691940]  [<ffffffff8122d9f0>] ?do_splice_from+0xf0/0xf0
[ 1000.691942]  [<ffffffff8122d8d2>] do_splice_direct+0x62/0x90
[ 1000.691944]  [<ffffffff811fe7c8>] do_sendfile+0x1d8/0x3c0
[ 1000.691947]  [<ffffffff811ffb2e>] SyS_sendfile64+0x5e/0xb0
[ 1000.691949]  [<ffffffff81698b49>] system_call_fastpath+0x16/0x1b
[ 1000.691951] BUG: Bad page state in process server.o  pfn:309d23

It can be seen that the reason for page release failure is: non null mapping, that is, when releasing, page – > Mapping is not null. Let’s look at the check function

static inline int free_pages_check(struct page *page)
{
    char *bad_reason = NULL;
    unsigned long bad_flags = 0;

    if (unlikely(page_mapcount(page)))
        bad_reason = "nonzero mapcount";
    if (unlikely(page->mapping != NULL))-------------------The mapping of the page is not NULL and is considered an exception.
        bad_reason = "non-NULL mapping";
    if (unlikely(page_ref_count(page) != 0))
        bad_reason = "nonzero _count";
    if (unlikely(page->flags & PAGE_FLAGS_CHECK_AT_FREE)) {
        bad_reason = "PAGE_FLAGS_CHECK_AT_FREE flag(s) set";
        bad_flags = PAGE_FLAGS_CHECK_AT_FREE;
    }
    if (unlikely(mem_cgroup_bad_page_check(page)))
        bad_reason = "cgroup check failed";
    if (unlikely(bad_reason)) {
        bad_page(page, bad_reason, bad_flags);
        return 1;
    }
    page_cpupid_reset_last(page);
    if (page->flags & PAGE_FLAGS_CHECK_AT_PREP)
        page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP;
    return 0;
}

According to the principle, if it is an anonymous page, the mapping of the page will be set to null when it is released, as follows:

static bool free_pages_prepare(struct page *page, unsigned int order)
{
    int i;
    int bad = 0;

    trace_mm_page_free(page, order);
    kmemcheck_free_shadow(page, order);

    if (PageAnon(page))
        page->mapping = NULL;
    for (i = 0; i < (1 << order); i++)
        bad += free_pages_check(page + i);
    if (bad)
        return false;

    if (!PageHighMem(page)) {
        debug_check_no_locks_freed(page_address(page),PAGE_SIZE<<order);
        debug_check_no_obj_freed(page_address(page),
                       PAGE_SIZE << order);
    }
    arch_free_page(page, order);
    kernel_map_pages(page, 1 << order, 0);

    return true;
}

Now that the bad count is entered, the page is not anonymous when it is released. In my code, the mapping of page refers to the address of the file_ Space, so mapping is not null

The reason for the problem is that when I manage the page in my own memory pool, there is a process that does not count normally. As a result, when it is released abnormally, the pointer has not been cleaned up

Linux: Environment Variables C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, CPATH Common Error [How to Solve]

C_ INCLUDE_ PATHCPLUS_ INCLUDE_ Path and cpath are often used to globally add the include directory when preprocessing C/C + +, where C + + is used as the include directory_ INCLUDE_ Path is only effective for pretreatment C, cplus_ INCLUDE_ Path is only valid for preprocessing C + +, while cpath is valid for all languages. Next, we only use C_ INCLUDE_ Path as an example

The common error prone setting method is to simply use recursive assignment in ~ /. Bashrc and other files

export C_INCLUDE_PATH=$C_INCLUDE_PATH:/somewhere/include

The command of this statement will change C_ INCLUDE_ Path is assigned to its original value, followed by the value of :/somewhere/include

For example, if the original $C_ INCLUDE_ The value of path is /previous/include , then after executing this shell statement, $C_ INCLUDE_ The value of path will change to /previous/include/somewhere/include , and if the environment variable C has not been defined before_ INCLUDE_ Path or defined but empty, then $C_ INCLUDE_ The value of path will change to :/somewhere/include .

But why is it easy to make mistakes

We know that colon : is used to separate two directories in Linux (semicolon is commonly used in Windows)</The expected effect of using this statement should be to add /somewhere/include to the included directory when preprocessing C

There is a sentence in the official document of GCC about the influence of environment variables on GCC

In all these variables, an empty element instructs the compiler to search its current working directory. Empty elements can appear at the beginning or end of a path. For instance, if the value of CPATH is :/special/include, that has the same effect as -I. -I/special/include.

In all of these variables, an empty element instructs the compiler to search the current working directory empty elements can appear at the beginning or end of a path . For example, if the value of cpath is :/special/include , this would be equivalent to - I. - I/special/include

Therefore, in the previous example, we just want to add a /somewhere/include , the expected C, to the preprocessed search path_ INCLUDE_ The value of path is /somewhere/include , but actually C_ INCLUDE_ Path is assigned as :/somewhere/include . Although the colon at the beginning is empty, the current working directory will be added to the preprocessing search path, that is, , in Linux, and the priority is the highest in all directories

This is often not the result we want, which will lead to the change of the included directory of preprocessing with the change of the current working directory. If there is a file with the same name as the file contained in the source code in the current working directory, it will lead to unexpected errors

Unfortunately, tasks. Options. CWD happens to be /usr/bin in the tasks. JSON automatically generated by vscode for us, so once C is set incorrectly_ INCLUDE_ Path , and there is a file with the same name in /usr/bin (you should know that most of the files here are executable programs). When compiling C programs, you will mistakenly include the file with the same name as the source code file, and then you can appreciate a large number of compilation errors. For example, manjaro, the most popular Linux distribution at present, will have an executable program named array in /usr/bin after installation, which is similar to & lt; array> duplicate name

Correct method:

First of all, to be clear, these environment variables that contain the directory are not part of the Linux operating system, so in general, Linux will not set these environment variables

Therefore, when setting an environment variable for the first time, it should be directly assigned to the required directory, and then the recursive assignment should be used in the subsequent settings; Or all directories can be separated by : at one time and assigned values together; Or simply do not use these environment variables, but use the - I parameter to add the included directory at compile time

Others:

To view the search directory of GCC preprocessing C:

echo | gcc -x c -v -E -

To view the search directory of GCC preprocessing C + +

echo | gcc -x c++ -v -E -

To view the search directory of C + + preprocessed by clang:

echo | clang -x c++ -v -E -

cwd : current working directory

Linux Programmer Error: /bin/bash: No such file or directory [How to Solve]

As an example, take the following script.

#!/bin/bash

 

conn=’mysql -upitt -p123456 -hhostname –default-character-set=UTF8 database’

 

`$conn -e “select Name from Product1 where Type=’Live'” > a.txt`

`$conn -e “select Name from Product2 where Type=’Live'” >> a.txt`

echo “query end”

echo “start check”

 

`cd /home/user/NameCheck`

`grep ‘@’ a.txt | wc -l > result.txt`

 

Using Notepad++ editor.

1. In the Edit menu bar, select EOL Conversion sidebar and choose UNIX Format

2. In the Encoding menu bar, select Encode in UTF-8 without BOM

This way, you will not get the error /bin/bash: No such file or directory when running under Linux.

The solution to the problem of installing WGet in Linux

Front end developers must read! Starting from scratch, teach you to build a low code website platform in stages>>>

When using the WGet command to report an error certificate common name ‘xxx’ doesn’t match request de host name, our general solution is to find the download address, but sometimes an error occurs when changing the address

wget http://www.monkey.org/~provos/libevent-1.2.tar.gz

Report the following error:

error:certificate common name “monkey.org” doesn’t match requested host name ” www.monkey.org “

The curl command can be used interchangeably

curl -O -L http://www.monkey.org/~provos/libevent-1.2.tar.gz

Can solve the reason that cannot download

[Solved] Linux Start database Error: could not open parameter file init**.ora

Sqlplus/nolog, Conn/as SYSDBA, startup command

SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ‘/home/oracle/app/product/11.2.0/dbhome_ 1/dbs/initLCDC.ora’

Look up the file, it doesn’t exist. It is estimated that it is caused by illegal shutdown

This is because in Oracle 9i and Oracle 10g, Oracle will use SPFILE to start the database by default. If SPFILE does not exist, the above error will appear

Solution 1:
add $Oracle_Copy the init.ora.012009233838 file in the base/admin/database name/pfile directory to $oracle_Initlcdc.ora in the home/DBS directory( Note: Oracle in initoracle.ora is your instance name oracle_ Sid, the file name is the file name of the error prompt)

The corresponding path is:

Path 1: Home/Oracle/APP/admin/LCDC/pfile/init.ora.4132019135738

Path 2: Home/Oracle/APP/product/11.2.0/dbhome_ 1/dbs

The use of libpqxx interface in Linux solves the error of PSQL: connections on UNIX domain socket “/TMP/.S.pgsql.5432”

When using PostgreSQL database in the project, it is required to be compatible on both windows and Linux platforms. So the interface used in windows broke out an exception in Linux

psql:connections on Unix domain socket "/tmp/.s.PGSQL.5432"

After analyzing and checking the documentation the problem was solved as follows.

1. Reason: This is due to the fact that when connecting to pg under linux, the default unix domain socket method is used to connect to pg, and the port of pg is running on a non-default port (default port is 5432). Under windows the same interface uses the TCP protocol of socket to connect to pg.

2. When using pgxx::connection(“”), the string to be passed in is incomplete, resulting in a connection using the unix domain socket method under linux.

The following is the official postgresql documentation explaining.

host

Name of host to connect to.If a host name begins with a slash, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored. If multiple host names are specified, each will be tried in turn in the order given. The default behavior whenhostis not specified is to connect to a Unix-domain socketin/tmp(or whatever socket directory was specified whenPostgreSQLwas built). On machines without Unix-domain sockets, the default is to connect tolocalhost.

A comma-separated list of host names is also accepted, in which case each host name in the list is tried in order.

hostaddr

Numeric IP address of host to connect to. This should be in the standard IPv4 address format, e.g.,172.28.40.9. If your machine supports IPv6, you can also use those addresses. TCP/IP communication is always used when a nonempty string is specified for this parameter.

Usinghostaddrinstead ofhostallows the application to avoid a host name look-up, which might be important in applications with time constraints. However, a host name is required for GSSAPI or SSPI authentication methods, as well as forverify-fullSSL certificate verification. The following rules are used:

Ifhostis specified withouthostaddr, a host name lookup occurs.

Ifhostaddris specified withouthost, the value forhostaddrgives the server network address. The connection attempt will fail if the authentication method requires a host name.

If bothhostandhostaddrare specified, the value forhostaddrgives the server network address. The value forhostis ignored unless the authentication method requires it, in which case it will be used as the host name.

Note that authentication is likely to fail ifhostis not the name of the server at network addresshostaddr. Also, note thathostrather thanhostaddris used to identify the connection in a password file .

A comma-separated list ofhostaddrvalues is also accepted, in which case each host in the list is tried in order. SeeSection33.1.1.3for details.

Without either a host name or host address,libpqwill connect using a local Unix-domain socket; or on machines without Unix-domain sockets, it will attempt to connect tolocalhost.

Therefore, there are 2 main things wrong with our interface.

1. std::string strConnection has a problem with string splicing when using strConnection = “dbname=”+pg_dbname+” user=”+pg_username+” password=” under windows. So when splicing the string again use

std::string strConnection = "dbname=";
strConnection += pg_dbname.c_str();
strConnection += " user=";
strConnection += pg_username.c_str();
strConnection += " password=";
strConnection += pg_password.c_str();
strConnection += " hostaddr=";
strConnection += pg_ip.c_str();
strConnection += " port=";
strConnection += pg_port.c_str();

2. It is better to add the configuration of host = localhost in the strconnection string to ensure that there is no problem