Tag Archives: Linux

Monitoring ora XXX error message in Oracle alert file in Linux concurrent mail Perl script

Monitor ora XXX error messages in alert files.

The script code of alertlog.pl is as follows:

!/ usr/bin/perl

Name: alertlog.pl

sub countSet{

open(OUT, “>$idFile”);

Printf (out “% d”, $currcount); # write the current line number to the file

close(OUT);

}

————————–

Define Variables

————————–

$obase=”/u01/app/oracle”;

$SH_ TOP=”/home/oracle/general/sh”;

$SID=”$ARGV[0]”;

$idFile=”$SH_TOP/log/alert_${SID}.id”; # Only the start line number and end line number of the current file have been checked

If (! – f $idfile) {# if the file does not exist

Open (out, “& gt; $idfile”); # then create and open the file in writing mode

Printf (out “% s \ n”, 1); # write 1

close(OUT);

}

$alertFile=”${obase}/admin/${SID}/bdump/alert_${SID}.log”;

$errFile=”$SH _TOP/err${SID}.txt”;

$cmd=”head -1 $idFile”;

$preCount=qx/$cmd/;

chomp($preCount); # Remove line breaks at the end of string variable values

$cmd=”wc -l $alertFile | awk ‘{print $1}'”;

$currCount=qx/$cmd/;

printf (“$preCount:$currCount\n”);

–Modified tail +preCount with tail -minusCount for Linux Compliance

$minusCount=$currCount-$preCount;

$cmd=”tail -$minusCount $alertFile | grep “ORA-” | /bin/egrep -v -f $SH_TOP/errLogAlert.dat | sort -u> $errFile”;

printf (“$cmd \n”) ;

system($cmd);

Ssize=-s $errFile;

if ($size >1){

printf (“Sending Alert for $SID \n”);

$cmd=”$SH_TOP/alert_notification_db.ksh -s “Alert Log Error” -d $SID -h ‘hostname’ -f $errFile”;

printf(“$cmd \n”);

system($cmd);

}

& countSet; # Execute counterset to write $currcount to the file $idfile

——————————

In order to run the above monitoring script, we need to start with sorace_ Bdump directory under base/admin/$Oracle Sid directory, such as/u01/APP/Oracle/admin/+ ASM/bdump

In addition, we also need to create an alert in the bdump directory that points to the tracking directory_+ ASM [i]. Log symbolic link. Examples are as follows:

exaddb01:/u01/app/oracle/admin/+ASM/bdump

+ASM1 -oracle:1s -1tr

total 0

Irwxrwxrwx 1 oracle dba 57 Nov 13 2011 alert_+ ASM.1og-→

/001/app/oracle/diag/asm/+asm/+ASM1/trace/alert_+ ASM1.1og

In the above example, the symbolic link created is alert + asm.log (no ASM instance name is used), which points to alert_+ Asm1.log file

This is intentional, because by doing so, we can configure the same cron task on each database server, regardless of whether the server is in independent mode or a node in RAC

The cron task looks like this:

–Monitor Alert Logs

0,10,20,30,40,50 * * * * /home/oracle/general/sh/alertlog.p1 +ASM >/ tmp/alertlog_+ ASM.log 2>& amp; one

SH top in the above script alertlog.pl defines where to execute the script. Under the SH top directory, the line number of the last line of the alarm log is recorded in the log subdirectory

This log subdirectory should be created as part of the alarm log file monitoring configuration:

exaddb01:/home/oracle/general/sh/log

TOOLSDEV1 – oracle:cat alert_+ ASM.id

191126

If, for some reason, you want to mine from the beginning of the alarm log, you can simply add alert_+ Modify the content of asm.id file to 0

The alert notify ati on db.ksh line in the above Perl script can also be replaced by mail or mailx

In our example, each detected ora message in the alarm log file will be uploaded to an Oracle table for further analysis in the future.

Like database alarm logs, ASM alarm logs need to be cleaned and archived:

exaddb01:/home/oracle/general/sh

