youngjuning / issues

一寸欢喜 - 怕什么真理无穷,进一寸有一寸的欢喜
https://youngjuning.js.org
44 stars 4 forks source link

ubuntu mate for raspberry pi #199

Closed youngjuning closed 4 years ago

youngjuning commented 5 years ago

装机

参考 https://github.com/youngjuning/youngjuning.github.io/issues/190#issue-383201802

更新

$ apt update # 更新软件源
$ apt dist-upgrade # 升级所有软件 目前不要执行这个,firefox 会不能用的
youngjuning commented 5 years ago

root账号

解锁root账号

$ sudo passwd root
$ sudo passwd --unlock root

配置 root 账号自动登录

修改 /etc/lightdm/lightdm.conf 为:

[Seat:*]
greeter-session=unity-greeter 
user-session=ubuntu 
autologin-user=root 
allow-guest=false   #不允许guest登录

/root/.profile 文件中将 mesg n||true 修改为 tty -s && mesg n ||true

允许远程用root登录

ubuntu 默认的sshd的设置不允许root用户用密码远程登录

$ nano /etc/ssh/sshd_config

作如下修改:

- PermitRootLogin prohibit-password
+ PermitRootLogin yes
youngjuning commented 5 years ago

realvnc-vnc-server

  1. 下载 realvnc-server
  2. 按照官方安装文档安装 debian-install-remove image
  3. 开启服务并配置开机自启动unix-start-stop
    $ systemctl enable vncserver-x11-serviced.service #systemd 
    $ update-rc.d vncserver-x11-serviced defaults #initd
youngjuning commented 5 years ago

开启ssh

$ raspi-config

进入之后找到 ssh 服务,开启即可。

youngjuning commented 5 years ago

Nodejs

1. 先在系统上安装好nodejs和npm

$ sudo apt install nodejs-legacy
$ sudo apt install npm

2. 安装用于安装nodejs的模块n

$ sudo npm install -g n

3. 通过n模块安装指定的nodejs

详细使用参考:https://github.com/youngjuning/youngjuning.github.io/issues/88#issuecomment-441446806

$ sudo n latest
$ sudo n stable // 推荐这个
$ sudo n lts

4. 升级 npm 为最新版本

$ npm  i -g npm@latest

5. 重启终端测试

$ node -v
$ npm -v
youngjuning commented 5 years ago

Docker

1、安装

最快捷

$ curl -sSL https://get.docker.com | sh

国内镜像【未测试】

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

2、安装后日志分析

// docker客户端
Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:57:21 2018
 OS/Arch:           linux/arm
 Experimental:      false
// docker服务端 - 社区版
Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:17:57 2018
  OS/Arch:          linux/arm
  Experimental:     false

// 如果你不想用root账号使用 Docker,你应该把你的用户加入到 “docker” 分组中(安装过程中已经新建了docker分组)
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

// 记住你必须退出并重新登录才能生效
Remember that you will have to log out and back in for this to take effect!

// 警告:将用户添加到“docker”组将授予运行容器的能力,这些容器可用于获取docker主机上的root权限。
WARNING: 
Adding a user to the "docker" group will grant the ability to run containers which can be used to obtain root privileges on the docker host.
// 参考资源
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface for more information.

总结:

  1. 一些版本信息
  2. 不想使用root账号操作docker,就在 "docker" 分组下添加user(重启后生效)

3、安装docker-compose

使用Docker的准时轻量级开发环境

$ apt-get install docker-compose

4、添加用户到docker分组【可选】

默认情况下,docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑,一般 Linux 系统上不会直接使用 root 用户。因此,更好地做法是将需要使用 docker 的用户加入 docker 用户组。

$ sudo usermod -aG docker $USER // 一般是 pi
# 如果没有该分组就新建 sudo groupadd docker

退出当前终端并重新登录

5、启动 Docker CE

$ sudo systemctl enable docker
$ sudo systemctl start docker

6、测试 Docker 是否安装正确

$ docker run arm32v7/hello-world // 树莓派
$ docker run hello-world

执行以上命令,若能正常输出以下信息,则说明安装成功。

Unable to find image 'arm32v7/hello-world:latest' locally
latest: Pulling from arm32v7/hello-world
ad0f38092cf2: Pull complete 
Digest: sha256:f1ee3cbf1dbeab65f6b542360aca910ce1f6ba0ff31c803fdf08a13f5f846249
Status: Downloaded newer image for arm32v7/hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm32v7)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

7、国内镜像

请在 /etc/docker/daemon.json 中写入如下内容(如果文件不存在请新建该文件)

{
  "registry-mirrors": [
    "https://registry.docker-cn.com"
  ]
}

注意,一定要保证该文件符合 json 规范,否则 Docker 将不能启动。

之后重新启动服务。

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

配置加速器之后,如果拉取镜像仍然十分缓慢,请手动检查加速器配置是否生效,在命令行执行 docker info,如果从结果中看到了如下内容,说明配置成功。

Registry Mirrors:
 https://registry.docker-cn.com/

8、单独支持 树莓派的 docker

9、Portainer

PortainerDocker引擎或Swarm集群上作为轻量级Docker容器(Docker映像权重小于4MB)运行。因此,在使用Docker的任何计算机上运行容器都是一个命令。

部署Portainer

使用以下Docker命令部署Portainer:

$ docker volume create portainer_data
$ docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

您只需要使用浏览器访问运行portainerDocker引擎的端口9000

注意:该-v /var/run/docker.sock:/var/run/docker.sock选项只能在Linux环境中使用。

10、docker info 引发的警告

参考链接

youngjuning commented 5 years ago

为Ubuntu Mate for ARM 更换中国软件源(可选)

配置之后 firefox 打不开了!!!!

在中国玩树莓派真是各种苦逼,github慢的要死,各种软件源慢的要死……之前树莓派装的Raspbian,无奈国内的软件源不全,很多软件包自动跳到官方源,简直无法使用,于是换了Ubuntu Mate,虽然官方的软件源能用,但也很慢,找了一番,发现国内为Ubuntu on ARM 搭建的镜像站还真少,我目前只找到一个~~~

更换步骤

  1. 以root身份打开 /etc/apt/sources.list ,至于用什么打开随意
  2. http://ports.ubuntu.com/ 全部替换为 http://mirrors.ustc.edu.cn/ubuntu-ports/ ,这是中科大的
  3. 执行 sudo apt-get updatesudo apt-get upgrade 测试

查看是否提供arm支持的方法

打开一个镜像站点,然后以此打开 /dists/xenial/main/ ,看这个目录下面有没有 binary-arm 这样的字眼,如果有,就是提供arm支持的

youngjuning commented 5 years ago

面板误删解决办法

$ mate-panel --reset