Difference between revisions of "New CentOS 7 Server Setup Commands"
From Labrats.us
Jump to navigationJump to search (Created page with "== Install From Image, with 'minimal install' option == == Post install configuration == === Remove Network Manager software === <pre> # /bin/systemctl disable NetworkManag...") |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
== Post install configuration == | == Post install configuration == | ||
+ | |||
+ | === Update /etc/yum.repo.d/CentOS-Base.repo for archive support === | ||
+ | |||
+ | <pre> | ||
+ | # CentOS-Base.repo | ||
+ | # | ||
+ | # 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] | ||
+ | name=CentOS-$releasever - Base | ||
+ | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra | ||
+ | #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ | ||
+ | baseurl=http://vault.centos.org/7.9.2009/os/$basearch/ | ||
+ | gpgcheck=1 | ||
+ | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 | ||
+ | |||
+ | #released updates | ||
+ | [updates] | ||
+ | name=CentOS-$releasever - Updates | ||
+ | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra | ||
+ | #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ | ||
+ | baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/ | ||
+ | gpgcheck=1 | ||
+ | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 | ||
+ | |||
+ | #additional packages that may be useful | ||
+ | [extras] | ||
+ | name=CentOS-$releasever - Extras | ||
+ | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra | ||
+ | #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ | ||
+ | baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/ | ||
+ | gpgcheck=1 | ||
+ | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 | ||
+ | |||
+ | #additional packages that extend functionality of existing packages | ||
+ | [centosplus] | ||
+ | name=CentOS-$releasever - Plus | ||
+ | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra | ||
+ | #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ | ||
+ | baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/ | ||
+ | gpgcheck=1 | ||
+ | enabled=0 | ||
+ | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 | ||
+ | </pre> | ||
=== Remove Network Manager software === | === Remove Network Manager software === | ||
Line 42: | Line 94: | ||
</pre> | </pre> | ||
− | === Disable selinux | + | === Disable selinux === |
<pre> | <pre> | ||
# setenforce 0 | # setenforce 0 | ||
− | + | # sed -i.bak "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config | |
</pre> | </pre> | ||
Line 55: | Line 107: | ||
# yum -y install finger nc net-snmp net-snmp-perl net-snmp-utils ntp perl-Date-Manip \ | # yum -y install finger nc net-snmp net-snmp-perl net-snmp-utils ntp perl-Date-Manip \ | ||
perl-DBD-SQLite sendmail sendmail-cf sssd tcp_wrappers tcpdump telnet tftp \ | perl-DBD-SQLite sendmail sendmail-cf sssd tcp_wrappers tcpdump telnet tftp \ | ||
− | tog-pegasus traceroute vim-enhanced wget oddjob-mkhomedir net-tools | + | tog-pegasus traceroute vim-enhanced wget oddjob-mkhomedir net-tools yum-cron \ |
+ | bind-utils | ||
+ | </pre> | ||
+ | |||
+ | Alternately, you can leave Postfix and just install needed packages. | ||
+ | |||
+ | <pre> | ||
+ | # yum -y install finger nc net-snmp net-snmp-perl net-snmp-utils ntp perl-Date-Manip \ | ||
+ | perl-DBD-SQLite sssd tcp_wrappers tcpdump telnet tftp tog-pegasus traceroute \ | ||
+ | vim-enhanced wget oddjob-mkhomedir net-tools yum-cron bind-utils | ||
</pre> | </pre> | ||
Line 69: | Line 130: | ||
<pre> | <pre> | ||
# echo "net.ipv4.conf.default.rp_filter = 0" > /etc/sysctl.d/rpfilter.conf | # echo "net.ipv4.conf.default.rp_filter = 0" > /etc/sysctl.d/rpfilter.conf | ||
+ | </pre> | ||
+ | |||
+ | ==Update required Packages== | ||
+ | |||
+ | <pre> | ||
+ | # yum update kernel bash nss nspr ntp glibc cvs | ||
+ | </pre> | ||
+ | |||
+ | ==Reboot Server to apply new kernel== | ||
+ | |||
+ | <pre> | ||
+ | # shutdown -r now | ||
+ | </pre> | ||
+ | |||
+ | ==Remove old kernel so system scans cleanly and update kernel tools== | ||
+ | |||
+ | <pre> | ||
+ | # rpm -qa | grep kernel | ||
+ | # yum -y erase kernel-<old kernel version> | ||
+ | # yum -y update kernel-tools kernel-tools-libs | ||
+ | </pre> | ||
+ | |||
+ | ==Install VM Tools== | ||
+ | |||
+ | If this is a virtual machine, install the open vm tools. | ||
+ | |||
+ | <pre> | ||
+ | # yum -y install open-vm-tools | ||
</pre> | </pre> |
Latest revision as of 22:53, 20 March 2025
Install From Image, with 'minimal install' option
Post install configuration
Update /etc/yum.repo.d/CentOS-Base.repo for archive support
# CentOS-Base.repo # # 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] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://vault.centos.org/7.9.2009/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Remove Network Manager software
# /bin/systemctl disable NetworkManager # /bin/systemctl disable NetworkManager-dispatcher # yum erase NetworkManager-tui NetworkManager-glib NetworkManager
Configure Network
Run the commands below to set up a static ip address (192.168.1.221) and hostname (test-centos-1).
# export remote_hostname=guest1 # export remote_ip=192.168.1.221 # export remote_gateway=192.168.1.1 # hostnamectl set-hostname $remote_hostname # sed -i.bak "s/.*BOOTPROTO=.*/BOOTPROTO=none/g" /etc/sysconfig/network-scripts/ifcfg-eth0 # cat << EOF >> /etc/sysconfig/network-scripts/ifcfg-eth0 IPADDR0=$remote_ip PREFIX0=24 GATEWAY0=$remote_gateway DNS1="216.136.95.2" DNS2="64.132.94.250" NM_CONTROLLED="no" EOF # systemctl restart network # systemctl enable network.service # systemctl enable sshd # systemctl start sshd # echo "checking connectivity" # ping www.google.com
Disable selinux
# setenforce 0 # sed -i.bak "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
Remove Postfix, and add needed packages.
# yum -y erase postfix # yum -y install finger nc net-snmp net-snmp-perl net-snmp-utils ntp perl-Date-Manip \ perl-DBD-SQLite sendmail sendmail-cf sssd tcp_wrappers tcpdump telnet tftp \ tog-pegasus traceroute vim-enhanced wget oddjob-mkhomedir net-tools yum-cron \ bind-utils
Alternately, you can leave Postfix and just install needed packages.
# yum -y install finger nc net-snmp net-snmp-perl net-snmp-utils ntp perl-Date-Manip \ perl-DBD-SQLite sssd tcp_wrappers tcpdump telnet tftp tog-pegasus traceroute \ vim-enhanced wget oddjob-mkhomedir net-tools yum-cron bind-utils
Fix Time Zone
# rm -f /etc/localtime # ln -s /usr/share/zoneinfo/MST7MDT /etc/localtime
Turn off rp_filter
# echo "net.ipv4.conf.default.rp_filter = 0" > /etc/sysctl.d/rpfilter.conf
Update required Packages
# yum update kernel bash nss nspr ntp glibc cvs
Reboot Server to apply new kernel
# shutdown -r now
Remove old kernel so system scans cleanly and update kernel tools
# rpm -qa | grep kernel # yum -y erase kernel-<old kernel version> # yum -y update kernel-tools kernel-tools-libs
Install VM Tools
If this is a virtual machine, install the open vm tools.
# yum -y install open-vm-tools