<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="https://publishpress.com/"
	>

<channel>
	<title>Linux Archives - 아빠프로그래머의 좌충우돌 개발하기!</title>
	<atom:link href="https://www.daddyprogrammer.org/post/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.daddyprogrammer.org/post/category/linux/</link>
	<description>기저귀 갈면서 코딩해야 프로다!</description>
	<lastBuildDate>Thu, 17 Feb 2022 09:54:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://www.daddyprogrammer.org/wp-content/uploads/2019/04/cropped-spring-bird-2295431_960_720-300x300.jpg</url>
	<title>Linux Archives - 아빠프로그래머의 좌충우돌 개발하기!</title>
	<link>https://www.daddyprogrammer.org/post/category/linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>thumbor+varnish를 이용한 이미지 처리 서버(thumbnail server) 구축</title>
		<link>https://www.daddyprogrammer.org/post/3086/thumbor-varnish-smart-image-service/</link>
					<comments>https://www.daddyprogrammer.org/post/3086/thumbor-varnish-smart-image-service/#comments</comments>
		
		<dc:creator><![CDATA[happydaddy]]></dc:creator>
		<pubDate>Mon, 06 May 2019 16:04:36 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Thumbor]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[Thumbnail]]></category>
		<guid isPermaLink="false">http://3.36.120.4/?p=3086</guid>

					<description><![CDATA[<p>이번 장에서는 서비스 구축시 클라이언트에게 최적의 이미지를 제공하기 위해 필요한 이미지 처리서버를 구축해 보겠습니다. 현대의 서비스들은 웹, 모바일 웹, android, ios등 다양한 다양한 플랫폼으로 서비스가 되고 있습니다. 각각의 플랫폼은 같은 이미지라 하더라도 플랫폼별로 권장되는 최적의 이미지 사이즈가 있습니다. 원본 이미지 하나로는 플랫폼 전체를 커버할 수 없게 되었습니다. 따라서 원본 이미지로 다양한 사이즈의 썸네일을 만들어내거나, 각각의 [&#8230;]</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/3086/thumbor-varnish-smart-image-service/">thumbor+varnish를 이용한 이미지 처리 서버(thumbnail server) 구축</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">이번 장에서는 서비스 구축시 클라이언트에게 최적의 이미지를 제공하기 위해 필요한 이미지 처리서버를 구축해 보겠습니다. </p>



<p class="wp-block-paragraph">현대의 서비스들은 웹, 모바일 웹, android, ios등 다양한 다양한 플랫폼으로 서비스가 되고 있습니다. 각각의 플랫폼은 같은 이미지라 하더라도 플랫폼별로 권장되는 최적의 이미지 사이즈가 있습니다. 원본 이미지 하나로는 플랫폼 전체를 커버할 수 없게 되었습니다. 따라서 원본 이미지로 다양한 사이즈의 썸네일을 만들어내거나, 각각의 이미지를 최적화 하여 서비스 하기 위한 이미지 솔루션이 필요하게 되었습니다. </p>



<p class="wp-block-paragraph">thumbor와 varnish를 이용하면 제법 쓸만한 이미지 처리서버의 구축이 가능합니다. 그 방법에 대해 실습해 보도록 하겠습니다.</p>



<h3 class="wp-block-heading">thumbor</h3>



<p class="wp-block-paragraph">thumbor는 오픈소스 이미지 처리 서비스입니다. python으로 만들어져 있으며 이미지에 다양한 처리를 쉽고 빠르게 적용할 수 있습니다. thumbor의 특징은 기존의 이미지 서비스처럼 사용할 사이즈의 썸네일을 미리 만들어 서비스하는 것이 아니라, 필요한 사이즈의 썸네일을 URL을 통해 유동적으로 생성해낼수 있다는 점입니다.</p>



<p class="wp-block-paragraph">ex) http://이미지서버주소/unsafe/요청이미지사이즈/원본이미지주소<br> <br>thumbor에 대한 자세한 내용은 아래 링크에서 확인 할 수 있습니다.<br><a rel="noreferrer noopener" aria-label=" (새탭으로 열기)" href="https://thumbor.readthedocs.io/en/latest/index.html" target="_blank">https://thumbor.readthedocs.io/en/latest/index.html</a></p>



<h3 class="wp-block-heading">의존성 프로그램 설치</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo yum install ffmpeg libjpeg-dev libpng-dev libtiff-dev libjasper-dev libgtk2.0-dev python-numpy python-pycurl webp python-opencv python-dev python-pip</pre>



<h3 class="wp-block-heading">thumbor 설치</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo pip install thumbor</pre>



<h3 class="wp-block-heading">thumbor config 파일 생성</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo thumbor-config > /etc/thumbor.conf</pre>



<h3 class="wp-block-heading">thumbor config 수정</h3>



<p class="wp-block-paragraph">기본 설정들은 모두 주석 처리되어 있습니다. 몇가지 설정을 활성화 하고 값을 변경합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">QUALITY = 95 # 이미지 처리시 결과물 퀄리티 변경 80->95
PRESERVE_EXIF_INFO = True # EXIF값을 유지.
ENABLE_ETAGS = False # Etag가 자동 생성되지 안도록 처리.
STORAGE_EXPIRATION_SECONDS = 0 # 이미지 유효시간. vanish를 사용하여 이미지를 캐시할 것이므로 0으로 설정.</pre>



<h3 class="wp-block-heading">thumbor 실행</h3>



<p class="wp-block-paragraph">아래 방법으로 띄우면 서버 데몬으로 뜨지 않습니다. 따라서 crtl+c를 누르면 종료됩니다. 아래 내용의 Supervisor를 이용하여 서버 데몬으로 띄우도록 하겠습니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ thumbor</pre>



<h3 class="wp-block-heading">Supervisor</h3>



<p class="wp-block-paragraph">Supervisor는 사용자가 UNIX와 유사한 운영 체제에서 여러 프로세스를 쉽게 제어 할 수 있도록 도와주는 프로그램입니다. Supervisor를 이용하면 thumbor를 쉽게 서버 데몬으로 구성이 가능합니다. 다음 명령어로 설치합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo pip install supervisor</pre>



<h3 class="wp-block-heading">Supervisor 설정</h3>



<p class="wp-block-paragraph">/etc/supervisord.conf를 생성합니다. 아래 내용 중 &#8211;port=900%로 설정하고 numprocs=2로 설정하면 9001, 9002번 포트로 thumbor가 자동으로 생성됩니다. 로그 위치를 지정하면 thumbor에서 처리되는 로그를 Supervisor가 해당 경로로 출력되도록 처리해 줍니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo vi /etc/supervisord.conf
[supervisord]
[program:thumbor]
command=thumbor --conf="/etc/thumbor.conf" --port=900%(process_num)s
process_name=thumbor900%(process_num)s
numprocs=2
autostart=true
autorestart=true
startretries=3
stopsignal=TERM
stdout_logfile=/var/log/thumbor900%(process_num)s.stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/thumbor900%(process_num)s.stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10</pre>



<h3 class="wp-block-heading">Supervisor 실행</h3>



<p class="wp-block-paragraph">설정한 conf파일로 Supervisor를 실행합니다. 프로세스를 확인하면 Supervisor와 thumbor 프로세스가 실행되고 있음을 확인할 수 있습니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo supervisord -c /etc/supervisord.conf
$ ps -ef | grep supervisord
root     24420     1  0 11:36 ?        00:00:00 /usr/bin/python2 /bin/supervisord -c /etc/supervisord.conf
$ ps -ef | grep thumbor
root     24421 24420  0 11:36 ?        00:00:00 /usr/bin/python2 /bin/thumbor --conf=/etc/thumbor.conf --port=9001
root     24422 24420  0 11:36 ?        00:00:00 /usr/bin/python2 /bin/thumbor --conf=/etc/thumbor.conf --port=9000</pre>



<h3 class="wp-block-heading">Varnish  설치</h3>



<p class="wp-block-paragraph">Varnish는 오픈소스 웹 캐시 프로그램입니다. thumbor만으로도 사용가능하지만 동일한 static resource에 대한 반복 요청을 Varnish를 통해 캐시하여 빠르게 처리할 수 있습니다. thumbor앞단에 Varnish캐시를 적용하면 thumbor단독으로 사용하는것보다 최소 2배에서 10배 이상 뛰어난 응답속도 개선을 얻을 수 있습니다.<br>Varnish는 설치하기 전에 epel reposotiry를 install 해야 합니다. install후에 varnish를 설치합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo amazon-linux-extras install epel
$ sudo yum install -y varnish</pre>



<h3 class="wp-block-heading">Varnish 설정 수정</h3>



<p class="wp-block-paragraph">Varnish를 thumbor 앞단의 캐시로 사용할 것이므로 아래 설정 파일의 주석을 풀고 값을 수정합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo vi /etc/varnish/varnish.params
VARNISH_LISTEN_ADDRESS=0.0.0.0
VARNISH_LISTEN_PORT=80</pre>



<p class="wp-block-paragraph">thumbor를 서비스 하기 위해 proxy설정 및  purge 관련 설정을 추가합니다.<br>purge는 varnish의 이미지 캐시를 삭제하는 명령입니다. HttpMethod를 PURGE로 해서 썸네일을 요청하면 캐시가 지워집니다. 이미지주소는 동일한데 원본이 변경되었을경우 PURGE를 요청하면 됩니다.  아무나 요청하면 안되므로 localhost에서만 수행 가능하도록 설정합니다.</p>



<p class="wp-block-paragraph"></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo vi /etc/varnish/default.vcl
vcl 4.0;

import directors;
# 서비스할 thumbor 서버 정보를 세팅
backend thumbor1 { .host ="127.0.0.1"; .port="9000";  .max_connections = 200; .connect_timeout = 5s; .between_bytes_timeout  = 5s; }
backend thumbor2 { .host ="127.0.0.1"; .port="9001";  .max_connections = 200; .connect_timeout = 5s; .between_bytes_timeout  = 5s; }

# purge, ban 요청 가능한 네트워크 목록
acl internal {
    "localhost";
    "127.0.0.1";
}

# 위에서 설정한 thumbor 2대를 varnish에서 round-robin으로 서비스하도록 설정
sub vcl_init {
    new vdir = directors.round_robin();
    vdir.add_backend(thumbor1);
    vdir.add_backend(thumbor2);
}

sub vcl_recv {
    set req.backend_hint = vdir.backend();
    if (req.method == "PURGE") {
         # Purge는 acl목록의 네트워크에서만 가능
         if (!client.ip ~ internal) {
            return (synth(405, "This IP is not allowed to send PURGE requests."));
         }
         return (purge);
    }

    # 이미지 주소 ?문자열 뒤의 내용을 제거
    if (req.url ~ "\?$") {
        set req.url = regsub(req.url, "\?$", "");
    }
    return (hash);
}</pre>



<h3 class="wp-block-heading">Varnish 실행</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo service varnish start
Redirecting to /bin/systemctl start varnish.service
$ ps -ef | grep varnish
root     27109     1  0 15:00 ?        00:00:00 /usr/sbin/varnishd -P /var/run/varnish.pid -f /etc/varnish/default.vcl -a 0.0.0.0:80 -T : -S /etc/varnish/secret -u varnish -g varnish -s malloc,256M
varnish  27110 27109  0 15:00 ?        00:00:00 /usr/sbin/varnishd -P /var/run/varnish.pid -f /etc/varnish/default.vcl -a 0.0.0.0:80 -T : -S /etc/varnish/secret -u varnish -g varnish -s malloc,256M</pre>



<h3 class="wp-block-heading">테스트</h3>



<p class="wp-block-paragraph"><strong>원본 이미지 &#8211; 사이즈 : 1680&#215;1050</strong><br><a rel="noreferrer noopener" aria-label="https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg (새탭으로 열기)" href="https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg" target="_blank">https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg</a></p>



<p class="wp-block-paragraph"><strong><span class="has-inline-color has-vivid-cyan-blue-color">가로x세로 : 300px x 300px 정사각형 Resize &amp; Crop</span></strong><br>http://서버주소/unsafe/300&#215;300/https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg</p>



<figure class="wp-block-image is-resized"><img fetchpriority="high" decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_square.png" alt="" class="wp-image-3173" width="476" height="355" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_square.png 476w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_square-150x112.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_square-300x224.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_square-80x60.png 80w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_square-265x198.png 265w" sizes="(max-width: 476px) 100vw, 476px" /></figure>



<p class="wp-block-paragraph"><strong><span class="has-inline-color has-vivid-cyan-blue-color">x세로 : x300px 세로 사이즈 300px 직사각형 Resize</span></strong><br>http://서버주소/unsafe/x300/https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg</p>



<figure class="wp-block-image is-resized"><img decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/05/height300.png" alt="" class="wp-image-3175" width="495" height="341" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/05/height300.png 495w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/height300-150x103.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/height300-218x150.png 218w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/height300-300x207.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/height300-100x70.png 100w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p class="wp-block-paragraph"><strong><span class="has-inline-color has-vivid-cyan-blue-color">-가로x-세로 : -300px x -300px 가로 세로 반전</span></strong><br>http://서버주소/unsafe/-300x-300/https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg</p>



<figure class="wp-block-image is-resized"><img decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_flip.png" alt="" class="wp-image-3176" width="460" height="350" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_flip.png 460w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_flip-150x114.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_flip-300x228.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_flip-80x60.png 80w" sizes="(max-width: 460px) 100vw, 460px" /></figure>



<p class="wp-block-paragraph"><strong><span class="has-inline-color has-vivid-cyan-blue-color">왼쪽상단:오른쪽하단 : 특정 부분 Crop</span></strong><br>http://서버주소/unsafe/600&#215;200:900&#215;600/https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg </p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/05/specific_crop.png" alt="" class="wp-image-3178" width="458" height="446" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/05/specific_crop.png 458w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/specific_crop-150x146.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/specific_crop-300x292.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/specific_crop-431x420.png 431w" sizes="auto, (max-width: 458px) 100vw, 458px" /></figure>



<p class="wp-block-paragraph"><strong><span class="has-inline-color has-vivid-cyan-blue-color">필터 효과</span></strong><br>http://서버주소/unsafe/300&#215;300/filters:brightness(10):contrast(30)/https://sites.google.com/site/davidenglishpost/_/rsrc/1456907158206/ironman3/Iron-Man-3-slots.jpg</p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_filter.png" alt="" class="wp-image-3177" width="461" height="342" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_filter.png 461w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_filter-150x111.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_filter-300x223.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_filter-80x60.png 80w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/300x300_filter-265x198.png 265w" sizes="auto, (max-width: 461px) 100vw, 461px" /></figure>



<p class="wp-block-paragraph">이상으로 thumbor + varnish 서버 구축이 완료되었습니다. 해당 썸네일 서버를 통해 플랫폼별로 최적의 이미지를 제공 할 수 있게 되었습니다!</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/3086/thumbor-varnish-smart-image-service/">thumbor+varnish를 이용한 이미지 처리 서버(thumbnail server) 구축</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.daddyprogrammer.org/post/3086/thumbor-varnish-smart-image-service/feed/</wfw:commentRss>
			<slash:comments>13</slash:comments>
		
		
			</item>
		<item>
		<title>AWS EC2 &#8211; install nginx, mariadb</title>
		<link>https://www.daddyprogrammer.org/post/2348/aws-ec2-install-nginx-mariadb/</link>
					<comments>https://www.daddyprogrammer.org/post/2348/aws-ec2-install-nginx-mariadb/#comments</comments>
		
		<dc:creator><![CDATA[happydaddy]]></dc:creator>
		<pubDate>Tue, 30 Apr 2019 01:39:53 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[데이터베이스]]></category>
		<category><![CDATA[웹서버]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Mariadb]]></category>
		<guid isPermaLink="false">http://3.36.120.4/?p=2348</guid>

					<description><![CDATA[<p>AWS EC2에 nginx와 mariadb를 설치하는 방법에 대하여 정리합니다. 서버 타임존 변경 aws는 기본적으로 os설치시 타임존이 UTC로 맞춰져있으므로 nginx/mariadb 설치전에 TimeZone을 변경해 줍시다. nginx 설치 &#8211; amazon-linux-extras install nginx yum으로는 nginx 패키지를 찾지 못합니다. amazon-linux-extras 명령어로 nginx를 설치합니다. nginx 관련 파일 위치 설정 &#8211; /etc/nginx/nginx.conf로그 &#8211; /var/log/nginx 방화벽 오픈 웹서버에 접근하기 위해 80 port를 열어줍니다.ec2 security [&#8230;]</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/2348/aws-ec2-install-nginx-mariadb/">AWS EC2 &#8211; install nginx, mariadb</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">AWS EC2에 nginx와 mariadb를 설치하는 방법에 대하여 정리합니다.</p>



<h2 class="wp-block-heading">서버 타임존 변경</h2>



<p class="wp-block-paragraph">aws는 기본적으로 os설치시 타임존이 UTC로 맞춰져있으므로 nginx/mariadb 설치전에 TimeZone을 변경해 줍시다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ date
2019. 04. 30. (화) 04:23:00 UTC
$ sudo rm /etc/localtime
$ sudo ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime
$ date
2019. 04. 30. (화) 13:45:00 KST</pre>



<h2 class="wp-block-heading"><strong>nginx 설치</strong></h2>



<h3 class="wp-block-heading">&#8211; amazon-linux-extras install nginx</h3>



<p class="wp-block-paragraph">yum으로는 nginx 패키지를 찾지 못합니다. amazon-linux-extras 명령어로 nginx를 설치합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ amazon-linux-extras list
  0  ansible2                 available    [ =2.4.2  =2.4.6 ]
  2  httpd_modules            available    [ =1.0 ]
  3  memcached1.5             available    [ =1.5.1 ]
  4  nginx1.12                available    [ =1.12.2 ]
  5  postgresql9.6            available    [ =9.6.6  =9.6.8 ]
  6  postgresql10             available    [ =10 ]
  8  redis4.0                 available    [ =4.0.5  =4.0.10 ]
  9  R3.4                     available    [ =3.4.3 ]
 10  rust1                    available    \
        [ =1.22.1  =1.26.0  =1.26.1  =1.27.2  =1.31.0 ]
 11  vim                      available    [ =8.0 ]
................. 생략
$ sudo amazon-linux-extras install nginx1.12
$ sudo service nginx start
Redirecting to /bin/systemctl start nginx.service</pre>



<h3 class="wp-block-heading">nginx 관련 파일 위치</h3>



<p class="wp-block-paragraph"><span class="has-inline-color has-vivid-cyan-blue-color"><strong>설정 </strong></span>&#8211; /etc/nginx/nginx.conf<br><span class="has-inline-color has-vivid-cyan-blue-color"><strong>로그 </strong></span>&#8211; /var/log/nginx</p>



<h3 class="wp-block-heading">방화벽 오픈</h3>



<p class="wp-block-paragraph">웹서버에 접근하기 위해 80 port를 열어줍니다.<br>ec2 security groups 설정에서 inbound에 80 port를 추가합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Type : HTTP
Protocol : TCP
Port range : 80
Source : 0.0.0.0/0</pre>



<h3 class="wp-block-heading">nginx 실행</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo service nginx start</pre>



<h3 class="wp-block-heading">확인</h3>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/05/nginx.png" alt="" class="wp-image-2549" width="869" height="266" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/05/nginx.png 1158w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/nginx-1024x314.png 1024w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/nginx-768x235.png 768w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/nginx-150x46.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/nginx-300x92.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/05/nginx-696x213.png 696w" sizes="auto, (max-width: 869px) 100vw, 869px" /></figure>



<h2 class="wp-block-heading" id="mce_1"><strong>mariadb 설치</strong></h2>



<h3 class="wp-block-heading">&#8211; yum install mariadb-server</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo yum install mariadb-server
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                        | 2.4 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.62-1.amzn2.0.1 will be installed
--> Processing Dependency: mariadb(x86-64) = 1:5.5.62-1.amzn2.0.1 for package: 1:mariadb-server-5.5.62-1.amzn2.0.1.x86_64
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.62-1.amzn2.0.1.x86_64
............. 생략
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================
 Package                                 Arch                   Version                                 Repository                  Size
===========================================================================
Installing:
 mariadb-server                          x86_64                 1:5.5.62-1.amzn2.0.1                    amzn2-core                  11 M
Installing for dependencies:
 mariadb                                 x86_64                 1:5.5.62-1.amzn2.0.1                    amzn2-core                 9.0 M
............ 생략

Transaction Summary
===========================================================================
Install  1 Package (+9 Dependent packages)

Total download size: 22 M
Installed size: 111 M
Is this ok [y/d/N]: y

$ sudo service mariadb start
Redirecting to /bin/systemctl start mariadb.service</pre>



<h3 class="wp-block-heading">Port 변경 / 언어셋 변경</h3>



<p class="wp-block-paragraph">기본포트 3306은 잘 알려진 Port이므로 다른 포트로 변경하여 사용하는 것을 추천합니다. 언어셋을 utf8mb4로 설정하는 이유는, IOS에서 이모티콘/이모지 등을 표현할때 문자당 4byte를 사용하는데 기본설정을 사용하면 3byte까지만 받을수있어 utf8mb4로 설정해서 문자를 받을수있게 해주는 것입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo vim /etc/my.cnf
[mysqld]
port = 36091
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
$ sudo service mariadb restart</pre>



<h3 class="wp-block-heading">root 패스워드 변경</h3>



<p class="wp-block-paragraph">root패스워드는 처음엔 설정이 안되어 있으므로 설정을 해주도록 합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">// root 패스워드 설정
$ mysqladmin -u root -p password 'xxRootPwd^&amp;*'
Enter password: 그냥 엔터
$ mysql -u root -p
Enter password:설정한 비밀번호 입력
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)</pre>



<h3 class="wp-block-heading">운영용 database / id 생성</h3>



<p class="wp-block-paragraph">root를 그냥 사용해도 되지만. root의 경우 모든 권한을 가지고 있고 외부에서 접속 가능하게 설정할 경우엔 위험할 수 있으므로 운영 DB와 운영ID를 따로 만들어 권한을 격리시켜 사용하는 것을 추천합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">// root로 mariadb 접속
MariaDB [(none)]> create database daddyprogrammer;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> set password for happydaddy@localhost=password('xxxdaddypwd^&amp;*');
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on daddyprogrammer.* to happydaddy@localhost identified by 'xxxdaddypwd^&amp;*';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit;

$ mysql -u happydaddy -p
Enter password:설정한 비밀번호 입력
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| daddyprogrammer    |
| test               |
+--------------------+
3 rows in set (0.00 sec)</pre>



<h3 class="wp-block-heading">외부 접속 설정</h3>



<p class="wp-block-paragraph">ec2 security groups 설정에서 mariadb port를 inbound에 추가합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Type : Custom TCP Rule
Protocal : TCP
Port range : 위에서 설정한 myriadb의 port
Source : 0.0.0.0/0</pre>



<h3 class="wp-block-heading">운영 계정 외부 접속 권한 설정</h3>



<p class="wp-block-paragraph">daddyprogrammer database에 대하여 happydaddy 유저가 103.xxx.200. 으로 시작하는 IP에서만 비밀번호를 넣어 접근가능하도록 설정합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">// root 로그인
MariaDB [(none)]> grant all privileges on daddyprogrammer.* to happydaddy@'103.xxx.200.%' identified by 'xxxdaddypwd^&amp;*';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)</pre>



