Posts Tagged ‘centos’

Minimal Post Configuration for CentOS

service yum-updatesd stop
chkconfig yum-updatesd off
service avahi-daemon stop
chkconfig avahi-daemon off
service bluetooth stop
chkconfig bluetooth off
service cups stop
chkconfig cups off
service ip6tables stop
chkconfig ip6tables off
service iptables stop
chkconfig iptables off
yum install screen -y
yum install strace -y
yum install ntp -y
chkconfig ntpd on
mv /etc/ntp.conf /etc/ntp.conf.orig
cat > /etc/ntp.conf << EOF
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
EOF
chkconfig ntpd on
yum update -y
reboot
Posted: October 7th, 2009
Categories: centos
Tags:
Comments: No Comments.

Installing & Configuring NTP on Linux CentOS & RHEL

yum install ntp -y
mv /etc/ntp.conf /etc/ntp.conf.orig
cat > /etc/ntp.conf << EOF
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
fudge  127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
EOF
chkconfig ntpd on
service ntpd restart
ntpq -p
Posted: October 6th, 2009
Categories: centos, linux, rhel
Tags: , , ,
Comments: No Comments.

Installing & Configuring PXEboot TFTP Server for Kickstart on RHEL or CentOS

  • PXEboot TFTP Server
  • Kickstart Server
yum install tftp-server xinetd -y
cat &gt; /etc/xinetd.d/tftp &lt;&lt; EOF
service tftp
{
socket_type             = dgram
protocol                = udp
wait                    = yes
user                    = root
server                  = /usr/sbin/in.tftpd
server_args             = -s /tftpboot
disable                 = no
per_source              = 11
cps                     = 100 2
flags                   = IPv4
}
EOF
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/.
chmod 644 /tftpboot/pxelinux.0
mkdir /tftpboot/pxelinux.cfg
cat &gt; /tftpboot/pxelinux.cfg/default &lt;&lt; EOF
default install
prompt 1
display pxeboot.msg
label install
kernel vmlinuz
append initrd=initrd.img
label kickstart-server01
kernel vmlinuz
append ksdevice=eth0 console=ttyS0,38400 console=tty0 load_ramdisk=1 initrd=initrd.img network ks=http://10.10.10.10/server01.cfg
EOF
cd /tftpboot
wget http://mirrors.atlanticmetro.net/centos/5/os/i386/isolinux/vmlinuz
wget http://mirrors.atlanticmetro.net/centos/5/os/i386/isolinux/initrd.img
wget http://mirrors.atlanticmetro.net/centos/5/os/i386/isolinux/memtest
wget http://mirrors.atlanticmetro.net/centos/5/os/i386/isolinux/boot.msg
wget http://mirrors.atlanticmetro.net/centos/5/os/i386/isolinux/splash.lss
mv boot.msg pxeboot.msg
service xinetd restart
Posted: December 4th, 2008
Categories: centos, linux, rhel
Tags: , , , ,
Comments: No Comments.

Issue with LDAP on RHEL or CentOS

If you bump into the following message on your box.

Checking configuration files for slapd:
bdb_db_open: unclean shutdown detected; attempting recovery.
bdb_db_open: Recovery skipped in read-only mode.
Run manual recovery if errors are encountered.

Change the ownership of /var/lib/ldap/DB_CONFIG to be owned by the user ldap and group ldap, then restart ldap.

chown ldap:ldap /var/lib/ldap/DB_CONFIG
service ldap restart

If you do have a issue with your database, you can try to repair it.

/usr/sbin/slapd_db_recover -v -h /var/lib/ldap
Posted: December 2nd, 2008
Categories: centos, directory services, ldap, linux, os, rhel
Tags: , , ,
Comments: No Comments.

Installing & Configuring SNMP on RHEL or CentOS

The script below was used to install and configure SNMP on a RHEL or CentOS box to act as a SNMP agent. This is a minimal configuration which can be tweaked for more functionality. In summary, the script does the following:

  1. Install net-snmp
  2. Setup snmpd.conf (minimal) configuration file
  3. Enable net-snmp to startup upon bootup
  4. Startup net-snmp
yum install net-snmp -y
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
<br />
cat &gt; /etc/snmp/snmpd.conf &lt;&lt; EOF
rocommunity public
com2sec  local       localhost        public
com2sec  network_1   172.16.0.0/24    public
com2sec  network_2   192.168.0.0/24   public
group    MyROGroup_1        v1                local
group    MyROGroup_1        v1                network_1
group    MyROGroup_2        v2c               network_2
view all-mibs         included   .1           80
access  MyROGroup_1  ""       v1       noauth    exact  all-mibs none   none
access  MyROGroup_2  ""       v2c      noauth    exact  all-mibs none   none
EOF
chkconfig snmpd on
service snmpd restart
Posted: November 26th, 2008
Categories: centos, linux, rhel
Tags: , , ,
Comments: No Comments.

Installing & Configuring NTP on RHEL or CentOS

The script below was used to configure the RHEL or CentOS host to act as an NTP client to the CentOS NTP pool. In summary, the script below does the following:

  1. Install ntp
  2. Setup the ntp.conf configuration file
  3. Enable ntp to startup upon bootup
  4. Startup ntp
  5. Execute ntpq to verify the box is acting as a ntp client
yum install ntp -y
cp /etc/ntp.conf /etc/ntp.conf.orig
<br />
cat &gt; /etc/ntp.conf &lt;&lt; EOF
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
EOF
chkconfig ntpd on
service ntpd restart
ntpq -p
Posted: November 26th, 2008
Categories: centos, linux, rhel
Tags: , ,
Comments: No Comments.

