Common Questions Set for Linux Enterprise Production

Keywords: Redis Zabbix vim Tomcat

1. How to set the memory size of tomcat-8.5.9 JVM

JAVA_OPTS="$JAVA_OPTS -Xmx2048m -Xms1024m -Xss512k -XX:NewRatio=4 -XX:SurvivorRatio=4"
     -Xmx2048m #Maximum available memory
     -Xms1024m #Minimum Available Memory (Maximum and Minimum Set to Equivalent)
     -Xss512k #Stack size for each process

2. nginx proxy back-end host, page and log are 504 gateway timeout prompt information when client visits. How to solve this problem?

There are many reasons for this kind of situation.
1: Network issues
 2: Code issues
 3: Configuration
 The solutions are as follows:
location / {
    ....................................
     proxy_pass http://10.0.0.101:9563
     proxy_connect_timeout 300 ;      
     proxy_read_timeout 300;
     proxy_send_timeout 300;
  }

Prevent other errors such as 504 500 by setting the proxy connection timeout interval. The default timeout time is 60S.

3. How to check whether the two files are completed synchronously and how to display and monitor them by configuring zabbix. Write out ideas and specific configuring steps.

There is no absolute answer to this question, only to see who can achieve the goal with a simple method, few configurations.
1: Synchronized client directory timing statistics directory and file number find. / | wc-l > file. log
 2: Real-time synchronization file.log to the synchronization server, the same server timing statistics directory and file number find. / wc-l > rsfile. log
 3: Use script to judge whether the size of numbers in two files is the same, print OK > result. log if they are the same, or print error > result. log if they are not.
4: The zabbix configuration only needs to check whether the number of ok in result is 1 or not regularly, and alarm if it is not 1.

4. Use free-mh to find that the size of cache is 4G and the usage of memory is only 5M. How to clear it? Write out the steps and annotate them.

####Manual Release of Memory Occupied by cached
//Write all unwritten system buffers to disk using the sync command before clearing
To free pagecache:  echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:  echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:  echo 3 > /proc/sys/vm/drop_caches
#When the manual release is completed, change back to default 0:echo 0 >/proc/sys/vm/drop_caches

#################Timing release script#################
#!/bin/bash
used=`free -m | awk 'NR==2' | awk '{print $3}'`
free=`free -m | awk 'NR==2' | awk '{print $4}'`
echo "===========================" >> /var/log/mem.log
date >> /var/log/mem.log
echo "Memory usage | [Use: ${used}MB][Free: ${free}MB]" >> /var/log/mem.log
if [ $free -le 1000 ] ; then
   sync && echo 1 > /proc/sys/vm/drop_caches
   sync && echo 2 > /proc/sys/vm/drop_caches
   sync && echo 3 > /proc/sys/vm/drop_caches
   echo "OK" >> /var/log/mem.log
else
  echo "Not required" >> /var/log/mem.log
fi
########################################

5. How to create and adjust SWAP partitions? Write down the specific steps.

####Method of creating and adjusting SWAP partitions
###Method 1: Create partition files 
dd if=/dev/zero of=/var/swap bs=1024 count=5G
mkswap /var/swap
swapon /var/swap
//Join / etc/fstab
/var/swap  swap swap defaults 0 0
###Method 2: Adjust the partition size in use
#Close partition
swapoff /dev/mapper/VolGroup-lv_swap
#Increase in size
lvm lvresize /dev/mapper/VolGroup-lv_swap -L +25000M 
#format partition
mkswap /dev/mapper/VolGroup-lv_swap
#Enable partition
swapon -va

6. How to set redis to open remote access

cd /etc/redis/
vim redis.confg
bind 127.0.0.1--—> #bind 127.0.0.1
protected-mode yes--—> protected-mode no

Restart service

7. Login mysql database for operation, Too Many Connections error prompts, how to solve?

vim /etc/my.cnf
max_connections = 500 #Adjust the size of the value according to the specific situation
wait_timeout=5

Posted by lordzardeck on Sat, 18 May 2019 09:42:38 -0700