<h3 class="wp-block-heading">접속 확인</h3>



<p class="wp-block-paragraph">아래 링크에서 mysql workbench를 다운로드 받아 설치합니다.<br><a href="https://dev.mysql.com/downloads/workbench/">https://dev.mysql.com/downloads/workbench/</a></p>



<p class="wp-block-paragraph">외부 접속 권한 설정한 운영계정으로 접속할 커넥션을 하나 생성합니다.</p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench.png" alt="" class="wp-image-2416" width="600" height="377" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench.png 800w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench-768x482.png 768w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench-150x94.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench-300x188.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench-696x437.png 696w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench-669x420.png 669w" sizes="auto, (max-width: 600px) 100vw, 600px" /></figure>



<p class="wp-block-paragraph">접속에 성공하면 다음과 같은 화면을 볼 수 있습니다.</p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="http://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2.png" alt="" class="wp-image-2417" width="629" height="461" srcset="https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2.png 838w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2-768x564.png 768w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2-150x110.png 150w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2-300x220.png 300w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2-696x511.png 696w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2-572x420.png 572w, https://www.daddyprogrammer.org/wp-content/uploads/2019/04/mysqlworkbench_2-80x60.png 80w" sizes="auto, (max-width: 629px) 100vw, 629px" /></figure>
<p>The post <a href="https://www.daddyprogrammer.org/post/2348/aws-ec2-install-nginx-mariadb/">AWS EC2 &#8211; install nginx, mariadb</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.daddyprogrammer.org/post/2348/aws-ec2-install-nginx-mariadb/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>OpenJdk 설치, 삭제, 업데이트</title>
		<link>https://www.daddyprogrammer.org/post/2062/openjdk-install-update-delete/</link>
					<comments>https://www.daddyprogrammer.org/post/2062/openjdk-install-update-delete/#comments</comments>
		
		<dc:creator><![CDATA[happydaddy]]></dc:creator>
		<pubDate>Sun, 28 Apr 2019 06:01:55 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[JDK설치]]></category>
		<category><![CDATA[OpenJDK]]></category>
		<guid isPermaLink="false">http://3.36.120.4/?p=2062</guid>

					<description><![CDATA[<p>Oracle에서 Java를 유료화 하면서 상업적인 목적의 서버에 Java를 설치하고 사용할 경우 주의해야 합니다. 로컬 PC에서의 개발은 oracle, openjdk 상관없이 사용해도 문제가 없지만, 서버 환경에서의 사용은 저작권이 침해될 수 있으므로 openjdk를 설치해서 java 어플리케이션을 구동하는 것을 추천합니다. JDK8 및 이전 버전 설치 ubuntu, debian 계열 리눅스 설치 JDK 삭제 Fedora, Centos, Redhat 계열 리눅스 설치 JDK [&#8230;]</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/2062/openjdk-install-update-delete/">OpenJdk 설치, 삭제, 업데이트</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Oracle에서 Java를 유료화 하면서 상업적인 목적의 서버에 Java를 설치하고 사용할 경우 주의해야 합니다. 로컬 PC에서의 개발은 oracle, openjdk 상관없이 사용해도 문제가 없지만, 서버 환경에서의 사용은 저작권이 침해될 수 있으므로 openjdk를 설치해서 java 어플리케이션을 구동하는 것을 추천합니다.</p>



<h2 class="wp-block-heading">JDK8 및 이전 버전 설치</h2>



<h3 class="wp-block-heading">ubuntu, debian 계열 리눅스 설치</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo apt-get install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libvpx3
......... 생략
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for ca-certificates (20170717~16.04.2) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)</pre>



<h3 class="wp-block-heading">JDK 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo apt-get remove openjdk*
$ sudo apt-get autoremove --purge
$ sudo apt-get autoclean</pre>



<h3 class="wp-block-heading">Fedora, Centos, Redhat 계열 리눅스 설치</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo yum -y install java-1.8.0-openjdk-devel
Dependencies Resolved
=======================================================================================================================
 Package                              Arch            Version                                Repository           Size
=======================================================================================================================
Installing:
 java-1.8.0-openjdk                   x86_64          1:1.8.0.201.b09-0.amzn2                amzn2-core          259 k
Installing for dependencies:
 alsa-lib                             x86_64          1.1.4.1-2.amzn2                        amzn2-core          425 k
 atk                                  x86_64          2.22.0-3.amzn2.0.2                     amzn2-core          258 k
 avahi-libs                           x86_64          0.6.31-
Transaction Summary
....... 생략
=======================================================================================================================
Install  1 Package (+63 Dependent packages)

Total download size: 46 M
Installed size: 145 M
Is this ok [y/d/N]: y

  libpng.x86_64 2:1.5.13-7.amzn2.0.2                            libthai.x86_64 0:0.1.14-9.amzn2.0.2
  libwayland-client.x86_64 0:1.14.0-2.amzn2.0.1                  libwayland-server.x86_64 0:1.14.0-2.amzn2.0.1
  libxcb.x86_64 0:1.12-1.amzn2.0.2                               libxshmfence.x86_64 0:1.2-1.amzn2.0.2
  libxslt.x86_64 0:1.1.28-5.amzn2.0.2                            lksctp-tools.x86_64 0:1.0.17-2.amzn2.0.2
  mesa-libEGL.x86_64 0:17.2.3-8.20171019.amzn2.0.4              

Complete!
$ java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)</pre>



<h3 class="wp-block-heading">JDK 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ rpm -qa | grep jdk
copy-jdk-configs-3.3-10.amzn2.noarch
java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64
java-1.8.0-openjdk-headless-1.8.0.201.b09-0.amzn2.x86_64

$ sudo yum -y remove copy-jdk-configs-3.3-10.amzn2.noarch
$ sudo yum -y remove java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64
$ sudo yum -y remove java-1.8.0-openjdk-headless-1.8.0.201.b09-0.amzn2.x86_64</pre>



<h2 class="wp-block-heading">JDK9 &amp; later</h2>



<p class="wp-block-paragraph">최신버전의 jdk의 경우 apt-get이나 yum을 통해 업데이트가 늦기 때문에 다음 링크중 하나에서 openjdk 최신버전을 다운로드 받아 설치합니다.</p>



<p class="wp-block-paragraph"><a rel="noreferrer noopener" aria-label=" (새탭으로 열기)" href="https://adoptopenjdk.net/releases.html?variant=openjdk11&amp;jvmVariant=hotspot" target="_blank">https://adoptopenjdk.net/releases.html?variant=openjdk11&amp;jvmVariant=hotspot</a><br><a href="https://jdk.java.net/archive/" target="_blank" rel="noreferrer noopener" aria-label=" (새탭으로 열기)">https://jdk.java.net/archive/</a></p>



<h3 class="wp-block-heading">다운로드</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz</pre>



<h3 class="wp-block-heading">압축해제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ tar -xvf OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz</pre>



<h3 class="wp-block-heading">JAVA 설치 디렉토리로 이동</h3>



<p class="wp-block-paragraph">리눅스에서 Java는 /usr/lib/jvm 밑에 설치됩니다. 기존에 설치한 Java가 있다면 해당 경로에 이미 다른 Java가 존재할 것입니다. 디렉토리가 없는경우 생성하고 위에서 압축해제한 jdk11을 해당 디렉토리로 이동 시킵니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo mkdir /usr/lib/jvm
$ sudo mv jdk-11.0.3+7/ /usr/lib/jvm/openjdk-11.0.3+7</pre>



<h3 class="wp-block-heading">사용중인 jdk 링크 변경</h3>



<p class="wp-block-paragraph">update-alternative &#8211;install 명령을 통하여 아래와 같이 수동으로 설치한 jdk11을 시스템에 업데이트합니다. </p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/openjdk-11.0.3+7/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/openjdk-11.0.3+7/bin/javac 1</pre>



<h3 class="wp-block-heading">java 버전 변경</h3>



<p class="wp-block-paragraph">update-alternatives &#8211;install 실행후에 java 버전이 이전 버전으로 나온다면 update-alternatives &#8211;config 명령으로 java 버전을 선택해 줍니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ java -version
penjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
$ sudo update-alternatives --config java
There are 2 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64/jre/bin/java)
   2           /usr/lib/jvm/openjdk-11.0.3+7/bin/java
