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

rpm包定制+yum仓库搭建

时间:2018-04-13 11:05:05      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:rpm包定制

1、实验环境

[root@m01 ~]# cat /etc/redhat-release 

CentOS release 6.9 (Final)

[root@m01 ~]# uname -r 

2.6.32-696.el6.x86_64

[root@m01 ~]# uname -m 

x86_6

[root@oldboy ~]# hostname -I

10.0.0.61 172.16.1.61 


2、实验中所涉及到的目录

mkdir -p /server/scripts   ####创建脚本的存放目录

mkdir -p /home/oldboy/tools  #####创建软件包的存放目录

mkdir -p /application/yum/centos6.9/x86_64/  ####创建yum仓库目录


3、开启yum安装的缓存

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

grep 'keepcache=1' /etc/yum.conf

find /var/cache/ -type f -name "*.rpm"

find /var/cache/ -type f -name "*.rpm"|xargs rm -f   ####清空之前的缓存


4、安装fpm

yum install ruby rubygems ruby-devel -y  ###安装FPM模块

gem sources -a http://mirrors.aliyun.com/rubygems/   ###添加国内的ruby仓库

gem sources --remove http://rubygems.org/    ###移除原生的ruby仓库

gem install fpm -v 1.3.3   ###安装指定的fpm

#####################安装过程中出现下面错误的解决方案#####################

+++++++错误信息+++++++++

[root@m01 ~]# gem install fpm -v 1.3.3 

ERROR:  Error installing fpm:

json requires Ruby version >= 1.9.

+++++++解决方案+++++++++

curl -L get.rvm.io|bash -s stable   

source /etc/profile.d/rvm.sh     #####然后根据结尾的提示执行

rvm -v 

rvm list known   ####列出ruby的版本

rvm install 2.3.0   #####以更新2.3.0为例

ruby -v   ####查看ruby的版本

gem install fpm -v 1.3.3   ####再次执行此条命令即可安装成功



5、FPM实战安装Nginx

####安装nginx

useradd www -s /sbin/nologin -M   ####创建nginx进程用户

yum install openssl-devel pcre-devel -y 

cd /home/oldboy/tools

wget -q http://nginx.org/download/nginx-1.6.3.tar.gz

tar xf nginx-1.6.3.tar.gz 

cd nginx-1.6.3

./configure \

--user=www \ ==>进程用户权限

--group=www \ ==>进程用户组权限

--prefix=/application/nginx-1.6.3 \  ==>设置安装路径

--with-http_ssl_module \  ==>激活状态信息

--with-http_stub_status_module   ==>激活ssl功能

make

make install

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

####创建脚本文件

cd /server/scripts

cat nginx_rpm.sh 

#!/bin/bash 

useradd www -s /sbin/nologin -M 

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

####fpm打包

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


####yum仓库的搭建

####将其移动到/server/yum/centos6.9/x86_64/ 目录中

cp nginx-1.6.3-1.x86_64.rpm /application/yum/centos6.9/x86_64/

yum -y install createrepo  ####安装createrepo

find /var/cache/ -type f -name "*rpm"|xargs cp -t /tmp/

cd /tmp/ && tar zcf nginx_yum.tar.gz *.rpm

cp nginx_yum.tar.gz /application/yum/centos6.9/x86_64/

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

python -m SimpleHTTPServer 80 &>/dev/null &   ###提供yum服务仅在内网中测试使用 长久的方法是搭建http或者nginx

createrepo --update /application/yum/centos6.9/x86_64/  ####在加入新rpm包后需要更新


####修改客户端的yum源

mkdir /tmp/yum/

mv /etc/yum.repos.d/* /tmp/yum/

cd  /etc/yum.repos.d/

cat oldboy.repo 

[oldboy]

name=Server

baseurl=http://10.0.0.61

enable=1

gpgcheck=0

yum clean all 

yum install nginx




FPM实战安装Mysql


####安装mysql

cd /home/oldboy/tools/

rz 

tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz 

mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49

ln -s /application/mysql-5.5.49/ /application/mysql

####建立用户并授权

useradd mysql -s /sbin/nologin -M 

chown -R mysql.mysql /application/mysql

####初始化数据库

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql 

cp /application/mysql/support-files/my-small.cnf /etc/my.cnf 

cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld 

chmod +x /etc/init.d/mysqld 

chkconfig --list mysqld 

chkconfig --add mysqld 

chkconfig --list mysqld 

sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

/etc/init.d/mysqld start 

cp -a  /application/mysql/bin/* /usr/local/sbin/

####创建脚本文件

cd /server/scripts/

cat  mysql_rpm.sh

#!/bin/bash

useradd -s /sbin/nologin -M mysql

ln -s /application/mysql-5.5.49/ /application/mysql

chown -R mysql.mysql /application/mysql-5.5.49/

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql 

/bin/cp /application/mysql/support-files/my-small.cnf /etc/my.cnf 

/bin/cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld 

chmod +x /etc/init.d/mysqld 

chkconfig --add mysqld 

chkconfig --list mysqld 

sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld 

/etc/init.d/mysqld start 

/bin/cp -a /application/mysql/bin/* /usr/local/sbin/

####fpm打包

fpm -s dir -t rpm -n mysql -v 5.5.49 --post-install /server/scripts/mysql_rpm.sh -f /application/mysql-5.5.49 

####建立索引文件

cp /server/scripts/mysql-5.5.49-1.x86_64.rpm /application/yum/centos/x86_64/

createrepo --update /application/yum/centos/x86_64/

####修改客户端的yum源

mkdir /tmp/yum/

mv /etc/yum.repos.d/* /tmp/yum/

cd  /etc/yum.repos.d/

cat oldboy.repo 

[oldboy]

name=Server

baseurl=http://10.0.0.61

enable=1

gpgcheck=0

yum clean all 

yum install mysql


rpm包定制+yum仓库搭建

标签:rpm包定制

原文地址:http://blog.51cto.com/lzhnb/2101617

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