yum源安装、自定义安装yum、ftp使用方法

1、物理机
禁用 selinux 和 firewalld
修改配置文件 /etc/selinux/config
SELINUX=disabled

禁用 firewalld
systemctl stop firewalld
systemctl mask firewalld

重启系统
#-------------------------------------------#
网络 yum 源
1 安装 FTP 服务
yum install -y vsftpd
/etc/vsftpd/vsftpd.conf
listen=YES
listen_ipv6=NO

systemctl start vsftpd

重启系统
#-------------------------------------------#
网络 yum 源
1 安装 FTP 服务
yum install -y vsftpd
/etc/vsftpd/vsftpd.conf
listen=YES
listen_ipv6=NO

systemctl start vsftpd

验证 ftp 服务
lftp 命令

[root@rootroom9pc01 ~]# yum -y install lftp

[root@rootroom9pc01 ~]# lftp 192.168.4.254/
cd 成功, 当前目录=/                     
lftp 192.168.4.254:/> ls
drwxr-xr-x    8 0        0            2048 Sep 05  2017 centos7
dr-xr-xr-x    5 0        0            2048 Nov 14  2016 ceph
drwxr-xr-x    2 0        0            4096 Aug 03  2017 pub
drwxr-xr-x    2 0        0            4096 Apr 26 13:08 rhel7
drwxrwxrwx    2 0        0            4096 Apr 26 13:08 share
lftp 192.168.4.254:/> 

