centos7 查看开启 IP
# 查看
ip addr
# 如果ens33没有inet这个属性 则需要开启
vi /etc/sysconfig/network-scripts/ifcfg-ens33 # 设置ONBOOT=yes
# 重启网络服务
service network restart
# 查看
ip addr
centos7关闭防火墙
# 查看防火墙状态 绿的running表示防火墙开启
systemctl status firewalld.service
# 执行关闭命令
systemctl stop firewalld.service
# 执行开机禁用防火墙自启命令
systemctl disable firewalld.service
常用操作
# 查看主机名
hostnamectl status
# 修改主机名
hostnamectl set-hostname <name>
yum常用操作
# 更新软件包缓存
sudo yum makecache
# 更新
yum update
# 显示系统中已经安装过的包
yum list installed
centos7 配置清华源镜像
# 备份
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# 修改CentOS-Base.repo参照下面文件内容
sudo vi /etc/yum.repos.d/CentOS-Base.repo
# 更新软件包缓存
sudo yum makecache
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
yum安装软件报错:获取GPG密钥失败
rpm --import /etc/pki/rpm-gpg/RPM*
centos7 安装 vim
sudo yum install vim*
centos7安装net-tools
sudo yum install -y net-tools
centos安装wget
yum -y install wget
centos7安装openjdk
# 查看可用的JDK软件包列表
yum search java | grep -i --color JDK
# 安装
yum install java-1.8.0-openjdk.x86_64
centos7 安装 pgsql12
# 安装rpm
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 安装server
sudo yum install -y postgresql12-server
# 初始化
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
# 设置开机自启动
sudo systemctl enable postgresql-12
# 启动服务
sudo systemctl start postgresql-12
centos7安装mysql8
# 下载源
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
# 安装源
yum localinstall mysql80-community-release-el7-3.noarch.rpm
# 检查是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
# 安装
yum install mysql-community-client mysql-community-server