2016. 12. 16. 16:44

CentOS 7 에 mysql 설치 하면서 막혔던 부분 위주로 정리 합니다.



패스워드 설정규칙 복잡성 해제

sudo vim /etc/my.cnf

validate-password=off



임시 패스워드 확인

grep 'temporary password' /var/log/mysqld.log



루트 패스워드 설정 및 기타 초기 설정

sudo mysql_secure_installation



방화벽 오픈 및 반영

sudo firewall-cmd --zone=public --add-service=mysql --permanent

sudo firewall-cmd --reload




Posted by 해비
2016. 12. 11. 01:52
인텔 내장그래픽의 하드웨어 가속 설정에 대해 설명합니다.

환경
- 민트 리눅스 64비트 시나몬
- 인텔 i5-5200U 내장그래픽
- VLC 플레이어

vaapi 드라이버 다운로드


deb 파일 받아서 설치하면 끝~!!


vainfo 명령어로 아래와 같이 가속되는 목록을 확인할 수있다.

haebi@haebi-W330AU ~ $ vainfo 

libva info: VA-API version 0.39.0

libva info: va_getDriverName() returns 0

libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so

libva info: Found init function __vaDriverInit_0_39

libva info: va_openDriver() returns 0

vainfo: VA-API version: 0.39 (libva 1.7.0)

vainfo: Driver version: Intel i965 driver for Intel(R) Broadwell - 1.7.1

vainfo: Supported profile and entrypoints

      VAProfileMPEG2Simple            : VAEntrypointVLD

      VAProfileMPEG2Simple            : VAEntrypointEncSlice

      VAProfileMPEG2Main              : VAEntrypointVLD

      VAProfileMPEG2Main              : VAEntrypointEncSlice

      VAProfileH264ConstrainedBaseline: VAEntrypointVLD

      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice

      VAProfileH264Main               : VAEntrypointVLD

      VAProfileH264Main               : VAEntrypointEncSlice

      VAProfileH264High               : VAEntrypointVLD

      VAProfileH264High               : VAEntrypointEncSlice

      VAProfileH264MultiviewHigh      : VAEntrypointVLD

      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice

      VAProfileH264StereoHigh         : VAEntrypointVLD

      VAProfileH264StereoHigh         : VAEntrypointEncSlice

      VAProfileVC1Simple              : VAEntrypointVLD

      VAProfileVC1Main                : VAEntrypointVLD

      VAProfileVC1Advanced            : VAEntrypointVLD

      VAProfileNone                   : VAEntrypointVideoProc

      VAProfileJPEGBaseline           : VAEntrypointVLD

      VAProfileVP8Version0_3          : VAEntrypointVLD

 


실제로 가속여부를 확인 하겠습니다

VLC 플레이어를 기준으로 설명 합니다.


일단 재생해서 현재 상태를 확인 합시다.

CPU 사용률이 40% 에 육박합니다. (제일위 하늘색 CPU% 부분 참고)



설정(Ctrl + P) 에 들어가서 [입력/코덱] -> [하드웨어 가속디코딩] 을 찾습니다.

기본상태는 [자동] 으로 되어 있습니다.

다른거 건들필요 없습니다.

[하드웨어 가속 디코딩]부분만 [X11 VA-API 비디오 디코더]로 선택해 주세요. 그리고 저장 눌러서 빠져 나옵시다.

우리가 위에서 설치한 것이 vaapi 드라이버 거든요



그리고 다시 재생!! 결과는..??

우오오오!!! - CPU 사용률10% 대로 진입!! (맨 윗부분하늘색 CPU%부분)

동영상 가속에 성공하여 CPU사용률이 뚝! 떨어진 것을 볼 수있습니다.




Posted by 해비
2016. 12. 5. 16:48


Tomcat AccessLog에서 특정 요청을 제외 (AccessLogValve 설정)

[참고] https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Access_Log_Valve


0. 전제조건:

- 소스 수정 필요!!


1. conf/server.xml 열어서 아래 내용 추가

         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

               conditionUnless="DoNotLog"

               prefix="localhost_access_log" suffix=".txt"

               pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 


  

2. 로그를 남기기 원하지 않는 요청에 request.setAttribute("DoNotLog", "")를  추가한다.

@RequestMapping(value = "/weblist", method = RequestMethod.GET)

public ModelAndView testPageList(HttpServletRequest request)

{

request.setAttribute("DoNotLog", "");

ModelAndView mav = new ModelAndView();

// Call services

mav.addObject("list", testService.getEmpDetail());

mav.addObject("list2", testService.getEmpDetail());

// ... if you need more

mav.setViewName("testlist");

return mav;

}

 


