CentOS検証環境作成時にやっていることまとめ

初期設定が結構長くなってきたのでまとめ

パッケージ更新

yum update
yum install epel-release vim

ロケール周り

vim /etc/sysconfig/clock
---
ZONE="Asia/Tokyo" 
---
cp -f /usr/share/zoneinfo/Japan /etc/localtime

ホストネーム、ドメイン周り

vim /etc/sysconfig/network
---
HOSTNAME={fqdn}
---

mkdir /root/template
mkdir /root/scripts
cp /etc/hosts /root/template/

vim /root/template/hosts
---
___public_ip___  {fqdn}
---

vim /root/scripts/update_hosts.sh
---
#!/bin/sh

PUBLICIP=`curl http://169.254.169.254/latest/meta-data/public-ipv4`
cp -f /root/template/hosts /etc/hosts
sed -i "s/___public_ip___/${PUBLICIP}/g" /etc/hosts
---

vim /etc/rc.local
---
/bin/sh /root/scripts/update_hosts.sh
---

sh /root/scripts/update_hosts.sh

vim /etc/hostname
---
{fqdn}
---

hostname -F /etc/hostname

# 確認
hostname
hostname -f

テスト環境用

vim /etc/profile.d/testenv.sh
---
export PS1="\[\033[1;32m\][\u@\h(TEST) \W]\\$\[\033[0m\] "
---

HVMディスク設定

source /etc/sysconfig/i18n
yum install cloud-utils parted
growpart /dev/{something} {number}

glusterfsのログローテーション修正

vim /etc/logrotate.d/glusterfs
# perform the log rotate every week
#weekly
# keep the backup of 52 weeks
#rotate 52
#missingok

# compress the logs, but from the .2 onwards
#compress
#delaycompress
#notifempty

# Rotate client logs
/var/log/glusterfs/*.log {
  missingok
  compress
  delaycompress
  notifempty
  sharedscripts
  postrotate
  /usr/bin/killall -HUP glusterfs > /dev/null 2>&1 || true
  /usr/bin/killall -HUP glusterd > /dev/null 2>&1 || true
  endscript
}

# Rotate server logs
/var/log/glusterfs/bricks/*.log {
  missingok
  compress
  delaycompress
  notifempty
  sharedscripts
  postrotate
  /usr/bin/killall -HUP glusterfsd > /dev/null 2>&1 || true
  endscript
}

IPTABLES

service iptables stop
iptables -L
service iptables save

SELINUX

setenforce 0
vim /etc/selinux/config
---
SELINUX=disabled
---

再起動

reboot

ディスク設定

resize2fs /dev/{something}