lftp 192.168.4.254:/> 
!      bzless   debug  get1       local   mrm      recls      set      wait
?      bzmore   dir      glob       login   mv      reconnect  shell    zcat
(      cache    du      help       lpwd    nlist  reget      site     zless
alias      cat       echo   history  ls       open   rels         sleep    zmore
anon      cd       edit   jobs       mget    pget   renlist    slot
at      chmod    eval   kill       mirror  put      repeat     source
attach      close    exit   lcd       mkdir   pwd      reput      suspend
bookmark  cls       fg      less       module  queue  rm         torrent
bye      command  find   lftp       more    quit   rmdir      user
bzcat      connect  get      ln       mput    quote  scache     version
lftp 192.168.4.254:/> 

[root@rootroom9pc01 networks]# systemctl status vsftpd
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
   Active: active (running) 

[root@rootroom9pc01 ~]# yum -y install lftp
 

[root@rootroom9pc01 networks]# systemctl enable vsftpd
[root@web1 ~]# lftp 192.168.4.254
lftp 192.168.4.254:~> ls
drwxr-xr-x    8 0        0            2048 Sep 05  2017 centos7
dr-xr-xr-x    5 0        0            2048 Nov 14  2016 ceph
drwxr-xr-x    2 0        0            4096 Aug 03  2017 pub
drwxr-xr-x    2 0        0            4096 Apr 26 13:08 rhel7
drwxrwxrwx    2 0        0            4096 Apr 26 13:08 share
lftp 192.168.4.254:/> exit
 

[root@web1 ~]# lftp sftp://[email protected]/
口令: 
cd 成功, 当前目录=/                                
lftp [email protected]:/> ls

lftp [email protected]:/> get /iso/rhel-server-7.4-x86_64-dvd.iso
[root@web1 ~]# mv ./rhel-server-7.4-x86_64-dvd.iso  /iso
[root@web1 ~]# ls /iso/
rhel-server-7.4-x86_64-dvd.iso
[root@web1 ~]# mount -t iso9660 -o ro,loop /iso/rhel-server-7.4-x86_64-dvd.iso /var/ftp/pub1
[root@web1 ~]# df -h
文件系统               容量  已用  可用 已用% 挂载点
/dev/mapper/rhel-root   17G  7.0G   11G   41% /
devtmpfs               481M     0  481M    0% /dev
tmpfs                  497M     0  497M    0% /dev/shm
tmpfs                  497M  7.1M  490M    2% /run
tmpfs                  497M     0  497M    0% /sys/fs/cgroup
/dev/vda1             1014M  161M  854M   16% /boot
tmpfs                  100M     0  100M    0% /run/user/0
/dev/loop0             3.8G  3.8G     0  100% /var/ftp/pub1

[root@web1 ~]# vim /etc/fstab 
 

/iso/rhel-server-7.4-x86_64-dvd.iso /var/ftp/pub1  defaults   0 0 
[root@web1 ~]# mount -a
[root@web1 ~]# vim /etc/yum.repos.d/centos.repo

[root@web1 ~]# cat /etc/yum.repos.d/centos.repo
[centos]
name=centos
baseurl=ftp://192.168.4.4/pub1
gpgcheck=0
enabled=1


[root@web1 ~]# yum repolist 
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
centos                                                                       | 4.1 kB  00:00:00     
(1/2): centos/group_gz                                                       | 137 kB  00:00:00     
(2/2): centos/primary_db                                                     | 4.0 MB  00:00:00     
源标识                                         源名称                                          状态
centos                                         centos                                          4,986
rhel7                                          rhel7                                           4,986
repolist: 9,972

ctrl+r  

(reverse-i-search)`lf': lftp sftp://[email protected]/
lftp [email protected]:/> get /root/mysql-community-client-5.7.17-1.el7.x86_64.rpm
25037548 bytes transferred                                                        
lftp [email protected]:/> exit
[root@web1 ~]# ls
anaconda-ks.cfg       mysql-community-client-5.7.17-1.el7.x86_64.rpm  模板  图片  下载  桌面
initial-setup-ks.cfg  公共                                            视频  文档  音乐
[root@web1 ~]# 
 

[root@web1 ~]# mkdir -p /var/ftp/public
[root@web1 ~]# mv  ./mysql-community-client-5.7.17-1.el7.x86_64.rpm /var/ftp/public
[root@web1 ~]# cd /var/ftp/public
[root@web1 public]# createrepo  . 
Spawning worker 0 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@web1 public]# ls
mysql-community-client-5.7.17-1.el7.x86_64.rpm  repodata

(reverse-i-search)`vim': vim /etc/yum.repos.d/centos.repo
[centos1]
name=centos
baseurl=ftp://192.168.4.4/public
gpgcheck=0
enabled=1

[root@web1 public]# yum repolist 
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
centos                                                                       | 4.1 kB  00:00:00     
centos1                                                                      | 2.9 kB  00:00:00     
centos1/primary_db                                                           | 2.8 kB  00:00:00     
源标识                                          源名称                                         状态
centos                                          centos                                         4,986
centos1                                         centos                                             1    //自定义yum源
rhel7                                           rhel7                                          4,986
repolist: 9,973
[root@web1 public]# 

[root@web1 public]# createrepo  --update  .   //可更新

转发 dns 安装配置

[root@rootroom9pc01 ~]# yum install -y bind bind-chroot

listen-on port 53 { 192.168.4.254; };
        #listen-on-v6 port 53 { ::1; };
        allow-query     { any; };
        forwarders { 192.168.1.1; };

      dnssec-enable no;
        dnssec-validation no;

[root@rootroom9pc01 ~]# systemctl restart named
[root@rootroom9pc01 ~]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.
[root@rootroom9pc01 ~]# vim /etc/resolv.conf 
 

# Generated by NetworkManager
search tedu.cn
nameserver 192.168.1.1

[root@rootroom9pc01 ~]# nslookup www.baidu.com
Server:        192.168.1.1
Address:    192.168.1.1#53

Non-authoritative answer:
www.baidu.com    canonical name = www.a.shifen.com.
Name:    www.a.shifen.com
Address: 14.215.177.38
Name:    www.a.shifen.com
Address: 14.215.177.39

时间服务器server
[root@rootroom9pc01 ~]# yum install -y chrony

[root@rootroom9pc01 ~]# vim /etc/chrony.conf
 

server ntp1.aliyun.com iburst
bindacqaddress 0.0.0.0
allow 0/0
 

[root@rootroom9pc01 ~]# systemctl restart chronyd
[root@rootroom9pc01 ~]# systemctl enable chronyd

[root@rootroom9pc01 ~]# chronyc sources -v
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 120.25.115.20                 2   6   177    42    +75us[ +593us] +/- 3111us
[root@rootroom9pc01 ~]# 
 

时间客户端client
[root@web1 public]#  vim /etc/chrony.conf
 

server 192.168.4.254 iburst

[root@web1 public]# date -s 08/15/2015
2015年 08月 15日 星期六 00:00:00 CST

[root@web1 public]# date -s 08/15/2015
2015年 08月 15日 星期六 00:00:00 CST
[root@web1 public]# date 
2015年 08月 15日 星期六 00:00:04 CST
[root@web1 public]# systemctl restart chronyd
[root@web1 public]# systemctl enable chronyd
[root@web1 public]# date 
2018年 07月 17日 星期二 22:33:40 CST
[root@web1 public]# 

//手动更新时间
[root@web1 public]# nt
ntpdate  ntsysv   
[root@web1 public]# ntpdate 192.168.4.254

时间服务器,server、 client


client:配置 /etc/chrony.conf
server server.ip.xx.xx iburst

检查状态
chronyc sources -v
* 同步成功,+ 备胎 , ? 同步失败

shell 命令 exec 重定向

猜你喜欢

转载自blog.csdn.net/weixin_40018205/article/details/81088960