CentOSのIPアドレスをDHCPから取得していたので、固定IPに設定を変更しました。

まず、「ifconfig」「netstat」コマンドを使ってネットワーク情報を取得します。

ifconfig
netstat -nr

/etc/sysconfig/network-scripts/ifcfg-eth0」にネットワーク情報を記入します。

DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.25.134
NETMASK=255.255.255.0
NEWORK=192.168.25.0
BROADCAST=192.168.25.255

/etc/sysconfig/network」にゲートウェイ情報を記入します。
NETWORKING=yes
NETWORKING_IPV6=no
GATEWAY=192.168.25.2

/etc/resolv.conf 」にDNSサーバーの設定を追記
search localdomain
nameserver 192.168.133.2

ネットワークを再起動します。
sudo /etc/init.d/network restart

これで固定IPアドレスに変更完了です。


[root@ufuso ~]# yum install yum-priorities ← yum-prioritiesプラグインをインストール
Setting up Install Process
Package yum-priorities-1.1.16-14.el5.centos.1.noarch already installed and latest version ← 既にインストール済みと出た。いつ入れたんだろ?
Nothing to do

[root@ufuso ~]# vim /etc/yum.repos.d/CentOS-Base.repo ← CentOS-Base.repoの編集
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
priority=1 ← 追加
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-5

#released updates
[updates]
priority=1 ← 追加
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-5

#packages used/produced in the build but not released
[addons]
priority=1 ← 追加
name=CentOS-$releasever – Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
priority=1 ← 追加
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-5

#additional packages that extend functionality of existing packages
[centosplus]
priority=1 ← 追加
name=CentOS-$releasever – Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplu
s
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib – packages by Centos Users
[contrib]
priority=1 ← 追加
name=CentOS-$releasever – Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

■Remi & EPELのパッケージをインストール


[root@ufuso ~]# wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm ← epelのダウンロード
2010-01-27 00:33:39 (40.4 KB/s) – `epel-release-5-3.noarch.rpm’ へ保存完了 [11989/11989]

[root@ufuso ~]# wget http://rpms.famillecollet.com/el5.x86_64/remi-release-5-6.el5.remi.noarch.rpm ← remiのダウンロード
2010-01-27 00:34:11 (15.4 KB/s) – `remi-release-5-6.el5.remi.noarch.rpm’ へ保存完了 [4821/4821]

[root@ufuso ~]# rpm -Uvh remi-release-5-6.el5.remi.noarch.rpm epel-release-5-3.noarch.rpm ← Remi & EPELのパッケージをインストール
警告: remi-release-5-6.el5.remi.noarch.rpm: ヘッダ V4 DSA signature: NOKEY, key ID 00f97f56
警告: epel-release-5-3.noarch.rpm: ヘッダ V3 DSA signature: NOKEY, key ID 217521f6
準備中… ########################################### [100%]
1:epel-release ########################################### [ 50%]
2:remi-release ########################################### [100%]

[root@ufuso ~]# rm -f remi-release-5-6.el5.remi.noarch.rpm epel-release-5-3.noarch.rpm ← ダウンロードした.rpmファイルの削除

[root@ufuso ~]# vim /etc/yum.repos.d/remi.repo ← remi.repoの編集
[remi]
priority=1 ← 追加
name=Les RPM de remi pour Enterprise Linux 5 – $basearch
baseurl=http://rpms.famillecollet.com/el5.$basearch/
http://iut-info.univ-reims.fr/remirpms/el5.$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority

[remi-test]
name=Les RPM de remi en test pour Enterprise Linux $releasever – $basearch
baseurl=http://rpms.famillecollet.com/test-el5.$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[root@ufuso ~]# vim /etc/yum.repos.d/epel.repo ← epel.repoの編集
[epel]
priority=1 ← 追加
name=Extra Packages for Enterprise Linux 5 – $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=0 ← 1を0に変更
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 5 – $basearch – Debug
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 5 – $basearch – Source
#baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

■RPMforgeのパッケージをインストール


[root@ufuso ~]# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm ← RPMforgeのパッケージをダウンロード
2010-01-27 00:35:58 (17.6 KB/s) – `rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm’ へ保存完了 [16697/16697]

[root@ufuso ~]# wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt ← RPM-GPG-KEY.dag.txtをダウンロード
2010-01-27 00:36:04 (61.3 MB/s) – `RPM-GPG-KEY.dag.txt’ へ保存完了 [1672/1672]

[root@ufuso ~]# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm ← RPMforgeのパッケージをインストール
準備中… ########################################### [100%]
パッケージ rpmforge-release-0.5.1-1.el5.rf.x86_64 (rpmforge-release-0.3.6-1.el5.rf.x86_64 より新しいもの) は既にインストールされています。 ← またもや・・・、面目ない

[root@ufuso ~]# rpm -import RPM-GPG-KEY.dag.txt ← RPM-GPG-KEY.dag.txtをインストール

[root@ufuso ~]# rm -f rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm RPM-GPG-KEY.dag.txt ← ダウンロードしたファイルを削除

[root@ufuso ~]# vim /etc/yum.repos.d/rpmforge.repo ← rpmforge.repoの編集
# Name: RPMforge RPM Repository for Red Hat Enterprise 5 – dag
# URL: http://rpmforge.net/
[rpmforge]
name = Red Hat Enterprise $releasever – RPMforge.net – dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 0 ← 1を0に変更
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
priority=1

