本地yum源部署记录
由于IDC的一些服务器没有外网,不能对外访问。所以打算部署一套内网的yum源环境,以供内网服务器使用。以下简单记录下操作过程:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
1)下载centos6.9和centos7.3的镜像,并挂载 [[email protected] ~] # wget http://mirrors.163.com/centos/6.9/isos/x86_64/CentOS-6.9-x86_64-bin-DVD1.iso
[[email protected] ~] # wget http://mirrors.163.com/centos/7.3.1611/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso
[[email protected] ~] # mount -o loop -t iso9660 CentOS-6.9-x86_64-bin-DVD1.iso /mnt
[[email protected] ~] # mount -o loop -t iso9660 CentOS-7-x86_64-DVD-1611.iso /opt/aa
[[email protected] ~] # ls /mnt/
CentOS_BuildTag images repodata RPM-GPG-KEY-CentOS-Testing-6 EFI isolinux RPM-GPG-KEY-CentOS-6 TRANS.TBL EULA Packages RPM-GPG-KEY-CentOS-Debug-6 GPL RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Security-6 [[email protected] ~] # ls /opt/aa/
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7 EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL 2)部署nginx [[email protected] ~] # yum install -y pcre pcre-devel openssl openssl-devel gcc
[[email protected] ~] # groupadd -r nginx
[[email protected] ~] # useradd -r -g nginx -s /bin/false -M nginx
[[email protected] ~] # cd /usr/loca/src
[[email protected] src] # wget http://nginx.org/download/nginx-1.8.0.tar.gz
[[email protected] src] # tar -zxvf nginx-1.8.0.tar.gz
[[email protected] src] # cd nginx-1.8.0
[[email protected] nginx-1.8.0] # ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
[[email protected] src] # make && make install
[[email protected] ~] # cat /data/nginx/conf/vhosts/yum.conf
server { listen 80;
server_name localhost;
index index.html index.php index.htm;
access_log /data/nginx/logs/access .log main;
error_log /data/nginx/logs/error .log;
location /{
root /data/centos ;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
}
[[email protected] ~] # mkdir -p /data/centos/6/os/x86_64/6/
[[email protected] ~] # mkdir -p /data/centos/7/os/x86_64/7/
[[email protected] ~] # cp -r /mnt/* /data/centos/6/os/x86_64/6/
[[email protected] ~] # cp -r /opt/aa/* /data/centos/7/os/x86_64/7/
[[email protected] ~] # /data/nginx/sbin/nginx -t
[[email protected] ~] # /data/nginx/sbin/nginx -s reload
|
访问http://192.168.1.240
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
然后就可以在客户机上配置自己的本地yum源,如下(其中192.168.1.240是上面yum源部署机的ip) [[email protected] ~] # cat centos6_yum.repo
[base] name=kevin repo baseurl=http: //192 .168.1.240 /6/os/x86_64/6/
gpgcheck=0 enabled=1 [updates] name=kevin update baseurl=http: //192 .168.1.240 /6/os/x86_64/6/
gpgcheck=0 enabled=1 [[email protected] ~] # cat centos7_yum.repo
[base] name=kevin repo baseurl=http: //192 .168.1.240 /7/os/x86_64/7/
gpgcheck=0 enabled=1 [updates] name=kevin update baseurl=http: //192 .168.1.240 /7/os/x86_64/7/
gpgcheck=0 // 不检查key
enabled=1 将上面的centos6或centos7的yum源文件放到客户机的 /etc/yum .repos.d/目录下,然后执行下面两条命令即可:
# mv CentOS-Base.repo CentOS-Base.repo.bak # yum clean all # yum makecache |
------------------------------------------------------------------------------------------------------------------------------------------------------
后续发现yum源里的包不全,有一些rpm的包不存在。发现是刚开始下载centos镜像的时候,只下载了CentOS-6.9-x86_64-bin-DVD1.iso,应该将CentOS-6.9-x86_64-bin-DVD2.iso的镜像也下载下来。
然后挂载到本地,将里面os/x86_64/Packages下的rpm包拷贝到/data/centos/6/os/x86_64/6的Packages下,最后yum makecache就行了。
本文转自散尽浮华博客园博客,原文链接:http://www.cnblogs.com/kevingrace/p/6923717.html,如需转载请自行联系原作者