Linux CentOS 7 搭建自己的Leanote云笔记( 二 )

systemctl status mongod 是用来查询mongod服务的运行状态 。
# 启动mongod服务systemctl start mongod# 停止mongod服务systemctl stop mongod# 重启mongod服务systemctl restart mongod#查看mongod服务当前状态systemctl status mongod#设置mongod服务开机自启动#停止mongod服务开机自启动systemctl disable mongod然后,我们可以给MongoDB配置为开机自启动:systemctl enable mongod
2.4 配置MongoDb 用户mongodb默认没有用户的,如果为了安全性,大家可以给自己的mongodb添加一个用户 。
但是我们如果只是在自己的服务器上配置,不创建用户也没有关系 。
如果你创建了用户名和密码 。那么在Leanote的app.conf配置文件中要添加上用户名和密码哦 。否则我们的云笔记就访问不了服务器了 。
注意:创建数据库账户的密码时,不要添加@,# 等特殊字符 。否则leanote会连接不上数据库的 。
3. 搭建Leanote服务3.1 下载Leanote通过wget 命令下载: wget --no-check-certificate
https://nchc.dl.sourceforge.net/project/leanote-bin/2.6.1/leanote-linux-amd64-v2.6.1.bin.tar.gz
我下载的是2.6.1版本 连接下载地址界面:
https://sourceforge.net/projects/leanote-bin/
(PS:现在最新版本就是v2.6.1版)
t@iZuf6c40gmjvniytagm3upZ ~]# wget --no-check-certificate https://nchc.dl.sourceforge.net/project/leanote-bin/2.6.1/leanote-linux-amd64-v2.6.1.bin.tar.gz--2022-10-21 16:45:27--https://nchc.dl.sourceforge.net/project/leanote-bin/2.6.1/leanote-linux-amd64-v2.6.1.bin.tar.gzResolving nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)... 140.110.96.69, 2001:e10:ffff:1f02::17Connecting to nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)|140.110.96.69|:443... connected.WARNING: cannot verify nchc.dl.sourceforge.net's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:Issued certificate has expired.HTTP request sent, awaiting response... 200 OKLength: 21438265 (20M) [application/x-gzip]Saving to: ‘leanote-linux-amd64-v2.6.1.bin.tar.gz’100%[============================================================================================>] 21,438,2655.52MB/sin 4.7s2022-10-21 16:45:32 (4.33 MB/s) - ‘leanote-linux-amd64-v2.6.1.bin.tar.gz’ saved [21438265/21438265][root@iZuf6c40gmjvniytagm3upZ ~]# lsleanote-linux-amd64-v2.6.1.bin.tar.gz[root@iZuf6c40gmjvniytagm3upZ ~]# 我们就会在root文件夹下,看到我们刚才下载的
leanote-linux-amd64-v2.6.1.bin.tar.gz压缩文件 。
执行解压缩命令:tar -zxvf
leanote-linux-amd64-v2.6.1.bin.tar.gz
[root@iZuf6c40gmjvniytagm3upZ ~]# tar -zxvf leanote-linux-amd64-v2.6.1.bin.tar.gzleanote/leanote/app/leanote/bin/...解押完毕后,我们就会在当前目录下看到一个leanote文件夹 。
[root@iZuf6c40gmjvniytagm3upZ ~]# lsleanoteleanote-linux-amd64-v2.6.1.bin.tar.gz[root@iZuf6c40gmjvniytagm3upZ ~]# 3.2 修改app.conf配置Leanote官方介绍,需要将leanote/conf/app.conf中的app.secret项进行修改 。否则会有安全风险 。
那么我们通过vim修改该文件就可以了 。
[root@iZuf6c40gmjvniytagm3upZ ~]# lsleanoteleanote-linux-amd64-v2.6.1.bin.tar.gz[root@iZuf6c40gmjvniytagm3upZ ~]# vim leanote/conf/app.conf 在打开的文件中找到:app.secret选项 。
# mongdbdb.host=127.0.0.1db.port=27017db.dbname=leanote # requireddb.username= # if not exists, please leave it blankdb.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=V85ZzBeTnzpsHyjQX4zukbQ8qqtju9y2aDM55VWxAH9Qop19poekx3xkcDVvrD0y ##--------------------------------# revel config# for dev#-----------------------修改成任意字符就可以:
# You Must Change It !! About Security!!app.secret=123qweasdzxcqweasdzxc然后执行保存操作即可 。

该配置文件也决定了Leanote服务的启动端口哦 。默认配置端口为9000 。如果想修改们可以通过该文件进行修改
3.3 初始化Leanote数据库配置完毕后,就可以开始配置数据库连接和初始化了 。
示例如下:
[root@iZuf6c40gmjvniytagm3upZ ~]# mongorestore -h localhost -d leanote --dir /root/leanote/mongodb_backup/leanote_install_data/注意,我的leanote目录就在root文件夹下,所以这么配置的 。
大家要根据实际的leanote目录所在位置,进行修改--dir 配置后的路径哦 。
当日志输出 done的时候,就代表数据库已经初始化结束了 。
3.4 启动Leanote服务常见的启动方法会让我们通过下面这个代码执行启动:


推荐阅读