码迷,mamicode.com
首页 > 其他好文 > 详细

yum仓库+fpm定制rpm包

时间:2017-03-28 14:30:03      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:yum   fpm   rpm   

试验环境:

ip:yum 10.0.0.201 yum仓库

    web 10.0.0.8 web(未安装nginx)


yum端安装:

第一个里程碑:创建定制的rpm包

1.开启rpm包的缓存

sed -i ‘s#keepcache=0#keepcache=1#g‘ /etc/yum.conf

2.清空已有缓存

find /var/cache/ -type f -name ‘*rpm‘|xargs rm -f

3.编译安装nginx

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

yum -y install pcre-devel openssl-devel gcc-c++

rz

cd /home/oldboy/tools/

useradd www -M -s /sbin/nologin

tar xf nginx-1.10.2.tar.gz

cd nginx-1.10.2

./configure --prefix=/application/nginx-1.10.2 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module

make && make install

ln -s /application/nginx-1.10.2/ /application/nginx

mv /application/nginx/conf{,.bak}

scp  10.0.0.8:/application/nginx-1.10.2/conf /application/nginx-1.10.2/

4.编写安装yum后执行的脚本

vim /server/scripts/nginx_rpm.sh

#!/bin/bash

useradd nginx -M -s /sbin/nologin

ln -s /application/nginx-1.6.3/ /application/nginx

5安装rpbbuid 

yum install rpm-build

6安装fpm(基于ruby)

yum -y install ruby rubygems ruby-devel

最新ruby仓库:

最新ruby仓库:

gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/

移除原生的ruby仓库

gem sources --remove http://rubygems.org/

查看ruby仓库

gem sources -l

安装fpm

gem install json -v 1.8.3

gem install fpm -v 1.3.3

检查fpm是否安装成功

fpm --help

7定制制作nginx的rpm包

fpm -s dir -t rpm -n nginx -v 1.10.2 -d ‘pcre-devel,openssl-devel‘ --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.10.2/

第二个里程碑:创建yum仓库

1.创建yum仓库根目录(不要妄图该目录,要不然客户端安装会有错误很坑的)

mkdir -p /application/yum/centos6/x86_64/

cd /application/yum/centos6/x86_64

find /var/cache/ -type f -name ‘*rpm‘|xargs cp -t /application/yum/centos6/x86_64/

2.上传rpm包

rz #s上传rpm包到此目录,此目录下马还可以包括文件夹中