Installing & Configuring DoveCot for RHEL of CentOS

The following is the script I use to install and configure DoveCot on RHEL of CentOS. In summary, the script is doing the following:

  1. Installing DoveCot
  2. Setup the dovecot.conf configuration file
  3. Enabling dovecot to start upon bootup
  4. Startup dovecot
yum install dovecot -y
cp /etc/dovecot.conf /etc/dovecot.conf.orig
cat &gt; /etc/dovecot.conf &lt;&lt; EOF
protocols = imap imaps
protocol imap {
}
protocol lda {
postmaster_address = postmaster@domain.com
}
auth default {
mechanisms = plain
passdb pam {
}
userdb passwd {
}
user = root
}
dict {
}
plugin {
}
EOF
chkconfig dovecot on
service dovecot restart

Once the script is completed, you can go ahead and use your mail client to connect to your server. The configuration file used here is for a IMAP(s) mail server.

Posted: November 26th, 2008
Categories: Uncategorized
Tags: , ,
Comments: No Comments.

Installing & Configuring Postfix on RHEL or CentOS

Below is the script I use to install and configure Postfix. My configuration requires that I use a outbound relay host, a smtp server from Postini. In summary, this script will do the following:

  1. Install Postfix
  2. Setup the main.cf configuration file
  3. Setup the virtual configuration file
  4. Execute postmap on the virtual file
  5. Enable Postfix to start upon bootup
  6. Disable Sendmail
  7. Shutdown Sendmail
  8. Startup Postfix
yum install postfix -y
cp /etc/postfix/main.cf /etc/postfix/main.cf.orig
cat &gt; /etc/postfix/main.cf &lt;&lt; EOF
myhostname = mail01.srv.domain.com
myorigin = $myhostname
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 192.168.0.0/24
virtual_alias_domains = domain.com domain2.com
virtual_alias_maps = hash:/etc/postfix/virtual
relayhost = outboundsXXX.obsmtp.com # postini
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
inet_interfaces = localhost, mail01
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.3.3/samples
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
EOF
cp /etc/postfix/virtual /etc/postfix/virtual.orig
cat &gt; /etc/postfix/virtual &lt;&lt; EOF
# postmap /etc/postfix/virtual
postmaster@domain.com           user1
user1@domain.com                user1
user.one@domain.com             user1
@domain.com                     user1
postmaster@domain2.com  user1
@domain2.com                    user1
EOF
postmap /etc/postfix/virtual
chkconfig --add postfix
chkconfig postfix on
chkconfig sendmail off
service sendmail stop
service postfix restart
Posted: November 26th, 2008
Categories: Uncategorized
Tags: , ,
Comments: No Comments.

Installing & Configuring Cacti on RHEL or CentOS

Below are the contents of a script I use to install cacti on either RHEL or CentOS. In summary, the script does the following.

  1. Configures the rpmforge repository
  2. Updates all the rpms on the box
  3. Removes 1.2.28 of RRDtool (currently broken)
  4. Installs 1.2.27 of RRDtool
  5. Installs Cacti
  6. Installs MySQL
  7. Enables MySQL & Apache to start on bootup
  8. Starts MySQL & Apache
  9. Initialize the Cacti database
  10. Adds the poller job to root crontab
  11. Update the cacti.conf file for Apache

With that said, you can go ahead and login to Cacti and configure Cacti. If you need more help on Cacti, refer to documentation on Cacti’s website.

cd /tmp
# Setup rpmforge repo
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum update -y
# rrdtool 1.2.28 is broken - remove 1.2.28 and install 1.2.27
yum remove rrdtool -y
rpm -ivh ftp://rpmfind.net/linux/EPEL/5Client/i386/rrdtool-1.2.27-3.el5.i386.rpm
# install cacti et al
yum install cacti -y
yum install mysql-server -y
chkconfig mysqld on
chkconfig httpd on
service mysqld start
service httpd start
mysqladmin --user=root create cacti
cd /var/www/cacti
mysql cacti < cacti.sql
cat > /tmp/perm.sql << EOF
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser';
flush privileges;
exit
EOF
mysql mysql < /tmp/perm.sql
cat >> /var/spool/cron/root  << EOF
*/5 * * * * cacti php /var/www/cacti/poller.php > /dev/null 2>&1
EOF
cat > /etc/httpd/conf.d/cacti.conf << EOF
Alias /cacti/ /var/www/cacti/
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
deny from all
#allow from 127.0.0.1
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
EOF
service httpd restart
echo "Login to the server via browser at http://`hostname`/cacti/index.php"
echo "login and password is admin"
Posted: November 26th, 2008
Categories: Uncategorized
Tags: , ,
Comments: No Comments.

Configure RHEL5 to use CentOS Repos

If you installed RHEL5 and you no longer have a subscription for Red Hat Support. You can use the CentOS repos to keep your software up to date. To make a long story shorter here, CentOS removes any Red Hat branding and artwork. For more information about CentOS, visit http://www.centos.org

Now, let’s get your box setup to use the CentOS repos.

First things first, import the key.

rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 yum list

Now create a file called /etc/yum.repos.d/CentOS.repo. Include the following in the CentOS.repo file.

[base] name=CentOS-5 - Base mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates [updates] name=CentOS-5 - Updates mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=updates#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released[addons] name=CentOS-5 - Addons mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=addons #baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful [extras] name=CentOS-5 - Extras mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages [centosplus] name=CentOS-5 - Plus mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=plus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

Now, you can run `yum update` to update the rpms on your RHEL5 box using the CentOS repos.

Posted: June 10th, 2008
Categories: Uncategorized
Tags: , ,
Comments: No Comments.