3. 빌드 및 배포 후 서버 재시작


4. 이제 더 이상 해당 요청에서는 AccessLog 가 기록되지 않는다.




== 간단 요약 ==

1. Server.xml 의 Valve 설정에 conditionUnless 를 추가 및 설정한다.

   (로그 필요없는 조건 = "DoNotLog" 파라메터를 검사 시 null 이 아닌 놈들)


2. 소스에서 AccessLog 에 설정한 파라메터에 "" 을 set 하였으므로,

   이 요청에서 DoNotLog 파라메터는 null 이 아니게 되고, => 기록이 되지 않게 된다.

   ( 기록대상은 request.getAttribute("DoNotLog") = null )




Posted by 해비
2016. 12. 5. 11:41

현재 상태 확인


현재 디스크의 파티션 구조 확인

lsblk 명령어

[haebi@localhost ~]$ lsblk

NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

sda               8:0    0 232.9G  0 disk 

├─sda1            8:1    0   238M  0 part /boot

└─sda2            8:2    0  78.3G  0 part 

  ├─centos-root 253:0    0  46.6G  0 lvm  /

  ├─centos-swap 253:1    0   3.8G  0 lvm  [SWAP]

  └─centos-home 253:2    0    28G  0 lvm  /home

sr0              11:0    1  1024M  0 rom   



[haebi@localhost ~]$ sudo sfdisk -ls /dev/sda

244198584


Disk /dev/sda: 30401 cylinders, 255 heads, 63 sectors/track

Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0


   Device Boot Start     End   #cyls    #blocks   Id  System

/dev/sda1   *      0+     30-     31-    243712   83  Linux

/dev/sda2         30+  10256-  10226-  82137088   8e  Linux LVM

/dev/sda3          0       -       0          0    0  Empty

/dev/sda4          0       -       0          0    0  Empty

- sfdisk 명령어로 sda3, sda4 가 현재 0 으로 사이즈가 할당되어 있지 않음을 볼 수 있다.

  (왜 2개 보여주는지는 모르겠다능)



[haebi@localhost ~]$ ls -l /dev/sd*

brw-rw----. 1 root disk 8, 0 12월  2 14:59 /dev/sda

brw-rw----. 1 root disk 8, 1 12월  2 14:59 /dev/sda1

brw-rw----. 1 root disk 8, 2 12월  2 14:59 /dev/sda2 

- /dev 폴더 내에서 sd* 로 리스트 조회 하면 현재 디스크 장치의 목록을 볼 수 있다.

- sda, sdb.. 가 디스크 단위이고, 뒤에 숫자 붙은 것들이 파티션넘버를 의미한다.



여기서 부터 ROOT 유저로 진행 할 것. (sudo 로 안됨)



fdisk 작업 시작!!

여기서는 1개의 디스크에 할당하지 않은 빈 공간을 새 파티션으로 생성 합니다.


1. 현재 장치 상태 확인 및 파티션 설정

[haebi@localhost ~]$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.23.2).


Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.


Command (m for help): m

- 일단 m을 눌러 도움말을 확인합니다.



Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)


명령어로 현재 파티션 현황을 조회한다.

Command (m for help): p

- p 를 눌러 파티션 테이블을 확인 합니다.



Disk /dev/sda: 250.1 GB, 250059350016 bytes, 488397168 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x00016022


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048      489471      243712   83  Linux

/dev/sda2          489472   164763647    82137088   8e  Linux LVM


새 파티션을 생성

Command (m for help): n 

- n 을 눌러 새 파티션을 생성 합니다.



Partition type:

   p   primary (2 primary, 0 extended, 2 free)

   e   extended

primary로 생성

Select (default p): p

디폴트 값 그냥 엔터

Partition number (3,4, default 3): Enter

First sector (164763648-488397167, default 164763648): Enter

Using default value 164763648

Last sector, +sectors or +size{K,M,G} (164763648-488397167, default 488397167): Enter

Using default value 488397167

Partition 3 of type Linux and of size 154.3 GiB is set


Command (m for help): w

- 파티션 타입은 primary 타입 (p)으로 설정 합니다.

- 나머지 항목들은 디폴트 값으로 엔터엔터...

- 그리고 w 를 눌러 저장하고 빠져 나옵니다.



2. 설정된 파티션 확인

[haebi@localhost ~]$ sudo fdisk -l


Disk /dev/sda: 250.1 GB, 250059350016 bytes, 488397168 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x00016022


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048      489471      243712   83  Linux

/dev/sda2          489472   164763647    82137088   8e  Linux LVM

/dev/sda3       164763648   488397167   161816760   83  Linux


