8月4日 實(shí)現(xiàn)多系統(tǒng)網(wǎng)絡(luò)yum服務(wù)器和第三方的yum倉庫

1唉俗、centos7 實(shí)現(xiàn)多系統(tǒng)網(wǎng)絡(luò)yum服務(wù)器

  • 關(guān)閉防火墻
[root@centos7 ~]#systemctl stop firewalld.service ---馬上關(guān)閉防火墻
[root@centos7 ~]#iptables -vnL  ---查看防火墻
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
[root@centos7 ~]#systemctl disable firewalld.service ---開機(jī)自動關(guān)閉防火墻
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service
  • 關(guān)閉SElinux
[root@centos7 ~]#setenforce 0 ---馬上關(guān)閉SElinux
[root@centos7 ~]#getenforce ---查看SElinux是否關(guān)閉
Permissive
或者更改配置文件 /etc/selinux/config中SELINUX=permissive
  • 安裝ftp服務(wù)包并啟動ftp服務(wù)
[root@centos7 ~]#rpm -ivh /misc/cd/Packages/vsftpd-3.0.2-21.el7.x86_64.rpm Preparing...                          ################################# [100%]
Updating / installing...
   1:vsftpd-3.0.2-21.el7              ################################# [100%]
[root@centos7 ~]#rpm -ql vsftpd ---查看ftp服務(wù)包生成哪些文件
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/lib/systemd/system-generators/vsftpd-generator
/usr/lib/systemd/system/vsftpd.service ---vsftpd的服務(wù)名
/usr/lib/systemd/system/vsftpd.target
/usr/lib/systemd/system/vsftpd@.service
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-3.0.2
/usr/share/doc/vsftpd-3.0.2/AUDIT
/usr/share/doc/vsftpd-3.0.2/BENCHMARKS
/usr/share/doc/vsftpd-3.0.2/BUGS
/usr/share/doc/vsftpd-3.0.2/COPYING
/usr/share/doc/vsftpd-3.0.2/Changelog
/usr/share/doc/vsftpd-3.0.2/EXAMPLE
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-3.0.2/FAQ
/usr/share/doc/vsftpd-3.0.2/INSTALL
/usr/share/doc/vsftpd-3.0.2/LICENSE
/usr/share/doc/vsftpd-3.0.2/README
/usr/share/doc/vsftpd-3.0.2/README.security
/usr/share/doc/vsftpd-3.0.2/REWARD
/usr/share/doc/vsftpd-3.0.2/SECURITY
/usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST
/usr/share/doc/vsftpd-3.0.2/SIZE
/usr/share/doc/vsftpd-3.0.2/SPEED
/usr/share/doc/vsftpd-3.0.2/TODO
/usr/share/doc/vsftpd-3.0.2/TUNING
/usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub    ---存放yum倉庫的位置
[root@centos7 ~]#systemctl start vsftpd  ---啟動ftp服務(wù)
vsftpd@         vsftpd.service  vsftpd.target   
[root@centos7 ~]#ss -tnl  ---查看ftp服務(wù)對應(yīng)的21端口是否打開
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128          *:111                      *:*                  
LISTEN     0      5      192.168.122.1:53                       *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      128    127.0.0.1:631                      *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::111                     :::*                  
LISTEN     0      32          :::21                      :::*         ---確認(rèn)已經(jīng)打開         
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      128        ::1:631                     :::*                  
LISTEN     0      100        ::1:25                      :::*                  
[root@centos7 ~]#systemctl enable vsftpd  ---設(shè)置成開機(jī)自動啟動ftp服務(wù)
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
  • 準(zhǔn)備yum 系統(tǒng)安裝包
