centos7新安装系统的基本优化

sunfeng 2021-08-04 04:33 阅读数 49 #Linux



安装完centos7.3后,做一些基本的操作
基本操作一:主机名
centos7有一个新的修改主机名的命令hostnamectl
# hostnamectl set-hostname --static li.cluster.com # vim /etc/hosts
--最后加上你的IP与主机名的绑定
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 172.16.13.250  li.cluster.com  li
基本操作二:关闭iptables
# systemctl status firewalld.service --查看firewalld服务的状态,active是启动状态,inactive是关闭状态
# systemctl stop firewalld.service --关闭此服务
# systemctl list-unit-files |grep firewalld --查看firewalld是否开机自动启动
firewalld.service                           enabled
# systemctl disable firewalld.service --类似以前的chkconfig xxx off
# systemctl list-unit-files |grep firewalld firewalld.service                           disabled
基本操作三:关闭selinux
# sed -i 7s/enforcing/disabled/  /etc/selinux/config --改完后,在后面重启系统生效
基本操作四:网络配置
# systemctl stop NetworkManager --停止服务
# systemctl status NetworkManager --查看状态,确认为关闭了
# systemctl disable NetworkManager --设置为开机不自动启动
# vim /etc/sysconfig/network-scripts/ifcfg-enp2s0 --网卡名如果不一样,找到对应的文件就行
BOOTPROTO="static" NAME="enp2s0" DEVICE="enp2s0" ONBOOT="yes" IPADDR=10.10.1.x NETMASK=255.255.255.0 GATEWAY=10.10.1.1 DNS1=114.114.114.114
# /etc/init.d/network restart --network服务这里默认还是可以使用原来的管理方法
# chkconfig network on
开机自启动
基本操作五:yum配置,配置本地yum源
# rm /etc/yum.repos.d/* -rf --这里我删除了它所有的默认的配置(因为这些默认配置要连公网的源,速度太慢)
# vim /etc/yum.repos.d/local.repo --然后自建了本地yum源配置文件
[local] name=local baseurl=file:///yum enabled=1 gpgcheck=0
配置可选163的centos源 163centos源(其实就是centos官方的yum,使用163的国内速度更快) 配置方法两种 a)直接公网连接网易163,优点:速度快,软件包会定期更新
# cd /etc/yum.repos.d/ # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
b)自己编写
# vim /etc/yum.repos.d/cento163.repo
[centos163] name=centos163 baseurl=http://mirrors.163.com/centos/7.3.1611/os/x86_64 enabled=1 gpgcheck=0
配置可选epel源 配置方法两种 a)直接公网连接epel,优点:速度快,软件包会定期更新
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm --此版本信息会随时间推移而变化 # rpm -ivh epel-release-7-10.noarch.rpm
b)自己编写
# vim /etc/yum.repos.d/epel.repo
[epel]
name=epel
baseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64
enabled=1
gpgcheck=0 
配置完上面三个yum后
# yum clean all # yum makecache fast
基本操作六:输入法配置
默认只有拼音中文输入法,需要使用极点五笔输入法,安装过程如下:
# yum install ibus ibus-table-chinese-wubi-jidian
安装完后,需要右上角把用户注销重登录
左上角applications--system tools -- settions -- Region & Language -- +或-你的输入法就可以了
加完之后,使用super+space键进行切换
基本操作七:时间同步
# yum install ntp  ntpdate --安装ntp时间同步相关软件包
# vim /etc/ntp.conf --确认配置文件里有下列的时间同步源
server 0.rhel.pool.ntp.org iburst server 1.rhel.pool.ntp.org iburst server 2.rhel.pool.ntp.org iburst server 3.rhel.pool.ntp.org iburst
# systemctl enable ntpd --设置开机自动启动ntpd
# systemctl start ntpd --立即启动ntpd服务
# date --确认时间与现在时间一致
# ntpdate 0.rhel.pool.ntp.org --如果还没有同步成功,你可以用此命令手动同步一下
另外一个时间服务器的搭建方法
# yum install xinetd -y # vim /etc/xinet.d/time-dgram disable         = no(--yes改为no)
# vim /etc/xinetd.d/time-stream disable         = no (--yes改为no)
# systemctl restart xinetd # systemctl status xinetd # systemctl enable xinetd
客户端同步时间的用法
# rdate -s 时间服务器的ip
基本操作八: 有些命令的参数可以自动补全,如果不能补全,则安装下面的命令(可能需要注销一下)
# yum install bash-completion基本操作九:vnc的配置
# vncpasswd --设定vcn连接的密码
Password: Verify: # x0vncserver --PasswordFile=/root/.vnc/passwd --AlwaysShared=on --AcceptKeyEvents=off AcceptPointerEvents=off &> /dev/null &


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

搜索
标签列表