[root@ufuso ~]# yum -y --enablerepo=remi,epel,rpmforge update mysql-server

 ← MySQLのバージョンアップ
file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.1.42-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_4.1.i386 ← mysql-5.0.77-4.el5_4.1.i386と競合しててインストール失敗

Error Summary
————-

[root@ufuso ~]# yum remove mysql-5.0.77-4.el5_4.1.i386 ← mysql-5.0.77-4.el5_4.1.i386を削除
Removed:
mysql.i386 0:5.0.77-4.el5_4.1

Dependency Removed:
mysql-devel.i386 0:5.0.77-4.el5_4.1

Complete!

[root@ufuso ~]# yum -y --enablerepo=remi,epel,rpmforge update mysql-server

 ← 再度MySQLのバージョンアップ
Installed:
mysql-libs.x86_64 0:5.1.42-1.el5.remi

Dependency Installed:
mysqlclient15.x86_64 0:5.0.67-1.el5.remi

Updated:
mysql-server.x86_64 0:5.1.42-1.el5.remi

Dependency Updated:
mysql.x86_64 0:5.1.42-1.el5.remi mysql-devel.x86_64 0:5.1.42-1.el5.remi

Replaced:
mysqlclient16.x86_64 0:5.1.30-1.el5.remi

Complete!

[root@ufuso ~]# /etc/rc.d/init.d/mysqld restart ← MySQLの再起動
MySQL を停止中: [ OK ]
MySQL を起動中: [ OK ]

[root@ufuso ~]# /etc/init.d/httpd restart ← Apacheの再起動
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]

[root@ufuso ~]# mysql –version ← MySQLのバージョンを確認
mysql Ver 14.14 Distrib 5.1.42, for redhat-linux-gnu (x86_64) using readline 5.1 ← Distrib 5.1.42にバージョンアップされている

パッケージのバージョン確認
パッケージをバージョン確認するには、

rpm -q パッケージ名

と実行します。


全パッケージのバージョン確認
インストールされている全パッケージのバージョン確認するには、

rpm -qa

と実行します。
CentOSをインストール直後、ウェブサーバが起動しているにもかかわらず、

アクセスできないことがある。

そのときは、ファイアウォールの設定を確認してみる


GUI
system-config-securitylevel-tui
コマンドライン
system-config-securitylevel-tui -q --disabled --selinux='disabled'

●コマンド

ntpdate NTPサーバー


ntpdate gpsntp.miz.nao.ac.jp


http://www.venus.dti.ne.jp/~yoshi-o/NTP/NTP-Table.html


●ntpdate の定期的実行


cron を使って ntpdate プログラムを定期的に実行するように指示します。


1、コマンドファイル作成

# vi ntpdate.cron

内容↓

#!/bin/sh
/usr/sbin/ntpdate gpsntp.miz.nao.ac.jp


2、実行権限の付与


以下のように実行して /etc/cron.daily/ntpdate.cron ファイルに実行権限を与えます。


# chmod 755 ntpdate.cron


3、自動実行の設定

crontab -ell

15分おきに実行の場合

15 * * * * /root/ntpdate.cron

/root/ntpdate.cron

例えばsnmpdの自動起動設定。

1.現在の設定確認

/sbin/chkconfig –list|grep snmpd

【応答例】

snmpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

上記例では、2,3,4,5がonで無いので、自動起動されない。

2.設定する。

# /sbin/chkconfig snmpd on

rootユーザで実行。

3.確認する

/sbin/chkconfig –list|grep snmpd

snmpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

設定完了。

Linuxサーバのホスト名を変更します。

2箇所のファイルの変更が必要になります。

#vi /etc/hosts
127.0.0.1 xxxx localhost.localdomain localhost

#vi etc/sysconfig/network

HOSTNAME=xxxx

変更が終わった後は、ネットワークの再起動を行います。

# /etc/rc.d/init.d/network restart

Force use of LBA32 (not normally required)オプションを使うと、/bootパーティションの1,024シリンダの制限を超えることができます。1,024シリンダの制限を超えるオペレーティングシステムを起動するためのLBA32拡張をサポートするシステムがあり、/bootパーティションをこの制限より上に置こうとしていて、インストールプログラムがまだBIOSからこの拡張を検出していない場合、Force use of LBA32 (not normally required)を選択する必要があります。

他のオペレーティングシステムが使用しているパーティションを含め、ブート可能なすべてのパーティションが表示されています。 Red Hat Linux Advanced Server システムのルート(/)ファイルシステムを保持しているパーティションのBoot labelは、Red Hat Linuxになっています。他のパーティションにもブートラベルを付けることができます。他のパーティションにブートラベルを追加する場合(または既存のブートラベルを変更する場合)は、対象のパーティションを1回クリックして選択します。選択した後で、Boot labelテキストボックスに入力されている名前を編集することにより、ブートラベルを変更できます。

ハードウェア クロックはローカル時表記なのに、CentOS 的には世界標準時表記だと思っているため、

日本の時差+9:00ぶんだけさらに加算されるから起こるみたい。

というわけで、ハードウェア クロックはローカル時間ですよということを明示してあげればよいらしい。

/etc/sysconfig/clock

ZONE="Asia/Tokyo"
UTC=false
ARC=false

ファイルを変更したら再起動させる。