Enter to keep the current selection[+], or type selection number: 2
$ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
$ sudo update-alternatives --config javac
There are 2 programs which provide 'javac'.
  Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64/bin/javac)
   2           /usr/lib/jvm/openjdk-11.0.3+7/bin/javac
Enter to keep the current selection[+], or type selection number: 2
$ javac -version
javac 11.0.3</pre>



<p class="wp-block-paragraph">이후의 최신 버전은 위의 방법을 반복하여 버전업하면 됩니다. 이전 버전인 jdk8로 돌아가야 하면 update-alternatives &#8211;config를 다시 실행하여 jdk8을 선택하면 됩니다.</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/2062/openjdk-install-update-delete/">OpenJdk 설치, 삭제, 업데이트</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.daddyprogrammer.org/post/2062/openjdk-install-update-delete/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Linux Command &#8211; touch, mkdir, rm, cp, mv, du, df</title>
		<link>https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/</link>
					<comments>https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/#comments</comments>
		
		<dc:creator><![CDATA[happydaddy]]></dc:creator>
		<pubDate>Sun, 21 Apr 2019 14:26:21 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux command]]></category>
		<guid isPermaLink="false">http://3.36.120.4/?p=1187</guid>

					<description><![CDATA[<p>touch &#8211; 빈 파일 생성 mkdir &#8211; 디렉터리 생성 rm &#8211; 파일 삭제 rm &#8211; 확인 없이 파일 삭제 rm &#8211; 확인 없이 디렉터리 삭제. rm &#8211; 디렉터리 하위의 mov 확장자 파일을 모두 삭제 cp &#8211; 파일 복사 cp &#8211; 디렉터리 하위의 모든 파일과 디렉터리를 다른 디렉터리로 복사 mv &#8211; 파일을 이동 mv &#8211; 파일명 [&#8230;]</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/">Linux Command &#8211; touch, mkdir, rm, cp, mv, du, df</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">touch &#8211; 빈 파일 생성</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) touch hello.txt</pre>



<h3 class="wp-block-heading">mkdir &#8211; 디렉터리 생성</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mkdir hellodir</pre>



<h3 class="wp-block-heading">rm &#8211; 파일 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm hello.txt</pre>



<h3 class="wp-block-heading">rm &#8211; 확인 없이 파일 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm -f hello.txt</pre>



<h3 class="wp-block-heading">rm &#8211; 확인 없이 디렉터리 삭제.</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm -rf hellodir</pre>



<h3 class="wp-block-heading">rm &#8211; 디렉터리 하위의 mov 확장자 파일을 모두 삭제</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) rm /hello/*.mov</pre>



<h3 class="wp-block-heading">cp &#8211; 파일 복사</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) cp hello.txt hello2.txt</pre>



<h3 class="wp-block-heading">cp &#8211; 디렉터리 하위의 모든 파일과 디렉터리를 다른 디렉터리로 복사</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) cp -R /hello /hello2</pre>



<h3 class="wp-block-heading">mv &#8211; 파일을 이동</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mv hello.txt /hi/hello.txt</pre>



<h3 class="wp-block-heading">mv &#8211; 파일명 변경. 같은 디렉터리 내에서 없는 커맨드를 호출하면 이름이 변경된다.</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mv hello.txt hello2.txt</pre>



<h3 class="wp-block-heading">mv &#8211; 디렉토리 이동/복사. hellodir2가 존재하면 하위로 hellodir이 이동되고 없으면 hellodir의 이름이 hellodir2로 이름이 변경된다.</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$) mv /ubuntu/hellodir /ubuntu/hellodir2</pre>



<h3 class="wp-block-heading">du &#8211; 디렉토리내 파일, 디렉터리들의 용량 확인(disk usage)</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du
44	./deps/hiredis/adapters
40	./deps/hiredis/examples
1304	./deps/hiredis
368	./deps/jemalloc/bin
88	./deps/jemalloc/build-aux
324	./deps/jemalloc/doc
684	./deps/jemalloc/include/jemalloc/internal
768	./deps/jemalloc/include/jemalloc
12	./deps/jemalloc/include/msvc_compat/C99
20	./deps/jemalloc/include/msvc_compat
788	./deps/jemalloc/include
16	./deps/jemalloc/m4
24	./deps/jemalloc/msvc/projects/vc2015/jemalloc</pre>



<h3 class="wp-block-heading">du &#8211; 해당 디렉터리 용량 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du -hs redis-5.0.4
115M	redis-5.0.4</pre>



<h3 class="wp-block-heading">du &#8211; 현재 디렉터리에 있는 디렉터리 및 파일 용량 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du -hs *
100K	00-RELEASENOTES
8.0K	MANIFESTO
4.0K	Makefile
24K	README.md
61M	deps
64K	redis.conf
4.0K	runtest-sentinel
12K	sentinel.conf
53M	src
796K	tests
160K	utils</pre>



<h3 class="wp-block-heading">du &#8211; 현재 디렉터리에 있는 디렉터리 및 파일 중에서 용량이 큰것순으로 5개 보기</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ du -hsx * | sort -rh | head -n 5
61M	deps
53M	src
796K	tests
160K	utils
100K	00-RELEASENOTES</pre>



<h3 class="wp-block-heading">df &#8211; 리눅스 디스크 사용량 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          485712       0    485712   0% /dev
tmpfs             503624       0    503624   0% /dev/shm
tmpfs             503624     492    503132   1% /run
tmpfs             503624       0    503624   0% /sys/fs/cgroup
/dev/xvda1       8376300 5294644   3081656  64% /
tmpfs             100728       0    100728   0% /run/user/1000</pre>



<h3 class="wp-block-heading">df &#8211; 읽기 쉽게 보기</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        475M     0  475M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  492K  492M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1      8.0G  5.1G  3.0G  64% /
tmpfs            99M     0   99M   0% /run/user/1000</pre>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/">Linux Command &#8211; touch, mkdir, rm, cp, mv, du, df</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.daddyprogrammer.org/post/1187/linux-command-linux-command-touch-mkdir-rm-cp-mv-du-df/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<series:name><![CDATA[Linux command 알아보기]]></series:name>
	</item>
		<item>
		<title>Linux Command &#8211; cd, dirname, basename, id, uname, cpuinfo, meminfo, locale, ps, kill, top</title>
		<link>https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/</link>
					<comments>https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/#comments</comments>
		
		<dc:creator><![CDATA[happydaddy]]></dc:creator>
		<pubDate>Sun, 21 Apr 2019 13:41:16 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux command]]></category>
		<guid isPermaLink="false">http://3.36.120.4/?p=1180</guid>

					<description><![CDATA[<p>커서 이동 맨앞으로 : Ctrl+a, 맨뒤로 : Crtl+e pwd : 현재 디렉터리 확인 cd : 디렉터리 이동 dirname : 디렉터리 이름 구하기 basename : 파일 이름 구하기 id : 현재 로그인한 id 정보를 확인 uname -a : 서버의 OS 정보를 출력 cat /proc/cpuinfo : 서버의 CPU 정보를 출력 cat /proc/meminfo : 서버의 Memory 정보를 출력 [&#8230;]</p>
<p>The post <a href="https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/">Linux Command &#8211; cd, dirname, basename, id, uname, cpuinfo, meminfo, locale, ps, kill, top</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="mce_0"> 커서 이동 </h2>



<p class="wp-block-paragraph"> 맨앞으로 : <strong>Ctrl+a</strong>, 맨뒤로 : <strong>Crtl+e</strong></p>



<h2 class="wp-block-heading" id="mce_2">pwd :  현재 디렉터리 확인 </h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ pwd
/home/ubuntu</pre>



<h2 class="wp-block-heading">cd : 디렉터리 이동</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 계정의 home 디렉터리로 이동
$) cd or cd ~
# 루트 디렉터리로 이동
$) cd /
# 이전 디렉터리로 이동
$) cd -
# 상위 디렉터리로 이동
$) cd ..
# hellodir 디렉터리로 이동
$) cd /hellodir</pre>



