agowa / WSL-DistroLauncher-Alpine

Alpine WSL Microsoft Store packages.
MIT License
211 stars 28 forks source link

iusse for install mongodb #7

Closed runzx closed 4 years ago

runzx commented 5 years ago

alpine v3.9 mongodb v4.0.5-r0

awk: /etc/network/interfaces:No such file or directory

agowa commented 5 years ago

Can you provide steps to reproduce including the full error message? Does this occur when you try to install mongodb or when you try to start it?

runzx commented 5 years ago
DESKTOP-VU1R2LK:/home/zhaixiang# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Unknown
          UP LOOPBACK RUNNING  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wifi0     Link encap:Ethernet  HWaddr 00:24:01:ED:9F:F0
          inet addr:192.168.1.80  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::4dc5:a6aa:b2f3:cd79/64 Scope:Unknown
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

DESKTOP-VU1R2LK:/home/zhaixiang# ip address
16: eth0: <> mtu 1500 ip: ioctl 0x8942 failed: Invalid argument

    link/ether f4:6d:04:77:52:f6
    inet 169.254.22.181/16 brd 169.254.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::8d9c:f1e1:7f65:16b5/64 scope link dynamic
       valid_lft forever preferred_lft forever
1: lo: <LOOPBACK,UP> mtu 1500 ip: ioctl 0x8942 failed: Invalid argument

    link/loopback 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host dynamic
       valid_lft forever preferred_lft forever
5: wifi0: <BROADCAST,MULTICAST,UP> mtu 1500 ip: ioctl 0x8942 failed: Invalid argument

    link/ieee802.11 00:24:01:ed:9f:f0
    inet 192.168.1.80/24 brd 192.168.1.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::4dc5:a6aa:b2f3:cd79/64 scope link dynamic
       valid_lft forever preferred_lft forever
12: wifi1: <> mtu 1500 ip: ioctl 0x8942 failed: Invalid argument

    link/ieee802.11 12:24:01:ed:9f:f0
    inet 169.254.137.225/16 brd 169.254.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::548:2e41:781c:89e1/64 scope link dynamic
       valid_lft forever preferred_lft forever
14: wifi2: <> mtu 1500 ip: ioctl 0x8942 failed: Invalid argument

    link/ieee802.11 22:24:01:ed:9f:f0
    inet 169.254.132.119/16 brd 169.254.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::8c80:8573:b53b:8477/64 scope link dynamic
       valid_lft forever preferred_lft forever
runzx commented 5 years ago
DESKTOP-VU1R2LK:/home/zhaixiang# /etc/init.d/networking restart
 * Starting networking ...
 *   lo ...
ip: RTNETLINK answers: File exists                                                                                [ !! ]
 *   wifi0 ...
ip: RTNETLINK answers: File exists
ip: RTNETLINK answers: File exists                                                                                [ !! ]
 * ERROR: networking failed to start
DESKTOP-VU1R2LK:/home/zhaixiang# /etc/init.d/mongodb restart
 * Starting networking ...
 *   lo ...
ip: RTNETLINK answers: File exists                                                                                [ !! ]
 *   wifi0 ...
ip: RTNETLINK answers: File exists
ip: RTNETLINK answers: File exists                                                                                [ !! ]
 * ERROR: networking failed to start
 * ERROR: cannot start mongodb as networking would not start
runzx commented 5 years ago

/etc/network/interfaces : auto lo iface lo inet loopback

auto wifi0 iface wifi0 inet static address 192.168.1.80 netmask 255.255.255.0 gateway 192.168.1.1

agowa commented 4 years ago

the issue is that networking is special within wsl. Also normal init scripts do not behave the same as one would think, as wsl uses its own custom init system. I just replied to someone asking about how to start the postgresql service, the best option for long running daemons might be to use docker (docker-compose or kubernetes) instead, all of these are available though "docker for windows" which by now uses the wsl backend by default. I'd recommend using wsl only for ad-hoc tasks and not for long running daemons.

Also using docker, docker-compose and/or kubernetes is much more portable and will allow you to just deploy anywhere in any cloud.

So from the dockerhub page of the mongo container, this might be the best solution for you.

# Use root/example as user/password credentials
version: '3.1'
services:
  mongo:
    image: mongo
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example
  mongo-express:
    image: mongo-express
    restart: always
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example

The alternative is to find how to start mongo without it reconfiguring the network and rewriting the init script.