mkdir -p /var/ftp/pub/centos/{6,7} 
cp -r /run/media/root/CentOS\ 7\ x86_64/* /var/ftp/pub/centos/7
cp -r /run/media/root/CentOS\ 6\ x86_64/* /var/ftp/pub/centos/6  ---此步驟需要將centos7的光盤卸載嗓蘑,然后換上centos6的光盤
  • 客戶端配置
[basecentos]
name=centos 
baseurl=ftp://192.168.25.144/pub/centos/$releasever/
gpgcheck=0

2、用gcc將c語言編譯成可執(zhí)行的二進(jìn)制内舟,用javac和java將java解析執(zhí)行

[root@centos7 app]#ls
hello.c  Hello.java  music  music.sh  test
[root@centos7 app]#gcc hello.c 
[root@centos7 app]#ls
a.out  hello.c  Hello.java  music  music.sh  test
[root@centos7 app]#./a.out 
Hello,world
[root@centos7 app]#gcc hello.c -o hello   ---默認(rèn)情況下解析成二進(jìn)制后名字為a.out合敦,可以用-o指定名字
yum install java-1.8.0-openjdk-devel.x86_64 ---安裝javac命令包
[root@centos7 app]#javac Hello.java ---注意對大小寫敏感
[root@centos7 app]#ls ---生成中間代碼Hello.class
a.out  hello  hello.c  Hello.class  Hello.java  music  music.sh  test
[root@centos7 app]#java Hello ---解析執(zhí)行,不用帶class
Hello,java

3验游、第三方的yum倉庫

有的時候我們在第三方平臺上下載一些rpm軟件包充岛,想要安裝,就要利用這些包自建倉庫耕蝉,生成它們對應(yīng)的元數(shù)據(jù)崔梗,也就是repodata這目錄,才能用yum進(jìn)行安裝垒在。

[root@centos7 app]#yum install httpd ---安裝http服務(wù)
[root@centos7 app]#rpm -ql httpd  ---查看服務(wù)對應(yīng)生成的文件
/usr/lib/systemd/system/httpd.service  ---http服務(wù)名
var/www/html  ---存放倉庫的位置
[root@centos7 app]#systemctl start httpd.service ---啟動http服務(wù)
[root@centos7 app]#ss -ntl  --查看http對應(yīng)的端口是否打開
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128          *:111                      *:*                  
LISTEN     0      5      192.168.122.1:53                       *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      128    127.0.0.1:631                      *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::111                     :::*                  
LISTEN     0      128         :::80                      :::*    ----http對應(yīng)的80端口已經(jīng)打開              
LISTEN     0      32          :::21                      :::*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      128        ::1:631                     :::*                  
LISTEN     0      100        ::1:25                      :::*                  
[root@centos7 app]#systemctl enable httpd.service ---開機(jī)自動啟動http服務(wù)
[root@centos7 app]#cd /var/www/html/
[root@centos7 html]#ls
[root@centos7 html]#vim index.html  ---編輯一個頁面蒜魄,文件名為index.html
  1 <h1>welcomme to magedu.com </h1>
[root@centos7 html]#mkdir app
[root@centos7 html]#ls
app  index.html
[root@centos7 html]#cd app
[root@centos7 app]#ls
[root@centos7 app]#cp /misc/cd/Packages/tree-1.6.0-10.el7.x86_64.rpm .  ---將tree包拷貝到該目錄下
[root@centos7 app]#ls
tree-1.6.0-10.el7.x86_64.rpm
[root@centos7 app]#createrepo .  ---在該目錄下自建倉庫
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 0 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
  lite DBs complete
▽root@centos7 app]#ls
repodata  tree-1.6.0-10.el7.x86_64.rpm ---可以看到會自動生產(chǎn)一個repodata的目錄
客戶端配置
[app]
name=app
baseurl=http://192.168.25.144/app
gpgcheck=0
[root@centos7 yum.repos.d]#yum repolist ---可以看到倉庫里只有一個文件
Loaded plugins: fastestmirror, langpacks
app                                                      | 2.9 kB     00:00     
app/primary_db                                             | 1.8 kB   00:00     
Loading mirror speeds from cached hostfile
repo id                                repo name                          status
app                                    app                                1
repolist: 1
[root@centos7 yum.repos.d]#yum install tree  ---利用自建倉庫安裝tree包

4、關(guān)閉防火墻和關(guān)閉SElinux的初始化腳本

#!/bin/bash
release=`cat /etc/centos-release|egrep -o " [0-9]"|tr -d " "`
[ "$release" -eq 6 ]&&service iptables stop &>/dev/null &&chkconfig iptables off&>/dev/dull
[ "$release" -eq 7 ]&&systemctl stop firewalld.service &>/dev/null && systemctl disable firewalld.service&>/dev/dull 
echo "firewall is stop"
setenforce 0
echo "SElinux is `getenforce`"
unset release
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末场躯,一起剝皮案震驚了整個濱河市谈为,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌踢关,老刑警劉巖伞鲫,帶你破解...
    沈念sama閱讀 218,941評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異签舞,居然都是意外死亡秕脓,警方通過查閱死者的電腦和手機(jī)柒瓣,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,397評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來吠架,“玉大人芙贫,你說我怎么就攤上這事∷懈兀” “怎么了屹培?”我有些...
    開封第一講書人閱讀 165,345評論 0 356
  • 文/不壞的土叔 我叫張陵默穴,是天一觀的道長怔檩。 經(jīng)常有香客問我,道長蓄诽,這世上最難降的妖魔是什么薛训? 我笑而不...
    開封第一講書人閱讀 58,851評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮仑氛,結(jié)果婚禮上乙埃,老公的妹妹穿的比我還像新娘。我一直安慰自己锯岖,他們只是感情好介袜,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,868評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著出吹,像睡著了一般遇伞。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上捶牢,一...
    開封第一講書人閱讀 51,688評論 1 305
  • 那天鸠珠,我揣著相機(jī)與錄音,去河邊找鬼秋麸。 笑死渐排,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的灸蟆。 我是一名探鬼主播驯耻,決...
    沈念sama閱讀 40,414評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼炒考!你這毒婦竟也來了吓歇?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,319評論 0 276
  • 序言:老撾萬榮一對情侶失蹤票腰,失蹤者是張志新(化名)和其女友劉穎城看,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體杏慰,經(jīng)...
    沈念sama閱讀 45,775評論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡测柠,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,945評論 3 336
  • 正文 我和宋清朗相戀三年炼鞠,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片轰胁。...
    茶點(diǎn)故事閱讀 40,096評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡谒主,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出赃阀,到底是詐尸還是另有隱情霎肯,我是刑警寧澤,帶...
    沈念sama閱讀 35,789評論 5 346
  • 正文 年R本政府宣布榛斯,位于F島的核電站观游,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏驮俗。R本人自食惡果不足惜懂缕,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,437評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望王凑。 院中可真熱鬧搪柑,春花似錦、人聲如沸索烹。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,993評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽百姓。三九已至渊额,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間瓣戚,已是汗流浹背端圈。 一陣腳步聲響...
    開封第一講書人閱讀 33,107評論 1 271
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留子库,地道東北人舱权。 一個月前我還...
    沈念sama閱讀 48,308評論 3 372
  • 正文 我出身青樓,卻偏偏與公主長得像仑嗅,于是被迫代替她去往敵國和親宴倍。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,037評論 2 355

推薦閱讀更多精彩內(nèi)容