作者:冥王星 "noright0@163.com"

前言

宿舍有个树莓派2B,连接到电视机,安装OSMC系统,USB接口连接移动硬盘一块,平时用来BT下载和看电影、美剧。

OSMC是基于Debian系统的,可以通过apt-get安装软件,软件仓库中有mongodb,而leanote也有相应的用于arm的二进制包,所以把leanote安装到树莓派是可行的。

mongodb 部分

安装mongodb

sudo apt-get install mongodb

安装软件一般我都用aptitude

配置mongodb运行的用户名

OSMC系统使用的是systemd,mongodb服务启动是在这个文件配置的:/etc/systemd/system/multi-user.target.wants/mongodb.service

文件的内容如下:

[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1) [Service]
User=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongodb.conf [Install]
WantedBy=multi-user.target

我们把User=mongodb改为User=osmc,使其用osmc身份运行。(只是为了方便)

运行命令使配置生效。

sudo systemctl daemon-reload

修改mongodb配置文件

从上边的启动配置文件中可以看出,mongodb启动时读取/etc/mongodb.conf作为配置文件,这个文件的内容如下:

# mongodb.conf

# Where to store the data.
dbpath=/data/db #where to log
logpath=/data/log/mongodb.log logappend=true bind_ip = 127.0.0.1
#port = 27017 # Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true # Enables periodic logging of CPU utilization and I/O wait
#cpu = true # Turn on/off security. Off is currently the default
#noauth = true
#auth = true # Verbose logging output.
#verbose = true # Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true # Enable db quota management
#quota = true # Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#oplog = 0 # Diagnostic/debugging option
#nocursors = true # Ignore query hints
#nohints = true # Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true # Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true # Turns off table scans. Any query that would do a table scan fails.
#notablescan = true # Disable data file preallocation.
#noprealloc = true # Specify .ns file size for new databases.
# nssize = <size> # Accout token for Mongo monitoring server.
#mms-token = <token> # Server name for Mongo monitoring server.
#mms-name = <server-name> # Ping interval for Mongo monitoring server.
#mms-interval = <seconds> # Replication Options # in replicated mongo databases, specify here whether this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com
# Address of a server to pair with.
#pairwith = <server:port>
# Address of arbiter server.
#arbiter = <server:port>
# Automatically resync if slave data is stale
#autoresync
# Custom size for replication operation log.
#oplogSize = <MB>
# Size limit for in-memory storage of op ids.
#opIdMem = <bytes> # SSL options
# Enable SSL on normal ports
#sslOnNormalPorts = true
# SSL Key file and password
#sslPEMKeyFile = /etc/ssl/mongodb.pem
#sslPEMKeyPassword = pass

我们只需要修改数据库文件目录和日志文件的文件名。

因为树莓派的系统安装在TF卡上,频繁读写不仅速度慢,而且容易坏卡。而我的树莓派长期连接一个移动硬盘,所有把数据库文件和日志文件放到移动硬盘也就顺理成章了。

# Where to store the data.
dbpath=/media/sea2t/srv/db #where to log
logpath=/media/sea2t/srv/log/mongodb.log

启动mongodb

# 启动命令
sudo service mongodb start
# 停止命令
sudo service mongodb stop
# 查看状态
sudo service mongodb status

leanote 部分

下载二进制安装包

从官网下载 leanote 的 for arm 的二进制文件。下载地址在这个网站:http://leanote.org/#download

https://sourceforge.net/projects/leanote-bin/files/2.0/leanote-linux-arm-v2.0.bin.tar.gz/download

解压文件

把安装包解压至移动硬盘。

/media/sea2t/srv/leanote

修改 leanote 配置文件

leanote的配置文件在这里:

/media/sea2t/srv/leanote/conf/app.conf

内容是这样的:

