溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么優(yōu)雅地用ARM開發(fā)板搭建服務(wù)器

發(fā)布時(shí)間:2021-12-10 18:31:04 來(lái)源:億速云 閱讀:563 作者:柒染 欄目:互聯(lián)網(wǎng)科技

這篇文章給大家介紹怎么優(yōu)雅地用ARM開發(fā)板搭建服務(wù)器,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

我拆了一個(gè)舊的ARM開發(fā)板,并用它制作了一個(gè)基于Debian的mini服務(wù)器。我現(xiàn)在有一個(gè)隨時(shí)可以訪問(wèn)的網(wǎng)關(guān),它:

  • 非常節(jié)能,只有大約3-3.5W

  • 總是可以訪問(wèn)的,即使我用的動(dòng)態(tài)IP (via DynDNS)

  • 有一個(gè)Nginx網(wǎng)絡(luò)服務(wù)器,所以我能和世界分享我的生活。(Nginx是一款面向性能設(shè)計(jì)的HTTP服務(wù)器,相較于Apache、lighttpd具有占有內(nèi)存少,穩(wěn)定性高等優(yōu)勢(shì)。)

  • 有一個(gè)Exim郵件服務(wù)器,所以我能通過(guò)SMTP接受Email并把它存在我的房子里。我通過(guò)SSH/mytt閱讀郵件。

  • 能夠通過(guò)SSH遠(yuǎn)程連接,允許遠(yuǎn)程喚醒我的主桌面。

  • 在后臺(tái)進(jìn)行下載(wget/rtorrent) ,用Samba服務(wù)器共享至綁定設(shè)備,如Andriod平板

  • SSH端口復(fù)用為HTTPS端口來(lái)濾除一些防火墻限制。

這個(gè)是我最好的作品。我喜歡建造它的過(guò)程。

##Building a tiny ARM-based server##

大約一年前,我拿到了一個(gè)NAS設(shè)備——這是一個(gè)相當(dāng)古老低耗能基于ARM的文件服務(wù)器。按照現(xiàn)代的標(biāo)準(zhǔn),它被認(rèn)為過(guò)時(shí)。然而我知道從我獲得它的那一天我會(huì)非常享受改造它。

我的職業(yè)是一個(gè)程序員。我誠(chéng)懇認(rèn)為編程和生活是分開的,可以有這樣一種可能它們都能被提高。

##Disassembling and soldering ##

首先我必須把整個(gè)東西拆開,這樣我才能按照我的想法去搭建這個(gè)世界。按照其他工程師的指導(dǎo),我足足拆了半個(gè)小時(shí)才拆開它。我把機(jī)器里面的兩個(gè)光驅(qū)拆出來(lái),連接到我的外部USB/SATA附件。迅速地檢測(cè)了一下它的功能。

<!-- lang: shell -->
smartctl -a /dev/sdX

這個(gè)命令顯示兩個(gè)光驅(qū)都有壞的扇區(qū)。 我找到一個(gè)160GB的USB移動(dòng)硬盤掛在上面。由于這是一個(gè)嵌入式設(shè)備,沒有VGA輸出,也沒有串口輸入。我需要找到一種監(jiān)視它啟動(dòng)過(guò)程的方法。我google了很久,這個(gè)機(jī)器上面實(shí)際有RS232的悍盤。萬(wàn)能的互聯(lián)網(wǎng)提供的方法說(shuō)明非常簡(jiǎn)單:

Pin 1 = +3.3V

Pin 2 = GND

Pin 3 = Rx

Pin 4 = Tx 我已經(jīng)過(guò)了用面包版搭建RS232接口的年紀(jì),我在網(wǎng)上從一家電子商城訂購(gòu)了一根TTL轉(zhuǎn)RS232電纜。

怎么優(yōu)雅地用ARM開發(fā)板搭建服務(wù)器

上圖紅箭頭所指的就是我焊接上去的串口線。兩天后,我又連接了一根串口轉(zhuǎn)USB的電纜。我的電腦是ArchLinux,Atom 330 。我把USB插入電腦,打開串口調(diào)試程序,這樣就能控制這個(gè)板子了。

<!-- lang: shell -->
minicom -D /dev/ttyUSB0 -b 115200

##U-booting from no BIOS whatsoever##

下面講的就是怎么對(duì)160G的硬盤分區(qū),然后啟動(dòng)內(nèi)核。

I mounted the old drives up to my main PC's USB/SATA enclosure, and sure enough, I saw clear signs of a Linux-based machine: the software RAID driver in my ArchLinux detected raid devices (cat /proc/mdstat showed information about the RAID structure 磁盤冗余陣列). Apparently, MyBook had the two drives in a RAID formation - which I proceeded to successfully mount. There were 4 partitions in each of the two drives, clearly in a RAID1 mirror formation - with the 4th and final partition being the one with the "File Server" storage area. I proceeded to copy the first three partitions (including the partition table) to my 160GB drive (via dd). I then used fdisk to fix the size of the 4th partition to be the remaining space of my drive.

##Installing Debian (and some thoughts about Windows)##

這一段主要是講如何安裝Debian操作系統(tǒng),和怎么看待linux和windows的差別。

Sadly, this is a skill that Microsoft all but destroyed, making people hopelessly dependent on "wizards". That, in itself would have been fine, if it were not for the inevitable side-effect: people clicking on buttons unaware of what is going on behind them, end up with systems that can only be rescued with "OS reinstalls". My own settings - since I work with UNIX systems - are simple files under /etc and my $HOME... and have always been living under revision control (e.g my main dot files and vim configuration), happily migrating over the last 15 years across many machines. Backing them up and restoring them

接下來(lái)作者講述如何解決服務(wù)提供商IP變動(dòng)的問(wèn)題,主要是使用cron定時(shí)工具讓一個(gè) DynDNS 程序自啟動(dòng),這個(gè)DynDNS可以映射一個(gè)固定IP地址。這樣就可以在外面穩(wěn)定地訪問(wèn)了。貼代碼。

下載

 <!-- lang: shell -->
# apt-get install gcc
...
# wget http://inatech.eu/inadyn/inadyn.v1.96.2.zip
# unzip inadyn.v1.96.2.zip
# cd inadyn
# make
...
# cp bin/linux/inadyn /usr/local/bin

自啟動(dòng)

<!-- lang: shell -->
# cat /var/spool/cron/crontabs/root 
...
@reboot /usr/local/bin/inadyn

然后作者講述怎么安裝郵件服務(wù)器Exim,網(wǎng)絡(luò)服務(wù)器Nginx

##Conclusion - UNIX glory##

In plain words, UNIX power put to use - in the tiny server, in my phone, in my tablet. All 3 of them, running on ARM processors. To be honest, I didn't expect that ; 15 years ago I was sure that Intel and MS had cornered the galaxy... but somehow, Linux managed to change all that.

關(guān)于怎么優(yōu)雅地用ARM開發(fā)板搭建服務(wù)器就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI