====================================================================================mysql
阿里鏡像站的配置方法:linux
http://mirrors.aliyun.com/nginx
##epel 配置方法sql
###一、備份(若有配置其餘epel源)docker
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
epel(RHEL 7)vim
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)centos
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)緩存
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
Base/Extras/Updates: 默認(國內源)
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/{*.repo,backup}
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo (aliyun)
yum makecache
EPEL:
yum -y install epel-release (國外源)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo (aliyun)
Nginx:
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
MySQL:
yum -y install https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
Zabbix:
# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpmbash
====================================================================================
Base源 [centos7光盤文件]
第三方軟件源 [yum緩存]
服務器
1. 提供基礎軟件包Base
2. 提供update軟件包
3. 提供其它軟件包如nginx, zabbix, docker, hadoop, openstack
[root@yangs ~]# yum -y install vsftpd
[root@yangs ~]# mkdir /var/ftp/{centos6u6,centos7u2}
[root@yangs ~]# systemctl start vsftpd
[root@yangs ~]# systemctl enable vsftpd
配置防火牆
[root@yangs ~]# firewall-cmd --permanent --add-service=ftp
[root@yangs ~]# firewall-cmd --reload
關閉SELinux
[root@yangs ~]# setenforce 0
[root@yangs ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
掛載centos鏡像
[root@yangs ~]# mount -o loop /home/centos7u2.iso /var/ftp/centos7u2
[root@yangs ~]# echo 「mount -o loop /home/centos7u2.iso /var/ftp/centos7u2」 >> /etc/rc.local
[root@yangs ~]# chmod +x /etc/rc.d/rc.local
複製已緩存的Nginx 及依賴包 到自定義YUM倉庫目錄中:
[root@localhost ~]# mkdir /var/ftp/{nginx,zabbix}
YUM緩存:
1. 配置nginx及zabbix源
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
2. 啓動yum緩存安裝nginx
[root@yangs ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1
debuglevel=2
[root@yangs ~]# yum clean all
[root@yangs ~]# yum -y install nginx
[root@yangs ~]# find /var/cache/yum/x86_64/7/ -iname "*.rpm" -exec cp -rf {} /var/ftp/nginx
3. 建立reopdata:
[root@yangs ~]# yum -y install createrepo
[root@yangs ~]# createrepo /var/ftp/nginx //若是加入新軟件包,從新建立
[root@localhost ~]# ls /var/ftp/nginx/
nginx-1.8.1-1.el6.ngx.x86_64.rpm repodata
[root@client ~]# vim /etc/yum.repos.d/centos7.repo //指向基礎源
[centos7]
name=centos7
baseurl=ftp://x.x.x.x/centos7u2
gpgcheck=0
[root@client ~]# vim /etc/yum.repos.d/nginx.repo //指向nginx源
[nginx]
name=nginx
baseurl=ftp://x.x.x.x/nginx
gpgcheck=0
[root@client ~]# yum -y install nginx
1000臺client使用自定義源:
1. Shell script
2. Saltstack, Asible, Puppet
YUM使用簽名檢查機制
rpm軟件提供組織例如redhat在構建rpm包時,使用其private key對rpm進行簽名
client在使用其rpm時,爲了驗證其合法性,能夠使用redhat提供的public key進行簽名檢查
方法一: 事先導入公鑰
[root@localhost ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
方法二: 指定公鑰的位置
[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
額外選項:
--nogpgcheck //不檢查軟件包的簽名
掛載安裝光盤(臨時):
[root@localhost ~]# mount /dev/cdrom /media
[root@localhost ~]# mount -o loop centos7u2.iso /media
[root@localhost ~]# vim /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=file:///media
gpgcheck=0
====================================================================================
====================================================================================自動解決包的依賴關係 ==檢查目前可用的倉庫[root@localhost ~]# yum clean all //清空緩存及其它文件[root@localhost ~]# yum makecache //重建緩存[root@localhost ~]# yum repolist //查詢可用的倉庫==安裝[root@localhost ~]# yum list mariadb-server //查詢[root@localhost ~]# yum install mariadb-server[root@localhost ~]# yum -y install mariadb-server[root@localhost ~]# yum -y install samba[root@localhost ~]# yum -y install mysql* httpd vsftpd samba chrony[root@localhost ~]# yum -y reinstall mariadb-server[root@localhost ~]# yum -y update samba[root@localhost ~]# yum -y update //升級全部軟件包 [剛安裝系統後]==查詢[root@localhost ~]# yum list vsftpd mysql-server //查詢單個軟件包安裝狀況[root@localhost ~]# yum grouplist //查詢包組的包裝狀況[root@localhost ~]# yum info vsftpd //查詢包的信息[root@localhost ~]# yum search chinese //查詢包名和描述中帶有chinese的包[root@localhost ~]# vncviewerbash: vncviewer: command not found[root@localhost ~]# yum provides */vncviewer //查詢指定的文件屬於哪一個包(該文件一般不存在於當前系統)Loaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.rhel6/filelists_db | 3.7 MB 00:00 tigervnc-1.1.0-5.el6.x86_64 : A TigerVNC remote display systemRepo : rhel6Matched from:Filename : /usr/bin/vncviewer[root@localhost ~]# yum -y install tigervnc-1.1.0-5.el6.x86_64 ==卸載[root@localhost ~]# yum -y remove mysql-server[root@localhost ~]# yum -y groupremove mysql-server