Browse Source

Update limits.conf

lj2007331 9 years ago
parent
commit
1bb7f7fb5e
6 changed files with 20 additions and 9 deletions
  1. 1 1
      apps.conf
  2. 5 2
      include/init_CentOS.sh
  3. 5 2
      include/init_Debian.sh
  4. 5 2
      include/init_Ubuntu.sh
  5. 2 1
      include/tomcat-7.sh
  6. 2 1
      include/tomcat-8.sh

+ 1 - 1
apps.conf

@@ -1,6 +1,6 @@
 # newest software version
 # Web
-nginx_version=1.9.3
+nginx_version=1.9.4
 tengine_version=2.1.1
 
 tomcat_7_version=7.0.63

+ 5 - 2
include/init_CentOS.sh

@@ -65,13 +65,16 @@ sed -i 's/^HISTSIZE=.*$/HISTSIZE=100/' /etc/profile
 [ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
 
 # /etc/security/limits.conf
-[ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <<EOF
+[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
+sed -i '/^# End of file/,$d' /etc/security/limits.conf
+cat >> /etc/security/limits.conf <<EOF
+# End of file
 * soft nproc 65535
 * hard nproc 65535
 * soft nofile 65535
 * hard nofile 65535
 EOF
-[ -z "`cat /etc/rc.local | grep 'ulimit -SH 65535'`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
+[ -z "`grep 'ulimit -SH 65535' /etc/rc.local`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
 
 # /etc/hosts
 [ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts

+ 5 - 2
include/init_Debian.sh

@@ -33,13 +33,16 @@ done
 [ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
 
 # /etc/security/limits.conf
-[ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <<EOF
+[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
+sed -i '/^# End of file/,$d' /etc/security/limits.conf
+cat >> /etc/security/limits.conf <<EOF
+# End of file
 * soft nproc 65535
 * hard nproc 65535
 * soft nofile 65535
 * hard nofile 65535
 EOF
-[ -z "`cat /etc/rc.local | grep 'ulimit -SH 65535'`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
+[ -z "`grep 'ulimit -SH 65535' /etc/rc.local`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
 
 # /etc/hosts
 [ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts

+ 5 - 2
include/init_Ubuntu.sh

@@ -55,13 +55,16 @@ sed -i 's/HISTSIZE=.*$/HISTSIZE=100/g' ~/.bashrc
 [ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
 
 # /etc/security/limits.conf
-[ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <<EOF
+[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
+sed -i '/^# End of file/,$d' /etc/security/limits.conf
+cat >> /etc/security/limits.conf <<EOF
+# End of file
 * soft nproc 65535
 * hard nproc 65535
 * soft nofile 65535
 * hard nofile 65535
 EOF
-[ -z "`cat /etc/rc.local | grep 'ulimit -SH 65535'`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
+[ -z "`grep 'ulimit -SH 65535' /etc/rc.local`" ] && echo "ulimit -SH 65535" >> /etc/rc.local
 
 # /etc/hosts
 [ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts

+ 2 - 1
include/tomcat-7.sh

@@ -45,8 +45,9 @@ if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     ./configure --with-apr=/usr/bin/apr-1-config
     make && make install
     if [ -d "/usr/local/apr/lib" ];then
+        [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
         cat > $tomcat_install_dir/bin/setenv.sh << EOF
-JAVA_OPTS='-server -Xms256m -Xmx`expr $Mem / 2`m'
+JAVA_OPTS='-server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 #  -Djava.rmi.server.hostname=$IPADDR
 #  -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password

+ 2 - 1
include/tomcat-8.sh

@@ -45,8 +45,9 @@ if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     ./configure --with-apr=/usr/bin/apr-1-config
     make && make install
     if [ -d "/usr/local/apr/lib" ];then
+        [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
         cat > $tomcat_install_dir/bin/setenv.sh << EOF
-JAVA_OPTS='-server -Xms256m -Xmx`expr $Mem / 2`m'
+JAVA_OPTS='-server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 #  -Djava.rmi.server.hostname=$IPADDR
 #  -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password