[base]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7
字段 | 含义 |
---|---|
base | 容器名称,一定要放在[]中 |
name | 容器说明,可以自己随便写 |
mirrorlist | 镜像站点,可以注释掉 |
baseurl | YUM源服务器的地址,默认是CentOS官方的YUM源 |
enable | 此容器是否生效 不写或者写成enable=1表示生效,写成enable=0表示不生效 |
gpgcheck | 如果是1就是指 RPM的数字证书生效,如果是0则表示不生效 |
gpgkey | 数字证书的公钥文件保存位置,不用改 |
使用阿里云镜像
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum -y update //升级所有包同时也升级软件和系统内核
命令 | 含义 |
---|---|
yum list | 查询所有可用软件包列表 |
yum search 关键字 | 搜索服务器上所有和关键字相关的包 |
yum -y install 包名 | -y 自动回答yes install安装 |
yum -y update 包名 | -y 自动回答yes update升级 |
yum -y remove 包名 | -y 自动回答yes remove 卸载,卸载有依赖性,所以尽量不要卸载 |
yum grouplist | 列出所有可用的软件组列表 |
yum groupinstall 软件组名 | 安装指定的组,组名可以用grouplist查询 |
yum groupremove 软件组名 | 卸载指定软件组 |
yum -y install gcc //安装C语言安装包
yum install nginx -y
whereis nginx //查看安装位置
启动服务
/bin/systemctl start nginx.service
/bin/systemctl stop nginx.service
curl http://115.29.148.6/
添加以下内容:
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
yum makecache
就是把服务器的包信息下载到本地电脑缓存起来yum makecache
yum -y install mongodb-org
whereis mongod
vi /etc/mongod.conf
/etc/mongod.conf
net:
port: 27017
# bindIp: 127.0.0.1
systemctl start mongod.service
systemctl stop mongod.service
systemctl status mongod.service
systemctl restart mongod.service
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
mongo 115.29.148.6
yum install redis -y
systemctl start redis.service
systemctl stop redis.service
systemctl status redis.service
systemctl restart redis.service
yum install mysql-community-server -y
/var/cache/yum/x86_64/7/mysql57-community/packages
https://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/
wget https://img.zhufengpeixun.com/mysql5.7-centos7.zip
systemctl start mysqld.service
systemctl stop mysqld.service
systemctl status mysqld.service
systemctl restart mysqld.service
mysql -h115.29.148.6 -uroot -p