Disk /dev/mapper/centos-root: 50.0 GB, 50000297984 bytes, 97656832 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes



Disk /dev/mapper/centos-swap: 4097 MB, 4097835008 bytes, 8003584 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes



Disk /dev/mapper/centos-home: 30.0 GB, 30001856512 bytes, 58597376 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

- /dev/sda3 이 할당되었다!!



3. 마무리 작업

파티션 테이블 리로드

partprobe


파티션 포맷

sudo mkfs.ext4 /dev/sda3 



축하한다. 이제 파티션 생성 및 포맷까지 완료 되었다.


이 후, 해당 파티션에 대해 폴더 만들고 해당위치로 마운트 하던가, ZFS 같은 파일 시스템 풀의 구성원으로 세팅하여 사용하면 되겠다.




Posted by 해비
2016. 12. 5. 11:24

CentOS 7 파일서버 작업로그 (Samba, ZFS)


0. 설치옵션 : 파일서버 (모두체크)


1. 네트워크 IP 설정


1.1 이더넷 장치 확인

ls -la /etc/sysconfig/network-scripts/ifcfg*


1.2 고정IP 설정

vim /etc/sysconfig/network-scripts/ifcfg-enp0s3

BOOTPROTO="none"

ONBOOT="yes"


# IP Address

IPADDR = "192.168.0.5"

# Subnet Mask

NETMASK = "255.255.255.0"

# Default Gateway

GATEWAY = "192.168.0.1"

# DNS Server

DNS1 = "192.168.0.1"


2. ZFS 설치

https://github.com/zfsonlinux/zfs/wiki/RHEL-%26-CentOS


2.1 ZFS 저장소 설치파일 내려받기

wget http://download.zfsonlinux.org/epel/zfs-release.el7.noarch.rpm


2.2 ZFS 저장소 설치

sudo yum install http://download.zfsonlinux.org/epel/zfs-release$(rpm -E %dist).noarch.rpm


2.3 ZFS 저장소 지문 등록

gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux


2.4 ZFS 저장소 커널모듈 옵션 사용으로 설정

sudo /etc/yum.repos.d/zfs.repo

dkms enabled=1

kmod enabled=1 

2.5 ZFS 설치

sudo yum install zfs


2.6 커널모듈 설치 (DKMS)

sudo yum install kernel-devel zfs


2.7 모듈 로드

sudo /sbin/modprobe zfs


2.8 ZFS 풀 생성

sudo zpool create haebinas /dev/sda3

[주의] 풀 생성 후 다시 이 명령어 입력하면 기존 풀이 다 날아가므로 주의! 주의!!


2.9 ZFS의 풀에 파일시스템을 생성

zfs create haebinas/data



3. Samba 설정


3.1 Samba공유를 위한 폴더 생성

cd /haebinas/data

mkdir haebi


3.2 권한 설정

chown -R haebi:haebi haebi/


3.3 Samba 환경설정

기존파일 백업

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak


설정파일 에 경로 설정

sudo vim /etc/samba/smb.conf

workgroup = WORKGROUP

dos charset = CP949

display charset = UTF8

unix charset = UTF8


[haebinas]

path = /haebinas/data

writable = yes

valid users = haebi 


3.4 Samba 사용자 등록

sudo smbpasswd -a haebi


3.5 서비스 허용

sudo systemctl enable smb

sudo systemctl enable nmb


3.6 서비스 재시작

sudo systemctl restart smb

sudo systemctl restart nmb


3.7 방화벽 설정

sudo firewall-cmd --permanent --zone=public --add-service=samba

sudo firewall-cmd --reload


3.8 SELinux Samba 허용

chcon -t samba_share_t /haebinas/data

chcon -t samba_share_t /haebinas/data/haebi



4. 부팅시 자동으로 서비스 올라오도록 설정


4.1 자동실행을 위한 rc.local 활성화

sudo chmod +x /etc/rc.d/rc.local


4.2 ZFS 커널모듈 로드 및 생성한 풀 등록 (create 대신 import 사용을 눈여겨 본다!)

sudo vim /etc/rc.local

/sbin/modprobe zfs

zpool import haebinas


참고1 - Samba 방화벽 설정 예

Chain IN_public_allow (1 references)

 pkts bytes target     prot opt in     out     source               destination         

   35  3234 ACCEPT     udp  --  *      *       0.0.0.0/0            0.0.0.0/0            udp dpt:137 ctstate NEW

   13  2971 ACCEPT     udp  --  *      *       0.0.0.0/0            0.0.0.0/0            udp dpt:138 ctstate NEW

    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:139 ctstate NEW

    1    52 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:445 ctstate NEW 





Posted by 해비