当前位置:网站首页>How to build a 32core raspberry pie cluster from 0 to 1
How to build a 32core raspberry pie cluster from 0 to 1
2022-07-07 02:24:00 【51CTO】
There was a time , The idea of creating a raspberry pie cluster has always been in my mind . In this paper , I'll show you how to build a raspberry pie cluster from scratch .
Raspberry pie is a kind of display that can be connected 、 mouse 、 keyboard , Through the graphic interface (GUI) install Linux Operating system microcomputer . You can also do it without GUI Use and run raspberry pie in headless mode , for example , database server . Raspberry pie offers many uses , Such as building Minecraft Server to Smart Mirror (smart mirrors), It has endless possibilities .
Since I began to contact MariaDB And understand the database cluster 、 Distributed SQL and Xpand after , The idea of building raspberry pie clusters has always been in my mind . Such a cluster is a good way to experience distributed systems .
In this article , I will show you how to build a raspberry pie cluster :
- 8 node
- 32 nucleus
- 64GB Memory
- 2TB Storage space
PART 01
preparation
If you want to build your own cluster , You don't need to buy 8 Raspberry pie equipment . Even one device is enough for you to learn . Even if you only plan to configure a raspberry pie , The instructions in this article can also be used . My advice is , If you really want to improve your Linux management 、Ansible、Docker、Kubernetes、 Database clustering and other skills , Then there must be at least three devices to build your cluster .
Consider this , Please use your number instead of 8. If you have different models , Or memory or storage space of different sizes , Then please use your raspberry pie device specifications to replace the corresponding parameters listed below . Here are the parameters of the equipment I use :
- 8 × Raspberry pie 4 Model B (8GB Memory )
- 1 × Anker 60W Desk charger (10 port )
- 8 x short USB C Type data cable (5A, 40W, 23cm)
- 8 x MicroSD card (256GB)
- 2 × Raspberry pie cluster box (4 layer , With cooling fan )
You can adjust it according to the number of your equipment , If you have few devices ( such as 1 Or 2 individual ), You can buy one or more raspberry pie power supplies , Or one more mouth USB The charger . If you use more USB The charger , Ensure that each port can provide at least 2.4Am (5V). Choose one that fits your goals and budget microSD card . I suggest using at least 32GB Of SD card . In terms of cables and enclosures , Just choose the one that suits you . Although the cooling fan is not necessary , But if you plan to keep the device on for a long time , I suggest you use a cooling fan .
I also suggest starting “ cooking ” Prepare all the ingredients before , Especially if you want to use multiple raspberry pie devices .
PART 02
Install headless
Raspberry pie operating system
The operating system we will use is raspberry pie (Raspberry Pi OS), One is based on Debian The operating system after optimization and adaptation . Use your computer to install the raspberry pie operating system in microSD obstruct . And then put these microSD Connect the card to the raspberry pie device and start them .
Put all the microSD Cards and raspberry pie boxes are on your desk . If your computer doesn't SD Card slot , You will need a SD Card adapter ( They usually come with microSD card ) Or a read SD Card USB Card reader . And prepare a marker .
download Raspberry Pi Imager And install it on your computer . Take one microSD Card and connect to your computer , open Raspberry Pi Imager Applications , Click on CHOOSE OS, Click... In the list that appears “Raspberry Pi OS (other)”. If your raspberry pie device is 64 Bit , select Raspberry Pi OS Lite (64-bit), Otherwise select Raspberry Pi OS Lite (32 position ).
Click on CHOOSE STORAGE And select microSD card . Check again that you have selected the correct drive , And then click “ gear ” Icon ( Advanced options ). Host name use rpi01 Or a similar name , Name the equipment as rpi01、rp02、rp03 etc. . Then choose “Enable SSH” and “Use password authentication” Options . Set the username ( I will use the default name pi) And set a secure password . see “Configure wireless LAN“ Options , And enter your WiFi Name and password of the connection . Note that you also need to set up your site .
Because we have to treat each microSD The card performs such an operation once , So please make sure that ”Image customization” The option field is set to :”to always use“. In this way, the settings will be saved , Next SD The card processing process will also be easier :
You can now click “SAVE“, And then click ”WRITE” To start the burning process . Once that is done , Eject card , And connect to one of the raspberry pie devices , Put it back in its box , And mark the numbers on the box 01. Repeat this process for all devices .
PART 03
Cluster assembly
Depending on the type of cluster used , The assembly process may be different . Follow the instructions on the box , Or search online for photos , You can clearly know how these devices should be placed in layers .
I suggest deciding in advance which parts to assemble first . for example , In the box I choose , I must install the cooling fan first , Then install the raspberry pie device on each layer .
Once you install raspberry pie , Write down the corresponding number on each layer with a marker . This will be when you need to modify the device hardware ( If you have to take out microSD card , And reconfigure or do other management tasks ), It will be very helpful .
After installing all the equipment , And will USB Line connected to raspberry pie device and multi port USB On the charger . If you like , You can choose to use Ethernet power supply and network switch (network switch), instead of USB The charger , But I want you to explore . You can put the charger ( Or network switch ) Put it next to the raspberry pie shelf , Or connected to it . I fixed the charger to one side of the box with a rubber band .
Plug in USB Line , You can start all mini computers ! Connect the charger and turn on the power . According to the raspberry pie model you use , They may take some time to start , So be patient . meanwhile , You can see that there are LED The light is flashing , At the same time, the fan has also started .
PART 04
adopt SSH Connecting device
If all goes well , You should be able to pass SSH visit Raspberry Pi equipment . Try running the following program on your computer :
Enter the password and answer yes, Add the device to the list of known hosts . here , Your cluster has started .
You may need to run the command to check the hardware information . for example :
- lscpu:CPU Architecture information
- df -H: File system disk space usage
- sudo fdisk -l: Zone information
- free -m: The quantity used , The number and total of free RAM size
- cat /proc/version:Linux Kernel information
PART 05
Use raspi-config Manual configuration
If you have a raspberry pie , You can use the above description SSH Connect to it , And use raspi-config To configure raspberry pie . You can modify it WiFi Connect (S1), Change host name (S4) And user password (S3), Extended file system (A1), And a lot more .
PART 06
Use Ansible Realize automatic configuration
If you have more than one raspberry pie in your cluster , You may want to use Ansible Such a tool for automatic configuration . Use Ansible, You can run a command on multiple machines , Without having to perform repetitive work . for example , Suppose we want to expand each Raspberry Pi File system on . You can execute the following commands on the command line :
If there is no Automation , You will have to pass the above command , Use SSH Connect to rpi01.local, Then the end SSH conversation . about rpi02.local and rpi03.local,rpi04.local Other equipment , All these steps must be repeated . contrary , You can simply tell Ansible Run this command for you on all machines .
The specific operation is that you must put Ansible Installed on the control node connected to the local network . It can be a raspberry pie device , It can also be your work laptop , Or any other machine , As long as it runs based on Unix Operating system of ( Such as Linux or macOS) that will do . I happen to have an old laptop , I reuse it as a dedicated database connected to my network , So I use it as a control node ( I'll show you in a later article how to Raspberry Pi Install a database with replication function in the device ). I won't elaborate on how to install Ansible, Because on different operating systems , The installation process is different . Please check the official documents , And install it on your laptop or any device you want to configure as a control node .
Before you start , I suggest you generate a sample configuration file , You can adjust it later according to your own wishes :
Slide left and right to see the full code
In this paper , Host key checking is disabled to simplify the operation , But don't do this in a production environment !
Change the following line :
Change to :
Next , You need to define a list , This list is what you want to use Ansible List of controlled machines . The manifest path is /etc/ansible/hosts. for example , You can use the IP Add the address or hostname to the list below :
Properties files
If the machine IP There is a pattern in the address or hostname , You can also use scope to configure , The specific method is to edit /etc/ansible/hosts file , Add the following at the end of the document :
Properties files
Change the pattern to match your hostname and number . This is equivalent to :
Properties files
In this list ,rpi Is an arbitrary name , When you use Ansible When running a command on a raspberry pie device , You can use it to refer to all devices .
You need to configure SSH user name ,Ansible Will use this user to connect to the machine . stay /etc/ansible/hosts Add the following to the file :
Properties files
Now it's time to control the machine . So let's use ping Command to connect :
Input SSH password . Then you should see how each machine is used in the output “pong” To respond to “ping” Of ( I only show one here ).
JSON
Slide left and right to see the full code
Let's go back to file system extensions . To do this on all machines , Please run :
Slide left and right to see the full code
It's that simple , All raspberry pie devices have an extended file system . This is a good time to update the system on all machines :
Slide left and right to see the full code
You can restart all devices as follows :
Once you're done , And hope to shut down all machines safely , Just run :
PART 07
Next operation
This is just the beginning . You now have a cluster , And can be determined by Ansible control . You can try to set up any type of server software , Include Web Server or database . There's a lot more to it Ansible The content of , In this article, I only use ad-hoc command , But you can use Playbooks To deploy your cluster to achieve the state you need . At the same time, you can also refer to the official documents for further research .
边栏推荐
- postgresql之integerset
- 老板被隔离了
- Time synchronization of livox lidar hardware -- PPS method
- Introduction to RC oscillator and crystal oscillator
- The boss is quarantined
- Several classes and functions that must be clarified when using Ceres to slam
- 猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
- STM32F4---通用定时器更新中断
- [server data recovery] data recovery case of a Dell server crash caused by raid damage
- 真实项目,用微信小程序开门编码实现(完结)
猜你喜欢
Jacob Steinhardt, assistant professor of UC Berkeley, predicts AI benchmark performance: AI has made faster progress in fields such as mathematics than expected, but the progress of robustness benchma
老板被隔离了
[paper reading | deep reading] dngr:deep neural networks for learning graph representations
Overall query process of PostgreSQL
Word wrap when flex exceeds width
New generation cloud native message queue (I)
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
【论文阅读|深读】 GraphSAGE:Inductive Representation Learning on Large Graphs
将截断字符串或二进制数据
Integerset of PostgreSQL
随机推荐
FLIR blackfly s usb3 industrial camera: white balance setting method
3D激光SLAM:Livox激光雷达硬件时间同步
猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
Twenty or thirty thousand a leaf? "Yang Mou" behind the explosion of plant consumption
Introduction to microservice architecture
Blackfly S USB3工业相机:缓冲区处理
老板被隔离了
【论文阅读|深读】DNGR:Deep Neural Networks for Learning Graph Representations
Chang'an chain learning notes - certificate model of certificate research
String or binary data will be truncated
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
Lombok同时使⽤@Data和@Builder 的坑
SchedulX V1.4.0及SaaS版发布,免费体验降本增效高级功能!
How do I dump SoapClient requests for debugging- How to dump SoapClient request for debug?
将截断字符串或二进制数据
强化学习如何用于医学影像?埃默里大学最新《强化学习医学影像分析》综述,阐述最新RL医学影像分析概念、应用、挑战与未来方向
Cat recycling bin
Centros 8 installation MySQL Error: The gpg Keys listed for the "MySQL 8.0 Community Server" repository are already ins
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
Centos8 install MySQL 8.0 using yum x