<h2 class="wp-block-heading">dirname : 디렉터리 이름 구하기</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ dirname /var/log/nginx/access.log
/var/log/nginx</pre>



<h2 class="wp-block-heading">basename : 파일 이름 구하기</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ basename /var/log/nginx/access.log
access.log
$ basename /var/log/nginx/access.log .log
access</pre>



<h2 class="wp-block-heading" id="mce_3">id : 현재 로그인한 id 정보를 확인</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ id
uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),110(lxd)</pre>



<h2 class="wp-block-heading" id="mce_4">uname -a : 서버의 OS 정보를 출력</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ uname -a
Linux ip-172-26-11-44 4.4.0-1079-aws #89-Ubuntu SMP Tue Mar 26 15:25:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux</pre>



<h2 class="wp-block-heading">cat /proc/cpuinfo : 서버의 CPU 정보를 출력</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 63
model name      : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
stepping        : 2
microcode       : 0x41
cpu MHz         : 2400.072
cache size      : 30720 KB</pre>



<h2 class="wp-block-heading" id="mce_2">cat /proc/meminfo : 서버의 Memory 정보를 출력</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cat /proc/meminfo
MemTotal:         498372 kB
MemFree:           17220 kB
MemAvailable:      90228 kB
Buffers:           21324 kB
Cached:           150520 kB
SwapCached:            0 kB
Active:           388416 kB
Inactive:          27688 kB
Active(anon):     344528 kB
Inactive(anon):     6176 kB
Active(file):      43888 kB
Inactive(file):    21512 kB</pre>



