安装完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 --设置图形模式为默认模式

一部分脚本:2020.06.19添加

#!/bin/bash
#1. 关闭防火墙
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
#2. 关闭seliunx
sed -i '/SELINUX=/s/enforcing/disabled/' /etc/selinux/config
#临时设置
setenforce 0
#3、ulimit 打开最大文件限制
ulimit_config() {
echo "ulimit -SHn 102400" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
EOF
}
grep 65535 /etc/security/limits.conf || ulimit_config
#4、安装系统基础依赖工具包
yum install net-tools gcc-c++ wget lrzsz vim ntpdate cronolog make psmisc mlocate
#5、设置国内镜像源
rm -f /etc/yum.repos.d/CentOS-Base.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
yum repolist
#6、修改主机名
hostnamectl set-hostname --static vm1
#7、配置网络
systemctl stop NetworkManager
systemctl status NetworkManager
systemctl disable NetworkManager
#配置静态桥接网络,信息根据自己情况改
network_config()
{
#网卡名文件
wk_file=ifcfg-ens33
cd /etc/sysconfig/network-scripts/
cp ${wk_file} /tmp/
cat > ${wk_file} << EOF
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
EOF
}
network_config
systemctl restart network

centos7 装机后的基本配置的更多相关文章

  1. Centos7安装成功后,网卡配置及更改镜像地址为国内镜像

    Centos7安装成功后,网卡配置及更改镜像地址为国内镜像 一.网卡配置 二.修改网络配置 踩坑一:IPADDR 踩坑二:网关,DNS与本地不一致 重启网络服务 三.镜像修改为aliyun 四.相关知 ...

  2. centos7装机和初步运维

    1.装机-制作U盘启动盘 CentOS7是一个比较新的版本.在服务器领域用得比较多.因为前安装软件可能没有Ubuntu那样方便,所以桌面领域好像不是很多. https://www.centos.org ...

  3. centos7系统安装后的基础优化

    1.更改网卡信息 1.编辑网卡 # cd /etc/sysconfig/network-scripts/ # mv ifcfg-ens33 ifcfg-eth0 # mv ifcfg-ens37 if ...

  4. 网络装机pxe服务器的配置过程

    网络装机pxe服务器的配置过程 背景: 针对于Linux运维工作中遇到的需要大批量安装Linux系统的情况,通过网络装机的方式实现无人值守安装Linux操作系统,现需要配置一台pxe服务器用于pxe批 ...

  5. Linux centos系统安装后的基本配置,Linux命令

    一.centos系统安装后的基本配置 .常用软件安装 yum install -y bash-completion vim lrzsz wget expect net-tools nc nmap tr ...

  6. Centos7搭建SS以及加速配置的操作记录 (转载)

    原文地址https://www.cnblogs.com/kevingrace/p/8495424.html 部署 Shadowsocks之前,对它做了一个简单的了解,下面先介绍下.一道隐形的墙众所周知 ...

  7. Linux—CentOS7下python开发环境配置

    CentOS7下python开发环境配置 上一篇博客讲了如何在Centos7下安装python3(https://www.cnblogs.com/zivli/p/9937608.html),这一次配置 ...

  8. Apache系列:Centos7.2下安装与配置apache

    Centos7.2下安装与配置apache(一) 配置机:腾讯云服务器,centos7.2 一.安装Apache服务(Apache软件安装包叫httpd) yum install httpd -y 二 ...

  9. 真实的物理机安装Centos7系统后网卡只有lo没有eno1的解决办法:实际上是物理机未安装网驱动卡

    问题症状: 我真实的物理机安装Centos7系统后,在/etc/sysconfig/目录下查看,发现网卡只有lo没有eno1,出现该问题的实际原因是物理机未安装网驱动卡. 解决办法: 不多说了,让我们 ...

随机推荐

  1. ActiveX 是什么,和IE什么关系

    在推出25年多以后,IE浏览器终于要退役了. 据外媒报道,微软决定自2022年6月15日起,让IE浏览器彻底退出互联网舞台,并全面改用Microsoft Edge浏览器. 关于IE的历史可以参考这篇文 ...

  2. 【Linux】apt软件管理和远程登录

    镜像下载.域名解析.时间同步请点击 阿里云开源镜像站 1. apt 介绍 apt 是 Advanced Packaging Tool 的简称,是一款安装包管理工具.在 Ubuntu 下,可以使用 ap ...

  3. mysql优化参数 (汇总)

    1 如下为128G内存32线程处理器的mariadb配置参数优化: [client]#password= your_passwordport= 3306 socket= /tmp/mysql.sock ...

  4. vue路由-router

    VueRouter基础 vue路由的注册 导入 <script src="https://unpkg.com/vue-router/dist/vue-router.js"&g ...

  5. 74CMS 3.0 存储型XSS漏洞

    一. 启动环境 1.双击运行桌面phpstudy.exe软件 2.点击启动按钮,启动服务器环境 二.代码审计 1.双击启动桌面Seay源代码审计系统软件 2.因为74CMS3.0源代码编辑使用GBK编 ...

  6. WindowsServer域用户批量创建方法

    @font-face { font-family: "Times New Roman" } @font-face { font-family: "宋体" } @ ...

  7. 07模块化设计之top_down

    一设计功能:(一)用两个分频模块,实现16分频,且让输入a 和b在16个系统时钟内,相与一次. (二)模块化设计思想(结构化思维) 拆分,即把一个系统划分成多个功能模块,控制模块,组合模块.然后从功能 ...

  8. Ubuntu一键安装LAMP,LNMP

    参考: https://blog.csdn.net/xueyingqi/article/details/50674078 https://www.cnblogs.com/pengzheng/p/363 ...

  9. pytest配置文件pytest.ini

    说明: pytest.ini是pytest的全局配置文件,一般放在项目的根目录下 是一个固定的文件-pytest.ini 可以改变pytest的运行方式,设置配置信息,读取后按照配置的内容去运行 py ...

  10. Spring cache源码分析

    Spring cache是一个缓存API层,封装了对多种缓存的通用操作,可以借助注解方便地为程序添加缓存功能. 常见的注解有@Cacheable.@CachePut.@CacheEvict,有没有想过 ...