cp /home/oldboy/tools/*rpm .此处把备份在tools下的rmp包复制到了当前目录

4.安装createrepo软件 用于生成yum仓库数据库的软件

yum install createrepo -y

5.初始化repodata索引文件

createrepo -pdo /application/yum/centos6/x86_64/ /application/yum/centos6/x86_64/

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+初始化以后如果每加入一个rpm包就要更新一下,看清楚update前面是2个横线  +

+createrepo --update /application/yum/centos6/x86_64/base/            +

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

6.因为我们要使用的客户端想要使用http方式来下载,所以我们需要更改我们的nginx

vim /application/nginx/conf/nginx.conf

============================

worker_processes  1;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {

        listen       80;

        server_name  localhost;

        location / {

   

            root   /application/yum/centos6/x86_64;    配置文件添加了这2条

            autoindex on;

            index  index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

}

}

==============================

检查语法重启nginx

/application/nginx/sbin/nginx -t

/application/nginx/sbin/nginx

进行检测

Windows端打开浏览器:10.0.0.201看看是不是可以下载的那种

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Index of /   +

  +

--------------------------------------------------------------------------------   +

  +

../   +

repodata/                                          20-Mar-2017 06:59                   -   +

cloog-ppl-0.15.7-1.2.el6.x86_64.rpm                20-Mar-2017 06:57               95248   +

compat-readline5-5.2-17.1.el6.x86_64.rpm           20-Mar-2017 06:57              132636   +

cpp-4.4.7-17.el6.x86_64.rpm                        20-Mar-2017 06:57             3908556   +

gcc-4.4.7-17.el6.x86_64.rpm                        20-Mar-2017 06:57            10601824   +

gcc-c++-4.4.7-17.el6.x86_64.rpm                    20-Mar-2017 06:57             4950008   +

keyutils-libs-devel-1.4-5.el6.x86_64.rpm           20-Mar-2017 06:57               29456   +

krb5-devel-1.10.3-57.el6.x86_64.rpm                20-Mar-2017 06:57              515904   +

libcom_err-devel-1.41.12-22.el6.x86_64.rpm         20-Mar-2017 06:57               33424   +

libselinux-devel-2.0.94-7.el6.x86_64.rpm           20-Mar-2017 06:57              140160   +

libsepol-devel-2.0.41-4.el6.x86_64.rpm             20-Mar-2017 06:57               65484   +

libstdc++-devel-4.4.7-17.el6.x86_64.rpm            20-Mar-2017 06:57             1676532   +

mpfr-2.4.1-6.el6.x86_64.rpm                        20-Mar-2017 06:57              160772   +

nginx-1.10.1-1.x86_64.rpm                          20-Mar-2017 06:57             2471456   +

openssl-1.0.1e-48.el6_8.4.x86_64.rpm               20-Mar-2017 06:57             1598916   +

openssl-devel-1.0.1e-48.el6_8.4.x86_64.rpm         20-Mar-2017 06:57             1227412   +

pcre-devel-7.8-7.el6.x86_64.rpm                    20-Mar-2017 06:57              327960   +

ppl-0.10.2-11.el6.x86_64.rpm                       20-Mar-2017 06:57             1322280   +

redhat-rpm-config-9.0.3-51.el6.centos.noarch.rpm   20-Mar-2017 06:57               61640   +

rpm-build-4.8.0-55.el6.x86_64.rpm                  20-Mar-2017 06:57              133912   +

ruby-1.8.7.374-4.el6_6.x86_64.rpm                  20-Mar-2017 06:57              551232   +

ruby-devel-1.8.7.374-4.el6_6.x86_64.rpm            20-Mar-2017 06:57              325868   +

ruby-irb-1.8.7.374-4.el6_6.x86_64.rpm              20-Mar-2017 06:57              324992   +

ruby-libs-1.8.7.374-4.el6_6.x86_64.rpm             20-Mar-2017 06:57             1732652   +

ruby-rdoc-1.8.7.374-4.el6_6.x86_64.rpm             20-Mar-2017 06:57              389836   +

rubygems-1.3.7-5.el6.noarch.rpm                    20-Mar-2017 06:57              211764   +

vsftpd-2.2.2-21.el6.x86_64.rpm                     20-Mar-2017 06:57              158832   +

zlib-devel-1.2.3-29.el6.x86_64.rpm                 20-Mar-2017 06:57               44984   +

  +

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

客户端操作:

1.更改yum源

cd /etc/yum.repos.d

mkdir yum_bak && mv *repo yum_bak

vim oldboyedu.repo

------------------

[oldboyedu]

name=Server

baseurl=http://10.0.0.201

enabled=1

gpgcheck=0

-----------------

2.清理一些缓存

yum clean all  清空本机已有yum缓存

yum list  列表显示yum仓库

3.然后yum install -y nginx 测试

第三个里程碑:同步公网yum源

/usr/bin/rsync -av --delete rsync://mirrors.usts.edu.cn/centos/6/os/x86_64/ /data/yum_data/centos/6/os/x86_64/

/usr/bin/rsync -av --delete rsync://mirrors.usts.edu.cn/extras/6/extras/x86_64/ /data/yum_data/centos/6/extras/x86_64/

/usr/bin/rsync -av --delete rsync://mirrors.usts.edu.cn/updates/6/updates/x86_64/ /data/yum_data/centos/6/updates/x86_64/

/usr/bin/rsync -av --delete rsync://mirrors.usts.edu.cn/updates/6/os/x86_64/ /data/yum_data/centos/6/updates/x86_64/

/usr/bin/rsync -avn --delete rsync://mirrors.usts.edu.cn/centos/6/os/x86_64/ /data/yum_data/centos/6/os/x86_64/


本文出自 “我的学习” 博客,请务必保留此出处http://shuai12138.blog.51cto.com/10118203/1911016

yum仓库+fpm定制rpm包

标签:yum   fpm   rpm   

原文地址:http://shuai12138.blog.51cto.com/10118203/1911016

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!