<h2 class="wp-block-heading">locale : 지역 정보 조회</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"</pre>



<h2 class="wp-block-heading">ps &#8211; 실행중인 프로세스 목록 조회</h2>



<h3 class="wp-block-heading">옵션</h3>



<figure class="wp-block-table"><table><tbody><tr><td>옵션</td><td>내용</td></tr><tr><td><strong>-a</strong></td><td>전체사용자 프로세스 출력</td></tr><tr><td><strong>-e</strong></td><td>모든 프로세스 상태 출력</td></tr><tr><td><strong>-r</strong></td><td>실행중인 프로세스 상태 출력</td></tr><tr><td><strong>-u</strong></td><td>각 프로세스 사용자 및 사용시간 출력</td></tr><tr><td><strong>-x</strong></td><td>제어 터미널이 없는 프로세스 출력</td></tr><tr><td><strong>-l</strong></td><td>긴 포맷(자세한 내용)으로 표시</td></tr><tr><td><strong>-f</strong></td><td>풀 포맷(모든 컬럼내용)으로 표시<br></td></tr></tbody></table></figure>



<h3 class="wp-block-heading">필드별 항목</h3>



<ul class="wp-block-list"><li><strong>USER </strong>&#8211; 프로세스 사용자</li><li><strong>PID </strong>&#8211; 프로세스 ID</li><li><strong>PPID </strong>&#8211; 부모 프로세스 ID</li><li><strong>%CPU</strong> &#8211; CPU 사용률</li><li><strong>%MEM</strong> &#8211; 메모리 사용률</li><li><strong>VSZ </strong>&#8211; 가상 메모리 사용량</li><li><strong>RSS </strong>&#8211; 실제 메모리 사용량</li><li><strong>TTY </strong>&#8211; Teletype. 프로세스가 수행되고 있는 제어 터미널. &#8216;?&#8217;는 제어 터미널에 연결되어있지 않음을 나타냄</li><li><strong>STAT </strong>&#8211; 프로세스 상태( R : 실행 또는 실행대 / S : 수면 / I : 휴식 / T : 정지 / Z : 좀비프로세스 / D : 디스크 대기)</li><li><strong>START, TIME</strong> &#8211; 프로세스가 시작된 시간</li><li><strong>CMD</strong>(Command) &#8211; 실행된 프로세스명</li></ul>



