2018년 9월 9일

CentOS7 설치후 기본설정 #1(IP, 호스트이름,repository, selinux, ssh, NTP, 문자셋)

1. 고정아이피 설정

> 서버로 활용시 고정IP를 설정하여 변경되지 않도록 해야함

?
001
vi /etc/sysconfig/network-scripts/ifcfg-eth0
>>> 유동IP
?
001
002
003
004
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:00:00:00:00
ONBOOT=yes
>>> 고정IP
?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:00:00:00:00:00
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID=00000000-0000-0000-0000-000000000000
IPADDR=000.000.000.000
NETMASK=255.255.255.0
GATEWAY=000.000.000.000
DNS1=000.000.000.000
DNS2=000.000.000.000
ETHTOOL_OPTS=wol g
IPV6INIT=no
USERCTL=no
>>>>>> description
– DEVICE :: 장치명
– BOOTPROTO :: static(고정IP) / dhcp(유동IP) / none(네트워크 미사용)
– HWADDR :: 물리적주소
– NM_CONTROLLED :: yes(네트워크 사용) / no(네트워크 미사용)
– ONBOOT :: 부팅시 장치 활성화 여부
– UUID :: 장치의 고유한 식별코드 (128bit로 구성)
– PEERDNS :: DBCP 사용시 Name Server를 DHCP 에서 받아온 것을 사용할 것인지 아닌지를 설정
– TYPE :: Ethernet
– IPADDR :: IP 주소 지정
– BROADCAST :: 브로드캐스트 지정
– NETMASK :: 서브넷마스크 지정
– GATEWAY :: 게이트웨이 지정
– ETHTOOL_OPTS :: Wake On Lan 기능 활성화, Ethtool필요함(CentOS의 경우 기본설치)
– IPV6INIT :: IPV6 사용여부
– USERCTL :: 일반 사용자의 네트워크 On/Off 가능 여부

2. 호스트네임 설정

> 서버를 구분하는 이름으로 시스템 구성시 유용하게 활용할 수 있음.

?
001
hostname ${hostname}
>>>>>> description
– 호스트명이 변경 됨
– 재부팅시 초기화 됨

?
001
vi /etc/sysconfig/network
?
001
HOSTNAME=${hostname}
>>>>>> description
– 호스트명이 변경 됨
– 재부팅시 반영 됨

?
001
vi /etc/hosts
?
001
002
127.0.0.1     localhost     ${hostname}
::1           localhost     ${hostname}
>>>>>> description
– 자기 자신을 가리키는 호스트 정보 수정

3. repository 추가

> 기본저장소에는 없는 최신의 패키지를 설치하기 위해 저장소를 추가한다.

>>> 저장소간 우선순위 지정
?
001
002
yum -y install yum-plugin-priorities
vi /etc/yum.repos.d/CentOS-Base.repo
?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
## 추가
priority=1
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
## 추가
priority=1
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
## 추가
priority=1
>>>>>> description
– 저장소간 우선순위 지정을 위해 플러그인 설치
– 우선순위는 1~99까지 설정가능하며 낮을수록 우선순위가 높음
>>> RPM Forge 설치
?
001
002
003
004
005
006
007
008
009
010
## rpm 다운로드
wget http://server.opendocs.co.kr/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
## DAG's GPG key 인스톨
rpm --import http://server.opendocs.co.kr/RPM-GPG-KEY.rpmforge.txt
## 다운받은 패키지 확인
rpm -K rpmforge-release-0.5.3-1.el7.rf.*.rpm
## 패키지 설치
rpm -i rpmforge-release-0.5.3-1.el7.rf.*.rpm
## 저장소 활성화 설정
vi /etc/yum.repos.d/rpmforge.repo
?
001
002
003
004
005
006
007
008
009
010
011
[rpmforge]
name=RHEL $releasever - RPMforge.net - dag
baseurl=http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
mirrorlist=http://mirrorlist.repoforge.org/el6/mirrors-rpmforge
#mirrorlist=file:///etc/yum.repos.d/mirrors-rpmforge
enabled=1
protect=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck=1
## 추가
priority=1
>>>>>> description
– http://pkgs.repoforge.org/rpmforge-release/ 에서 알맞는 패키지를 다운로드
– DAG’s GPG key 를 체크해서 안정성을 검토 – 저장소 활성화
>>> Epel 설치 : 페도라 저장소로 이용되며 레드햇계열간은 호환성에 거의 문제없음
?
001
002
003
004
005
006
007
008
009
010
## rpm 다운로드
wget http://server.opendocs.co.kr/epel-release-7-1.noarch.rpm
## GPG key 인스톨
rpm --import http://server.opendocs.co.kr/RPM-GPG-KEY-EPEL-7.txt
## 다운받은 패키지 확인
rpm -K epel-release-7-1.noarch*.rpm
## 패키지 설치
rpm -i epel-release-7-1.noarch*.rpm
## 저장소 활성화 설정
vi /etc/yum.repos.d/epel.repo
?
001
002
003
004
005
006
007
008
009
010
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
## 추가
priority=1
>>>>>> description
– http://dl.fedoraproject.org/pub/epel/ 에서 알맞는 패키지를 다운로드
– 저장소 활성화
>>> remi 설치 : 최신버전의 Mysql, PHP 등의 패키지를 지원함
?
001
002
003
004
005
006
007
008
009
010
## rpm 다운로드
wget http://server.opendocs.co.kr/remi-release-7.rpm
## GPG key 인스톨
rpm --import http://server.opendocs.co.kr/RPM-GPG-KEY-remi.txt
## 다운받은 패키지 확인
rpm -K remi-release-7.rpm
## 패키지 설치
rpm -i remi-release-7.rpm
## 저장소 활성화 설정
vi /etc/yum.repos.d/remi.repo
?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
[remi]
name=Les RPM de remi pour Enterprise Linux 7 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/7/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/7/remi/mirror
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
## 추가
priority=1
[remi-php55]
name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 7 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/7/php55/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/7/php55/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
## 추가
priority=1
[remi-php56]
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 7 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/7/php56/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/7/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
## 추가
priority=1
>>>>>> description
– http://dl.fedoraproject.org/pub/epel/ 에서 알맞는 패키지를 다운로드
– 저장소 비활성화 하고 필요한 경우에만 다음과 같이 사용함
yum install –enablerepo=remi,remi-php55 mysql-server
>>> 기존 설치된 패키지 update
?
001
002
yum clean all
yum -y --nogpgcheck update

