centos7 装机后的基本配置

来源:互联网 发布:电力数据网接入设备 编辑:程序博客网 时间:2024/05/16 09:54

安装完centos7.3后,做一些基本的操作

下面是我的环境的配置,你们可以根据自己的环境搭配相应的配置。修改下就可以了。



基本操作一:主机名
centos7有一个新的修改主机名的命令hostnatctl

# hostnamectl set-hostname --static feng.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.21.250 feng.cluster.com feng ----其中最后的li是主机名的别名
172.16.13.250 feng.cluster.com feng

主机名:内网名字
域名:公网名字
主机名不能是localhost
绑定主机名就相当于内网的dns,非常重要。
绑定主机名的作用?




基本操作二:关闭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=172.16.13.X
NETMASK=255.255.255.0
GATEWAY=172.16.13.254
DNS1=114.114.114.114


# /etc/init.d/network restart --network服务这里默认还是可以使用原来的管理方法
# chkconfig network on



基本操作五:yum配置

1,通过firefox访问下面路径,并下载centos7.3镜像

wget http://172.16.21.250/CentOS-7-x86_64-DVD-1611.iso


# ll CentOS-7-x86_64-DVD-1611.iso--拷贝完后,确认大小一致
-rw-r--r--. 1 qemu qemu 4379901952 Apr 20 04:56 /share/CentOS-7-x86_64-DVD-1611.iso


# mkdir /yum
# mount /share/CentOS-7-x86_64-DVD-1611.iso /yum --我本地的镜像在/share下,我把它挂载到/yum目录

# echo "mount /share/CentOS-7-x86_64-DVD-1611.iso /yum" >> /etc/rc.local
# chmod a+x /etc/rc.d/rc.local
--centos7要把rc.local原文件加执行权限,开机才会自动执行

注意:步骤1只有物理机装centos7系统的才需要做,虚拟机直接挂载镜像即可

2,配置本地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




3,配置可选163的centos源
163centos源(其实就是centos官方的yum,使用163的国内速度更快)
配置方法两种
a)直接公网连接网易163,优点:速度快,软件包会定期更新

# cd /etc/yum.repos.d/
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo


b)使用老师机器上的源(全部从163上下载而来),优点:局域网速度更快,但软件包不能更新(因为我没有写定期去网上同步)

# vim /etc/yum.repos.d/cento163.repo


[centos163]
name=centos163
baseurl=http://172.16.21.250/centos163/
enabled=1
gpgcheck=0


3,配置可选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)使用老师机器上的源(全部从epel上下载而来),优点:局域网速度更快,但软件包不能更新(因为我没有写定期去网上同步)

# vim /etc/yum.repos.d/epel.repo


[epel]
name=epel
baseurl=http://172.16.21.250/epel/
enabled=1
gpgcheck=0



配置完上面三个yum后
# yum clean all
# yum makecache fast

可能遇到的问题:

Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 146 M RSS (556 MB VSZ)
Started: Wed Aug 30 12:40:02 2017 - 20:22 ago
State : Sleeping, pid: 2247
原因:可能是系统自动升级正在运行,yum在锁定状态中。
已经有一个yum进程在运行了,但是使用kill干不掉它。
解决方法:# rm -f /var/run/yum.pid






基本操作六:输入法配置

默认只有拼音中文输入法,我这里需要使用极点五笔输入法(如果不用五笔的话可以不安装),安装过程如下:
# yum -y install ibus ibus-table-chinese-wubi-jidian

安装完后,需要右上角把用户注销重登录

左上角applications--system tools -- settions -- Region & Language -- +或-你的输入法就可以了

加完之后,使用super+space键进行切换






基本操作七:时间同步
# yum -y 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 -y 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 -y install bash-completion




基本操作九:vnc的配置

# vncpasswd
--设定vcn连接的密码
Password:
Verify:

# x0vncserver --PasswordFile=/root/.vnc/passwd --AlwaysShared=on --AcceptKeyEvents=off AcceptPointerEvents=off &> /dev/null &




基本操作十:桌面锁屏

左上角applications--system tools -- settions -- Privacy 设置是否自动锁屏

手动锁屏
super+l



基本操作十一:图形界面快捷键修改
左上角applications--system tools -- settions -- Keyboard -- Shortcuts 去修改自己习惯的快捷键



基本操作十二:设置默认启动级别为图形模式(相当于以前的5级别)

# systemctl get-default
--查看当前的运行模式

# systemctl set-default graphical.target --设置图形模式为默认模式




原创粉丝点击