<h3 class="wp-block-heading">ps -ef</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Apr07 ?        00:00:50 /lib/systemd/systemd --system --deserialize 25
root         2     0  0 Apr07 ?        00:00:00 [kthreadd]
root         3     2  0 Apr07 ?        00:00:08 [ksoftirqd/0]
root         5     2  0 Apr07 ?        00:00:00 [kworker/0:0H]
root         7     2  0 Apr07 ?        00:00:09 [rcu_sched]
root         8     2  0 Apr07 ?        00:00:00 [rcu_bh]
root         9     2  0 Apr07 ?        00:00:00 [migration/0]
root        10     2  0 Apr07 ?        00:00:07 [watchdog/0]
root        11     2  0 Apr07 ?        00:00:00 [kdevtmpfs]
root        12     2  0 Apr07 ?        00:00:00 [netns]
root        13     2  0 Apr07 ?        00:00:00 [perf]</pre>



<h3 class="wp-block-heading">ps -aux</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ps -aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  1.0 185332  5076 ?        Ss   Apr07   0:50 /lib/systemd/systemd --system --de
root         2  0.0  0.0      0     0 ?        S    Apr07   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Apr07   0:08 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S&lt;   Apr07   0:00 [kworker/0:0H]
root         7  0.0  0.0      0     0 ?        S    Apr07   0:09 [rcu_sched]
root         8  0.0  0.0      0     0 ?        S    Apr07   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    Apr07   0:00 [migration/0]
root        10  0.0  0.0      0     0 ?        S    Apr07   0:07 [watchdog/0]
root        11  0.0  0.0      0     0 ?        S    Apr07   0:00 [kdevtmpfs]</pre>