#------------------------
# leanote config
#------------------------ http.port=9000 site.url=http://localhost:9000 # or http://x.com:8080, http://www.xx.com:9000 # admin username
adminUsername=admin # mongdb
db.host=127.0.0.1
db.port=27017
db.dbname=leanote # required
db.username= # if not exists, please leave it blank
db.password= # if not exists, please leave it blank
# or you can set the mongodb url for more complex needs the format is:
# mongodb://myuser:mypass@localhost:40001,otherhost:40001/mydb
# db.url=mongodb://root:root123@localhost:27017/leanote
# db.urlEnv=${MONGODB_URL} # set url from env. eg. mongodb://root:root123@localhost:27017/leanote # You Must Change It !! About Security!!
app.secret=V85kbQ8qqtju9y2aDM55VWxAH9Qop19kcDVvrD0y #--------------------------------
# revel config
# for dev
#--------------------------------
app.name=leanote
http.addr=
http.ssl=false
cookie.httponly=false
cookie.prefix=LEANOTE
cookie.domain= # for share cookie with sub-domain
cookie.secure=false
format.date=2006-01-02
format.datetime=2006-01-02 15:04:05 # 必须这样配置
results.chunked=false log.trace.prefix = "TRACE "
log.info.prefix = "INFO "
log.warn.prefix = "WARN "
log.error.prefix = "ERROR " # The default language of this application.
i18n.default_language=en-us module.static=github.com/revel/modules/static [dev]
mode.dev=true
results.pretty=true
watch=true module.testrunner = # github.com/revel/modules/testrunner log.trace.output = stderr
log.info.output = stderr
log.warn.output = stderr
log.error.output = stderr [prod]
mode.dev=false
results.pretty=false
watch=false module.testrunner = log.trace.output = off
log.info.output = off
log.warn.output = %(app.name)s.log
log.error.output = %(app.name)s.log

我们需要修改的部分有:http.port,site.url,app.secret,其他暂时不需要修改。

需要注意的是site.url,这个是你正文中加在图片等附件前边的url部分,如果和你访问网站的url不同,就不能在网站中看到图片等附件。切切!

设置 leanote 的启动服务

我们把 mongodb.service 复制一下,修改为启动 leanote

sudo cp /etc/systemd/system/multi-user.target.wants/mongodb.service /etc/systemd/system/multi-user.target.wants/leanote.service
[Unit]
Description=Leanote, Not Just A Notepad! [Service]
User=osmc
ExecStart=/media/sea2t/srv/leanote/bin/run.sh [Install]
WantedBy=multi-user.target

运行命令使配置生效

sudo systemctl daemon-reload

初始化数据库

运行这个命令初始化数据库(请确认数据库已启动)

mongorestore -h localhost -d leanote --directoryperdb /media/sea2t/srv/leanote/mongodb_backup/leanote_install_data/

启动 leanote

# 启动 leanote
sudo service leanote start
# 停止 leanote
sudo service leanote stop
# 查看状态
sudo service leanote status

备份

一个是数据库文件,备份这个目录

/media/sea2t/srv/db

一个是内容图片附件,备份这个目录

/media/sea2t/srv/leanote/files

一个是leanote配置文件

/media/sea2t/srv/leanote/conf/app.conf

存在的问题

由于 /media/sea2t是通过usb接口连接到系统,系统启动后自动挂载的,所以mongodbleanote启动时/media/sea2t还没挂载上,两个服务会启动失败,需要手动启动一下。

解决办法:写启动脚本,启动前先等待移动硬盘挂载。

/home/osmc/start_mongodb.sh

#!/bin/bash

while [ ! -f "/media/sea2t/srv/db/local.0" ]; do
echo "=> Waiting for sea2t to be mounted"
sleep 5
done /usr/bin/mongod --config /etc/mongodb.conf

/home/osmc/start_leanote.sh

#!/bin/bash

while [ ! -f "/media/sea2t/srv/leanote/bin/run.sh" ]; do
echo "=> Waiting for sea2t to be mounted"
sleep 5
done /media/sea2t/srv/leanote/bin/run.sh

/etc/systemd/system/multi-user.target.wants/mongodb.service

[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1) [Service]
User=osmc
ExecStart=/home/osmc/start_mongodb.sh
Restart=always
RestartSec=30 [Install]
WantedBy=multi-user.target

/etc/systemd/system/multi-user.target.wants/leanote.service

[Unit]
Description=Leanote, Not Just A Notepad! [Service]
User=osmc
ExecStart=/home/osmc/start_leanote.sh
Restart=always
RestartSec=30 [Install]
WantedBy=multi-user.target