4. selinux를 사용하지 않도록 설정

> 사용할 경우 설치 및 운영시 제약사항이 많아 사용하지 않는다.

?
001
002
003
004
005
006
007
008
## 사용해제
/sbin/setenforce 0
## 부팅시 사용해제 설정
vi /etc/selinux/config
#### /etc/selinux/config
SELINUX=disabled
>>>>>> description
– 보안정책이 너무 엄격해 운영시 오히려 문제를 발생시킬 수 있으므로 사용하지 않는다.

5. ssh 접속설정

> 직접 서버에서 작업을 하는 경우는 없으므로 SSH설치 후 원격으로 나머지 설치 및 유지보수 진행함

?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
## 22번 포트가 열려있는지 확인
netstat -an|grep LISTEN
## 패키지 설치
yum -y install openssh-server openssh-clients
## 서비스 등록
chkconfig sshd on
## 서비스 시작
service sshd start
## 22번 포트가 열렸는지 확인
netstat -an|grep LISTEN
## 방화벽 설정
vi /etc/sysconfig/iptables
#### 다음내용 추가
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
## 방화벽 서비스 재시작
service iptables restart
>>>>>> description
– 22번 포트가 열려있다면 설치 불필요함

6. NTP(Network Time Protocol) 시간동기화

> 서버의 시간은 오차가 생기게 마련이므로 타임서버를 통해서 업데이트 받음

>>> NTP 설정
?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
## ntp & libedit & ntpdate 설치
yum -y install ntp
## peer 설정
vi /etc/ntp.conf
## 시작프로그램에 등록
systemctl enable ntpd.service
## 서비스 시작
systemctl start ntpd.service
## 확인
ntpq -p
?
001
002
003
# ntp.conf
server time.bora.net
server time.kornet.net
>>>>>> description
– UDP 123을 기본포트로 사용함
– 국내의 NTP peer 서버를 등록
>>> 시간 동기화 설정
?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
## rdate 설치
yum -y install rdate
## 하드웨어 시간확인
hwclock -r
#### ※ 시간설정
####    - hwclock -w (운영체제값과 동기화)
####    - hwclock -s (운영체제 값을 동기화 시킴)
## 운영체제 시간확인
date
#### ※ 시간설정
####    - date 082712122014(MM(월)DD(일)hh(시)mm(분)CCCC(년도))
## 타임서버 시간확인
rdate -p time.bora.net
#### ※ 시간설정
####    - rdate -s time.bora.net
## 시스템 부팅시 동기화
vi /etc/rc.d/rc.local
## cron을 이용한 주기적인 동기화
crontab -e
?
001
002
003
004
005
006
# rc.local
/usr/bin/rdate -s time.bora.net
/sbin/hwclock -w
# crontab
## 매일새벽 1시동기화
00    01    *    *    *    /usr/bin/rdate -s time.bora.net&&hwclock -w
>>>>>> description
– 운영체재의 시간은 시스템 재부팅시 CMOS의 시간으로 초기화 되므로 동기화 시켜주어야 함

7. 문자셋 설정

> 서버설치시 UTF-8로 설정되지 않았다면 다음과 같이 변경함

?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
## 문자셋 설치
yum -y install kde-i18n-Korean fonts-korean
## 문자셋 변경
vi /etc/sysconfig/i18n
## profile 추가
vi /etc/profile
## 반영
source /etc/sysconfig/i18n
locale
## 리부팅
init 6
?
001
002
003
004
005
006
007
008
# i18n
LANG="ko_KR.UTF-8"
SUPPORTED="en_US.UTF-8:en_US:en:ko_KR.UTF-8:ko_KR:ko"
SYSFONT="latarcyrheb-sun16"
SYSFONTACM="8859-15"
#profile
export LC_ALL="ko_KR.UTF-8"
export LANG="ko_KR.UTF-8"
>>>>>> description
– [LANG] : 최초 초기 지원 언어 지정(부팅시 사용할 언어 패키지).
– [SUPPORTED] : 최초 언어 패키지 외에 호환 가능한 패키지 지정
– [SYSFONT] : 사용할 언어 패키지의 글짜 폰트 지정
– [SYSFONTACM] : 8859-15, iso15, …
[참고사이트]
http://myblog.opendocs.co.kr/archives/17

댓글 없음:

댓글 쓰기

추천 게시물

전기차 충전 요금 비교(2024년 4월)

작성기준일: 2024. 4. 15. 충전업체 완속(3kW) 중속(7kW) 급속(~100kW) 초급속(100kW~) 기타 채비 https://www.chaevi.com/ 250 290 360 385 채비패스 유료 가입시 일정용량만...