<h3 class="wp-block-heading">프로세스 명으로 PID 알아내기</h3>



<p class="wp-block-paragraph">ps -ef | grep 프로세스명 | grep -v grep</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ps -ef | grep httpd | grep -v grep
root     23969     1  0 Apr20 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 23970 23969  0 Apr20 ?        00:00:37 nginx: worker process</pre>



<h3 class="wp-block-heading">프로세스 cpu 사용률 확인</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ps -C nginx -o user,pid,pcpu,pmem,vsize,size,etime,comm
USER       PID %CPU %MEM    VSZ  SIZE     ELAPSED COMMAND
root     23969  0.0  0.3 179612  2076  7-20:54:40 nginx
www-data 23970  0.0  1.3 180596  3060  7-20:54:40 nginx</pre>



<h3 class="wp-block-heading"><strong>PID로 프로세스 이름 알아내기</strong></h3>



<p class="wp-block-paragraph">cat /proc/프로세스아이디/status | grep Name</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cat /proc/23969/status | grep Name
Name:   nginx</pre>



<h2 class="wp-block-heading">kill &#8211; 프로세스 종료</h2>



<h3 class="wp-block-heading">시그널 종류</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ kill -l
1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX</pre>



<p class="wp-block-paragraph"><strong>kill -15 pid</strong> : Terminate의 약자로 정상 종료 시그널 요청<br><strong>kill -9 pid</strong> : 강제 종료 요청. kill -15로 몇번해도 죽지 않는 경우 사용.<br><strong>kill -1 pid</strong> : 해당 pid 프로세스를 재시작.</p>



