반응형


CentOS ulimit 값 변경 (Too many open files Tomcat Error and NoClassDefFoundError)




Too many open files Tomcat Error and  NoClassDefFoundError 에러가 톰캣에서 발생할 때 해결하는 방법이에요


OS에서 파일 갯수를 제한하고 있는데 이걸 늘려줌으로써 해결할 수 있어요





centos 상에서 ulimit 값은 아래와 같이 디폴트로 설정되어있어요


(ulimit -a 쳐보면 나와요) --> 현재 로그인 된 계정의 설정 값이 보임


    /proc/[pid]/limits : 이것을 통해 프로세스에 적용된 limit 정보도 확인 가능










이 값은 실행중인 파일이나 프로세스가 증가함에 따라 문제가 일으킬 수 있어요


open files 값이나 max user processes 값이 적어서 생기는 문제에요


이럴땐 


/etc/security/limits.conf로 들어가서


제일마지막에


root hard nofile 65535


root soft nofile 65535


root hard nproc 65535


root soft nproc 65535


이걸 추가해주고 centos를 재시작해주면 끝! --> 재시작 안해도 되는 듯 합니다.


그럼 ulimit -a명령어를 쳤을 경우 아래처럼 값이 변경되요













위의 방법은 user lever open file 갯수 조정하는 방법이고


전체 조정 방법은


    최대 open file 갯수 조회 방법


      #cat /proc/sys/fs/file-max


      #sysctl fs.file-max


로 조회가 가능하고


vi /etc/sysctl.conf에 들어가서 fs.file-max=66536과 같은 방식으로 조정이 가능해요



반응형
LIST
반응형

MariaDB(Mysql) var폴더에서 home폴더로 변경

MariaDB(Mysql) DB 서비스 중지
~# systemctl stop mysql

/var/lib/mysql 폴더를 /home/mysql 으로 이동
~# mv /var/lib/mysql /home/mysql

/home/mysql의 소유자 변경
~# chown -R mysql.mysql /home/mysql 
~# chmod 700 /home/mysql

/var/lib 에 심볼릭 링크 생성
~# ln -sf /home/mysql /var/lib/mysql

/usr/share/mysql/mysql.server 파일 수정
~# vi /usr/share/mysql/mysql.server
47행의 datadir= 을 datadir=/home/mysql 로 설정

/var/lib/mysql 의 디폴트 레이블 수정 -SELinux-
~# semanage fcontext -a -t mysqld_db_t ‘/var/lib/mysql’
~# restorecon -v ‘/var/lib/mysql’

/home/mysql 의 디폴트 레이블 변경 -SELinux-
~# semanage fcontext -a -t mysqld_db_t ‘/home/mysql;
~# restorecon -v ‘/home/mysql’

MaraiDB(Mysql) DB 서비스 재시작
~# systemctl restart mysql

출처 https://gamviel.wordpress.com/2015/05/12/mariadbmysql-var%ED%8F%B4%EB%8D%94%EC%97%90%EC%84%9C-home%ED%8F%B4%EB%8D%94%EB%A1%9C-%EB%B3%80%EA%B2%BD/

반응형
LIST
반응형

CentOS ulimit 값 변경 (Too many open files Tomcat Error and NoClassDefFoundError)


Too many open files Tomcat Error and  NoClassDefFoundError 에러가 톰캣에서 발생할 때 해결하는 방법이에요

OS에서 파일 갯수를 제한하고 있는데 이걸 늘려줌으로써 해결할 수 있어요


centos 상에서 ulimit 값은 아래와 같이 디폴트로 설정되어있어요

(ulimit -a 쳐보면 나와요) --> 현재 로그인 된 계정의 설정 값이 보임

    /proc/[pid]/limits : 이것을 통해 프로세스에 적용된 limit 정보도 확인 가능



이 값은 실행중인 파일이나 프로세스가 증가함에 따라 문제가 일으킬 수 있어요

open files 값이나 max user processes 값이 적어서 생기는 문제에요

이럴땐 

/etc/security/limits.conf로 들어가서

제일마지막에

root hard nofile 65535

root soft nofile 65535

root hard nproc 65535

root soft nproc 65535

이걸 추가해주고 centos를 재시작해주면 끝! --> 재시작 안해도 되는 듯 합니다.

그럼 ulimit -a명령어를 쳤을 경우 아래처럼 값이 변경되요




위의 방법은 user lever open file 갯수 조정하는 방법이고

전체 조정 방법은

    최대 open file 갯수 조회 방법

      #cat /proc/sys/fs/file-max

      #sysctl fs.file-max

로 조회가 가능하고

vi /etc/sysctl.conf에 들어가서 fs.file-max=66536과 같은 방식으로 조정이 가능해요



반응형
LIST
반응형

How To Install Apache Tomcat 7 on CentOS 7 via Yum

Posted Jun 15, 2015

 

Introduction