在树莓派上安装leanote的更多相关文章

  1. 在(Raspberry Pi)树莓派上安装NodeJS

    本文主讲如何在树莓派3B上安装node.js 环境描述1. 树莓派安装了`2016-11-25-raspbian-jessie-lite`(PS:在此版本的镜像中,默认禁用了ssh,在烧录好镜像之后, ...

  2. 在树莓派上安装Theano

    “查遍全网都没人成功在树莓派安装Theano,这是什么样的感觉?” ——写在开头 在这里必须先说一下,由于安装过程中的坑太多了,遇到的问题层出不穷,所以我这里只能记录我安装过程中的印象深刻的问题,如果 ...

  3. opencv2.4.9在ubuntu(树莓派)上安装

    参考原文:https://my.oschina.net/u/1757926/blog/293976 1. 先从sourceforge上下载OpenCV的源码 http://jaist.dl.sourc ...

  4. 树莓派上安装2.8寸TFT触摸屏

    在某宝的这里买了一个2.8寸的TFT触摸屏,其实就是中国版的ADAFRUIT 结合店家的帮助文档做了一下,一次点亮,这里也记录一下自己的安装过程(话说会硬件是会比会软件有不同的乐趣~~~) 由于店家推 ...

  5. 树莓派上 安装并 运行opencv

    1.先安装依赖项 OpenCV 2.2以后版本需要使用Cmake生成makefile文件,因此需要先安装cmake. sudo apt-get install build-essential sudo ...

  6. 树莓派上安装Samba实现树莓派与Windows间的文件共享

    我是参考这篇文章的: https://www.jianshu.com/p/ead92b06318e 安装samba和common-bin库(具有smbpasswd效用) sudo apt-get in ...

  7. 树莓派上安装boost库

    一.安装boost库 sudo apt-get install libboost-dev aptitude search boost 二.编写测试代码 #include <iostream> ...

  8. raspberrypi(树莓派)上安装mono和jexus,运行asp.net程序

    参考网址: http://www.linuxdot.net/ http://www.cnblogs.com/mayswind/p/3279380.html http://www.raspberrypi ...

  9. 树莓派+花生棒+leanote搭建自己的笔记服务器

    背景 对于一个程序猿来说.女朋友可以(暂时)没有,但是不能没有一个很好的记笔记的应用.因为记笔记可以帮助自己积累学习提升自己.每一次回头看自己记得笔记,你都会有新的理解. 也许有人会说,用有道云啊,有 ...

随机推荐

  1. List容器

    List 容器 list是C++标准模版库(STL,Standard Template Library)中的部分内容.实际上,list容器就是一个双向链表,可以高效地进行插入删除元素. 使用list容 ...

  2. IOS单例模式(Singleton)

    IOS单例模式(Singleton)   单例模式的意思就是只有一个实例.单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例.这个类称为单例类. 1.单例模式的要点: 显然单例模 ...

  3. 智能卡安全机制比较系列(三) MPCOS

    MPCOS是金普斯早期推出的一款多应用支付芯片卡操作系统,支持ISO7816以及PCOS的数据格式和命令.MPCOS具有两级目录文件结构,即MF下可以有一级DF,每个DF下最多可创建63个EF. MP ...

  4. 单片机串口通讯RXD与TXD如何对接详解

    相信很多人都对单片机与计算机或者芯片通信时,RXD与TXD如何连接比较困惑.因为在一些电路图中,有的是直连接法,有的是交叉接法,让人有点摸不着头脑. 首先需要明白两个概念,就是DTE和DCE.DTE是 ...

  5. 改进RazorPad

    从Git 上下载了作者的源码后,感觉用起来挺别扭,而且还要BUG............ 经过“篡改”后,好用多了,呵呵..

  6. Visual Studio中的lib的链接顺序

    描述:如果有一个exe工程,它依赖于A.lib,B.lib,A.lib和B.DLL我同样有他们的源码工程.依赖顺序是这样的exe->A.lib->B.DLL.那么如果我改动了B的源码,编译 ...

  7. sgu495:概率dp / 推公式

    概率题..可以dp也可以推公式 抽象出来的题目大意: 有 n个小球,有放回的取m次  问 被取出来过的小球的个数的期望 dp维护两个状态 第 i 次取出的是 没有被取出来过的小球的 概率dp[i] 和 ...

  8. HTTP请求的TCP瓶颈分析

    这篇文章基本是对<Web性能权威指南>第一章和第二章的读书笔记,另外加一些扩展内容,这本书确实赞,推荐 针对三次握手.流量控制(接收窗口).慢启动(cwnd,拥塞窗口).队首阻塞等方面看下 ...

  9. 第32讲 UI组件之 时间日期控件DatePicker和TimePicker

    第32讲 UI组件之 时间日期控件DatePicker和TimePicker 在Android中,时间日期控件相对来说还是比较丰富的.其中, DatePicker用来实现日期输入设置,    Time ...

  10. poj 1274 The Perfect Stall(二分图匹配)

    Description Farmer John completed his new barn just last week, complete with all the latest milking ...