本地Yum仓库搭建部署
本地yum仓库搭建:
系统:Centos6.5
去阿里镜像下载Centos6的yum源,安装系统eple-release源:
1
2
|
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo #yum install epel-release -y |
安装nginx服务和createrepo 创建yum仓库的命令:
1
2
|
#yum install nginx -y # yum install createrepo |
创建yum仓库/data/yum_repo/rhel6_64,和cdrom挂在点:
1
2
|
#mkdir /data/yum_repo/rhel6_64 -p #mkdir /mnt/cdrom |
将光盘CD挂在到/mnt/cdrom/目录下:
1
|
# mount /dev/cdrom /mnt/cdrom/ |
copy CD中的rpm包到刚创建好的本地yum仓库目录:
1
|
#cp /mnt/cdrom/Packages/* /data/yum_repo/rhel6_64/Packages/ |
将rpm包做成yum仓库的软件包:
1
|
# createrepo /data/yum_repo/rhel6_64/Packages/ |
yum仓库nginx资源映射:
将默认的default.conf文件备份.
1
|
#mv default.conf default.conf.bak |
创建nginx yum.conf文件配置:
1
2
3
4
5
6
7
8
9
|
server { listen 80;
server_name _;
# Load configuration files for the default server block.
include /etc/nginx/default .d/*.conf;
location / {
root /data/yum_repo/rhel6_64 ;
}
} |
编辑nginx.conf文件,开启文件浏览功能,方便web访问yum源,查看是否正确:
1
2
3
4
5
|
http { autoindex on; #开启nginx目录浏览功能
autoindex_exact_size off; #文件大小从KB开始显示
autoindex_localtime on; #显示文件修改时间为服务器本地时间
} |
启动nginx服务:
1
|
#/etc/init.d/nginx start |
web访问nginx地址可以看到软件包目录:
yum源文件配置:
1
2
3
4
5
6
|
# cat cc.repo [rhrl] name=rhel baseurl=http: //192 .168.30.128 /Packages/
enabled=1 #是否开启仓库,1为开启,0为关闭
gpgcheck=0 #是否检查gpgkey,1为开启,0为关闭
|
1
2
|
#yum clean all 清除yum机制的本地缓存的 #yum makecache yum服务器上的软件包信息缓存本地;作用以提高搜索安装软件的速度 |
确认系统中未安装apache软件包,并执行安装,确认yum仓库是否可以提供服务:
1
2
|
#rpm -qa httpd #yum install httpd -y |
安装软件包测试yum源是否ok:
更新本地yum源
将定制的软件包放入本地yum仓库,并更新yum源仓库:
1
2
3
4
5
6
7
8
9
10
|
[[email protected] ~] # mv java-1.7.0_80-1.x86_64.rpm /data/yum_repo/rhel6_64/Packages/
[[email protected] ~] # createrepo --update /data/yum_repo/rhel6_64/Packages/
Spawning worker 0 with 1 pkgs Workers Finished Gathering worker results Saving Primary metadata Saving file lists metadata
Saving other metadata Generating sqlite DBs Sqlite DBs complete |
请本地缓存,缓存yum服务器最新的软件包(如果不清本地缓存,看不到新添加的软件包)
1
2
|
# yum clean all # yum makecache |
卸载系统中已存在的java软件包:
1
|
yum remove -y java |
查看yum源中是否存在自定制的java软件包:
1
2
3
4
5
|
[[email protected] ~] # yum list java
Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile Available Packages java.x86_64 1.7.0_80-1 |
安装java软件包:
1
|
[[email protected] ~] # yum install java.x86_64 -y
|
#确实是否时自己定制的java版本,java是否安装完成.
1
2
3
4
5
6
7
8
9
10
11
12
|
[[email protected] ~] # ls /etc/profile.d/java.sh
/etc/profile .d /java .sh
[[email protected] ~] # cat /etc/profile.d/java.sh
export JAVA_HOME= /usr/local/java
export JRE_HOME= /usr/local/java/jre
export CLASSPATH=.:$JAVA_HOME /lib/dt .jar:$JAVA_HOME /lib/tools .jar:$JRE_HOME /lib :$CLASSPATH
export PATH=$JAVA_HOME /bin :$PATH
[[email protected] ~] # source /etc/profile
[[email protected] ~] # java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode) |
本文转自青衫解衣 51CTO博客,原文链接:http://blog.51cto.com/215687833/1943794