Apache Tomcat is a web server and servlet container that is used to serve Java applications. Tomcat is an open source implementation of the Java Servlet and JavaServer Pages technologies, released by the Apache Software Foundation.

This tutorial covers the basic installation and some configuration of Tomcat 7 with yum on your CentOS 7 server. Please note that this will install the latest release of Tomcat that is in the official Ubuntu repositories, which may or may not be the latest release of Tomcat. If you want to guarantee that you are installing the latest version of Tomcat, you can always download the latest binary distribution.

Note: Tomcat can be installed automatically on your Droplet by adding this script to its User Data when launching it. Check out this tutorial to learn more about Droplet User Data.

Prerequisites

Before you begin with this guide, you should have a separate, non-root user account set up on your server. You can learn how to do this by completing the initial server setup for CentOS 7 tutorial. We will be using the demo user for the rest of this tutorial.

Install Tomcat

Now you are ready to install Tomcat 7. Run the following command to install the Tomcat package:

  • sudo yum install tomcat

Answer y at the confirmation prompt to install tomcat. This will install Tomcat 7 and its dependencies, such as Java, and it will also create the tomcat user.

Most of the important Tomcat files will be located in /usr/share/tomcat. If you already have a Tomcat application that you want to run, you can place it in the /usr/share/tomcat/webapps directory, configure Tomcat, and restart the Tomcat service. In this tutorial, however, we will install a few additional packages that will help you manage your Tomcat applications and virtual hosts.

Let's make a quick change to the Java options that Tomcat uses when it starts. Open the Tomcat configuration file:

  • sudo vi /usr/share/tomcat/conf/tomcat.conf

Add the following JAVA_OPTS line to the file. Feel free to change the Xmx and MaxPermSize values—these settings affect how much memory Tomcat will use:

/etc/default/tomcat7 — JAVA_OPTS
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"

Save and exit.

Note that the Tomcat service will not be running yet.

Install Admin Packages

If you are just getting started with Apache Tomcat, you will most likely want to install some admin tools that will help you deploy your Java applications and manage your virtual hosts. Luckily, there are packages that include these tools as web applications.

To install the default Tomcat root page (tomcat-webapps), and the Tomcat Web Application Manager and Virtual Host Manager (tomcat-admin-webapps), run this command:

  • sudo yum install tomcat-webapps tomcat-admin-webapps

Answer y at the confirmation prompt.

This adds the ROOT, examples, sample, manager, and host-manager web apps to the tomcat/webapps directory.

Install Online Documentation (Optional)

If you want to install the Tomcat documentation, so that all of the links on the default Tomcat page will work, run this command:

  • sudo yum install tomcat-docs-webapp tomcat-javadoc

Answer y at the prompt to install the documentation packages.

Configure Tomcat Web Management Interface

In order to use the manager webapp installed in the previous step, we must add a login to our Tomcat server. We will do this by editing the tomcat-users.xml file:

  • sudo vi /usr/share/tomcat/conf/tomcat-users.xml

This file is filled with comments which describe how to configure the file. You may want to delete all the comments between the following lines, or you may leave them if you want to reference the examples:

tomcat-users.xml excerpt
<tomcat-users>
...
</tomcat-users>

You will want to add a user who can access the manager-gui and admin-gui (the management interface that we installed earlier). You can do so by defining a user similar to the example below. Be sure to change the username and password to something secure:

tomcat-users.xml — Admin User
<tomcat-users>
    <user username="admin" password="password" roles="manager-gui,admin-gui"/>
</tomcat-users>

Save and exit the tomcat-users.xml file.

Now we're ready to start the Tomcat service.

Start Tomcat

To put our changes into effect, restart the Tomcat service:

  • sudo systemctl start tomcat

If you started the service earlier for some reason, run the restart command instead:

  • sudo systemctl restart tomcat

Enable Tomcat Service

If you want Tomcat to run every time the server is booted up, you will need to enable the service:

  • sudo systemctl enable tomcat

Now we're ready to access the web interface.

Access the Web Interface

Now that Tomcat is up and running, let's access the web management interface in a web browser. You can do this by accessing the public IP address of the server, on port 8080:

Open in web browser:
http://server_IP_address:8080

You will see something like the following image:

Tomcat root

As you can see, there are links to the admin webapps that you installed earlier.

Let's take a look at the Manager App, accessible via the link or http://server_IP_address:8080/manager/html:

Tomcat Web Application Manager

The Web Application Manager is used to manage your Java applications. You can Start, Stop, Reload, Deploy, and Undeploy here. You can also run some diagnostics on your apps (i.e. find memory leaks). Lastly, information about your server is available at the very bottom of this page.

Now let's take a look at the Host Manager, accessible via the link or http://server_IP_address:8080/host-manager/html/:

Tomcat Virtual Host Manager

From the Virtual Host Manager page, you can add virtual hosts to serve your applications from.

Conclusion

Your installation of Tomcat is complete! Your are now free to deploy your own Java web applications!

반응형
LIST

+ Recent posts