How to port mongodb to OpenWrt?

I migrated by referring to gpsd, but an error occurred when compiling:

Checking whether the C compiler works... yes
Checking whether the C++ compiler works... yes
Checking that the C++ compiler can link a C++ program... no
C++ compiler g++ can't link C++ programs

so your dev environment is missing something ....

this isn't openwrt related.

It's too complicated. Mongodb's compilation system. Give up

mongodb is not small piece of software so not sure what is/was your plan to run on. i guess you aware that non-x86 routers are usually short on CPU power. but if you have an x86 based router probably easier to use docker instead of porting.

I want to run another software. The database used by this software is mongodb. The running environment is an x86 server. Docker can run on openwrt? Can openwrt be installed on x86 servers?

Is there an example of using Docker to deploy similar software? I'll try by reference

if you have an x86 server why you want to run a database server on openwrt??? makes very little sense imho. but it is your call.

yes, openwrt can run on x86 machine. yes, openwrt can run docker on x86 machine. check the wiki and forum for details.

I also think it's incredible that there should be a better way. It mainly aims to solve the problem that the operating system cannot be started normally due to the loss of system files after the server is suddenly powered off。It is very likely that I am going in the wrong direction. Because the power supply of the server is unstable, power failure often occurs. The hardware and power supply system cannot be improved for the time being。
I think that every time openwrt is started, the system files should be released from the rom and rebuilt, so that even if the power failure occurs, the next server can still be normal. However, I'm not sure whether the data file of the database will be damaged even in this way. I want to experiment. In the event of power failure without warning, ensure that the server can get up every time, and that the system files and data files are not lost or damaged. Do you have a good solution?

i'm still unsure what you expect from openwrt, but couple of things to understand:

  • owrt is meant to be an embedded, lightweight network router appliance. as such
    a) it is by design small, after installation on x86 the root partition is 104MB (on a real router it is even less). from which there is the os and additional packages, apps, so very little storage space left. it is definitely not meant to use owrt as a database server. (you can add additional disk space though)
    b) it is not a full featured general purpose linux distribution, ie. package management and release upgrade is very limited. e.g. release upgrade almost like an install from scratch: you'll need to overwrite the root partition but config files (more or less) retained. but packages are not kept (there is so called attended sysupgrade which helps to get additional packages too be kept). but package upgrades are not recommended. and rollback is reinstall basically.
  • owrt on x86 can use squashfs or ext4 as filesystem by default, thus as owrt is not specialized being real high available, redundant and survivable OS, it is only protected from power outage as for example ext4 is. as reinstall is very quick there is no point designing an extreme survivable OS.

this is not guaranteed at all.

installing owrt to a faulty server will get you no better reliability and survivability, you should fix your server first.

so in short, i do not think owrt is the right choice to run as database server. you're better off to run mongodb server on a debian, ubuntu, whatever your choice of linux distro, and if you want HA, run mongodb cluster across multiple servers.