+ASM1 – oracle: cat rotate_ asm.ksh

export CONF=/tmp/asml.conf

cat <& lt;!!& gt;$ CONF

/u01/app/oracle/diag/asm/+asm/+ASM1/trace/alert_+ ASM1.log

weekly

copytruncate

rotate 4

compress

}

!!

1ogrotate -s $SH/1og_ rotate_ asml -f $CONF-s SSH/log_ rotate_ listener_ scanl -f $CONF

The – s option in the above command enables the logrotate utility (log management tool under Linux) to specify other status files

In order for Oracle or grid users to execute the logrotate command, you must specify the – s option. Because the default status file is/var/lib/logrotate.status

Generally speaking, only the root user has permission to write to the file- The f option forces the rotation of log files, even if the logrotate tool considers this rotation unnecessary

The last option specifies the profile for log rotation. In this configuration file, we can set the following contents:

·Location of log files to be rotated and rotation options

·Rotation frequency

·Number of files to keep

·Whether to use compression

After we execute the log rotation script for the first time, we can see that the old alarm log has been compressed, and the size of the newly generated log file is 0 bytes:

exaddb01:/u01/app/oracle/diag/asm/+asm/+ASM1/trace

+ASM1 – oracle: 1s -1 alert_+ ASM*

-rw-r—–1 oracle dba 0 Dec 11 14:55 alert +ASM1.log

-rw-r—–1 oracle dba 643647 Dec 11 14:55 alert_+ ASM1.log.1.gz

Attachment:

####################################################################################

Every 15 seconds

* * * * * sleep 15;/ home/oracle/general/sh/alertlog.p1 +ASM >/ tmp/alertlog_+ ASM.log 2>& amp; one

####################################################################################

Linux: How to configurate Environment Variables

Configure by modifying the ~ /. Bashrc file in the user directory:

vim ~/.bashrc

# add in the last line
export PATH=$PATH:/home/uusama/mysql/bin

matters needing attention:

Effective time: it takes effect when a new terminal is opened with the same user, or it takes effect manually source ~ /. Bashrc

Effective period: permanent

Effective range: only valid for the current user

If a subsequent environment variable loading file overwrites the Path definition, it may not take effect

How to Share Files Between Linux and windows

1. Create users, directories and installation packages
yum install samba smbfs
useradd -s /sbin/nologin yunwei
smbpasswd -a yunwei
mkdir -p /date/yunwei
chmod 777 /data/yunwei
2. Configuration file
cp /etc/samba/smb.conf /etc/samba/smb.confbak
vi /etc/samba/smb.conf
[homes]
comment = Home Directories
valid users = %S
browseable = No
writable = yes
create mode = 0664
directory mode = 0775

[yunwei]
comment = yunwei
path = /data/yunwei
public = no
valid users = @yunwei
write list = yunwei
printable = no

3. Start the service
Red Hat Enterprise Linux Server release 6.4 (Santiago)
/etc/init.d/smb start
service smb reload
linux 7
systemctl start smb
systemctl status smb
4. Test the use of
windows => run =>
\\ip\yunwei

[Solved] Using jdk11 to deploy Nacos under Linux, the startup error is: could not find or load main class

Deploying Nacos using jdk11 under Linux

Error log

/nacos/jdk-11.0.12/bin/java   -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/nacos/nacos-server-2.0.3-node1/logs/java_heapdump.hprof -XX:-UseLargePages -Dnacos.member.list= -Xlog:gc*:file=/nacos/nacos-server-2.0.3-node1/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400 -Dloader.path=/nacos/nacos-server-2.0.3-node1/plugins/health,/nacos/nacos-server-2.0.3-node1/plugins/cmdb -Dnacos.home=/nacos/nacos-server-2.0.3-node1 -jar /nacos/nacos-server-2.0.3-node1/target/nacos-server.jar  --spring.config.additional-location=file:/nacos/nacos-server-2.0.3-node1/conf/ --logging.config=/nacos/nacos-server-2.0.3-node1/conf/nacos-logback.xml --server.max-http-header-size=524288
Error: Could not find or load main class 
Caused by: java.lang.ClassNotFoundException: 