<h2 class="wp-block-heading">top &#8211;  프로세스 목록을 CPU 사용률이 높은 것부터 출력</h2>



<h3 class="wp-block-heading">필드별 항목</h3>



<ul class="wp-block-list"><li><strong>PID </strong>: 프로세스 ID (PID)&nbsp; &nbsp; </li><li><strong>USER </strong>: 프로세스를 실행시킨 사용자 ID</li><li><strong>PRI </strong>: 프로세스의 우선순위 (priority)</li><li><strong>NI </strong>: NICE 값. 일의 nice value값이다. 마이너스를 가지는 nice value는 우선순위가 높음.</li><li><strong>VIRT </strong>: 가상 메모리의 사용량(SWAP+RES)</li><li><strong>RES </strong>: 현재 페이지가 상주하고 있는 크기(Resident Size)</li><li><strong>SHR </strong>: 분할된 페이지, 프로세스에 의해 사용된 메모리를 나눈 메모리의 총합.</li><li><strong>S</strong> : 프로세스의 상태 [ S(sleeping), R(running), W(swapped out process), Z(zombies) ]</li><li><strong>%CPU</strong> : 프로세스가 사용하는 CPU의 사용율</li><li><strong>%MEM</strong> : 프로세스가 사용하는 메모리의 사용율</li><li><strong>TIME+</strong> : 프로세스 시작된 이후 경과된 총 시간</li><li><strong>COMMAND </strong>: 실행된 명령어</li><li><strong>Load average</strong> (로드 애버리지) : 세 개의 숫자는 각각 1분, 5분, 15분 간의 평균 실행/대기 중인 프로세스의 수를 나타냄. uptime 명령어로도 확인할 수 있으며, 시스템 부하를 모니터링 할 수 있다. 숫자가 높을 수록 시스템에 부하가 있다는 것이다. load average 값은 CPU의 코어 수를 같이 확인해야 하며, 코어 수 보다 적으면 문제가 없다. </li></ul>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ top
top - 13:53:04 up 20 days, 13:54,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 110 total,   1 running, 109 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.0 sy,  0.0 ni, 99.6 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   498372 total,    13396 free,   237284 used,   247692 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   157444 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0  185332   5072   3188 S  0.0  1.0   0:50.83 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    3 root      20   0       0      0      0 S  0.0  0.0   0:08.18 ksoftirqd/0
    5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    7 root      20   0       0      0      0 S  0.0  0.0   0:09.68 rcu_sched
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh
    9 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
   10 root      rt   0       0      0      0 S  0.0  0.0   0:07.47 watchdog/0
   11 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs</pre>



<h3 class="wp-block-heading">top 실행후 옵션</h3>



<ul class="wp-block-list"><li><strong>shift + t</strong> : 실행된 시간이 큰 순서로 정렬</li><li><strong>shift + m</strong> : 메모리 사용량이 큰 순서로 정렬</li><li><strong>shift + p</strong> : cpu 사용량이 큰 순서로 정렬</li><li><strong>shift + b</strong> : 상단의 uptime 및 기타 정보값을 블럭 선택해 표시 </li><li><strong>k</strong> : Process 종료&nbsp; &#8211; k 입력 후 종료할 PID를 입력하고 signal을 입력하라 표시되면 9를 넣어준다.</li><li><strong>c</strong>&nbsp; : 명령 인자 표시 / 비표시</li><li><strong>l</strong> : uptime line(첫번째 행)을 표시 / 비표시</li><li><strong>space bar</strong> : Refresh</li><li><strong>u</strong> : 입력한 유저 소유의 Process만 표시 .which user유저를 입력하라 표시될때 User를 입력. blank(공백) 입력시 모두 표시</li><li><strong>f&nbsp;</strong> : 화면에 표시될 프로세스 관련 항목 설정</li><li><strong>i </strong>: idle 또는 좀비 상태의 프로세스는 표시 되지 않음</li><li><strong>z</strong> : 출력 색상 변경</li><li><strong>d</strong> [sec] : 설정된 초단위로 Refresh</li><li><strong>c&nbsp;</strong> : command뒤에 인자값 표시</li><li><strong>q</strong> : top 종료</li></ul>
<p>The post <a href="https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/">Linux Command &#8211; cd, dirname, basename, id, uname, cpuinfo, meminfo, locale, ps, kill, top</a> appeared first on <a href="https://www.daddyprogrammer.org">아빠프로그래머의 좌충우돌 개발하기!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.daddyprogrammer.org/post/1180/linux-command-cd-dirname-basename-id-uname-cpuinfo-meminfo-locale-ps-kill-top/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<series:name><![CDATA[Linux command 알아보기]]></series:name>
	</item>
	</channel>
</rss>