Solution:

In the Nacos-Server bin/startup.sh
Startup error caused by JAVA_OPT_EXT_FIX configuration

Replace the following configuration in the startup.sh file

x JAVA_OPT_EXT_FIX="-Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"
√ JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"

x echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}"
√ echo "$JAVA ${JAVA_OPT}"

x echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 &
x nohup "$JAVA" "$JAVA_OPT_EXT_FIX" ${JAVA_OPT} nacos.nacos >> ${BASE_DIR}/logs/start.out 2>&1 &
√ echo "$JAVA ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 &
√ nohup $JAVA ${JAVA_OPT} nacos.nacos >> ${BASE_DIR}/logs/start.out 2>&1 &

Rabbitmq error of connecting the native idea to Linux: java.net.connectexception: connection timed out: Connect [Solved]

The code is as follows:

        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("192.168.2.135");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("admin");
        connectionFactory.setPassword("admin");
        connectionFactory.setVirtualHost("/");

        Connection connection=null;
        Channel channel = null;

        try {
            //2.create linke Connection
            connection = connectionFactory.newConnection("Creator");

Error: Java. Net. Connectexception: connection timed out: connect

Cause analysis: first, the IP port account and password are excluded

Error reason: port 5672 is not open. I always thought that everything would be fine as long as the protective wall was closed

Solution:

1. Restart the firewall: systemctl start firewall

2. Open 5672 port: firewall CMD — zone = public — add port = 5672/TCP — permanent

3. Reload: firewall CMD — reload

Run debug:

success!!!

Linux error: command not found [How to Solve]

I saw a fun project some time ago: [musicbox]( https://github.com/darknessomi/musicbox )Start installing with git clone, and the input command cannot be run. At first, I thought there was a problem with the installation, so I changed to PIP installation. I found that it still couldn’t run
interface error: command not found

At first I wondered why I couldn’t find the order?After searching, it is found that the commands viewed by Linux must be placed in/usr/bin /. If they are not in this directory, they will not be found
at this time, we need to create a link file for these commands that cannot be found. Link it to/usr/bin to directly execute our commands

Establishing a soft link is equivalent to establishing a shortcut:

1、Want to see where the installation directory is
find/-name musicbox

2、Create a soft link
ln -s /usr/local/musicbox/bin/musicbox    /usr/bin

 

After doing the above operations, you can find the corresponding command

How to Solve Linux Error: ifconfig command not found

1. An error is reported when inputting ifconfig command in Linux: ifconfig command not found

Ifconfig may not be installed. If not, install it

2. Check if ifconfig is missing. It is in/usr/SBIN directory

[email protected] ~]#Ll/usr/SBIN

check if there is ifconfig

if there is no ifconfig, install the net tools package

[ [email protected] sbin]# sudo yum install net-tools

 

Linux: How to Solve Git clone error

How to Solve Error: error: The requested URL returned error: 401 Unauthorized while accessing

Problem:

Error: error: The requested URL returned error: 401 Unauthorized while accessing
git version1.7.1

Solution 1: Assign a user
git clone https://github.com/org/project.git

change to
git clone https://[email protected]/org/project.git
or
git clone https://username:[email protected]/org/project.git

If it appears in push or pull, then you need to change the remote address
git remote set-url origin https://[email protected]/org/project.git

Solution 2: Remove validation
git config -global http.sslverify false

Solution 3: (recommended)
Upgrade git version ≥ 1.7.10

Solution 4:
Add ssh secret key

 

Linux Run javac Error: javac: command not found

bash: javac: command not found

java version 1.8

[[email protected] home]# java -version
openjdk version "1.8.0_232"

Directly during installation

yum install java

After installation, run javac and report an error. It is found that there are fewer packages, so install the corresponding package again

yum install java-1.8.0-openjdk-devel.x86_64