日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

蚂蚁笔记私有部署

發(fā)布時間:2025/3/21 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 蚂蚁笔记私有部署 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

說明

其實官方的教程中已經(jīng)寫得很清楚了,我寫這個主要是為了記錄一下我自己當時安裝的過程,方便后續(xù)查詢

官方文檔請查閱:https://github.com/leanote/leanote/wiki

環(huán)境要求

  • CentOS6.5+Nginx+MongoDB
  • 最小配置:16G內(nèi)存+4CPU+500G硬盤
  • 推薦配置:32G內(nèi)存+4CPU+1T硬盤

安裝過程

  • 安裝 CentOS 6.5

最小化安裝,分區(qū)如下,推薦基于LVM,后面維護比較方便:

/boot 500Mswap 8G/ 20G/data 剩下所有
  • 系統(tǒng)優(yōu)化

關(guān)閉SELinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/'/etc/s

精簡啟動項

LANG=en for root in `chkconfig --list|grep 3:on|awk '{print 1}'`;do chkconfig --level 3 root off;done for root in crond network rsyslog sshd iptables;do chkconfig --level 3 $root on;done chkconfig --list|grep 3:on
  • 安裝軟件

    安裝Nginx

安裝Nginx的YUM源 rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm yum -y install nginx

安裝其他軟件

yum -y install vim wget curl lsof net-tools openssl
  • 安裝Mongodb

編輯mongodb的YUM源

#vim /etc/yum.repos.d/mongodb-org-3.4.repo #添加入一下內(nèi)容 [mongodb-org-3.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.4.as

安裝mongodb

yum -y install mongodb-org
  • 自定義Mondodb數(shù)據(jù)庫

修改數(shù)據(jù)庫存儲路徑,將dbpath自定義成自己的data分區(qū),首先需要創(chuàng)建目錄并賦予權(quán)限

mkdir -p /data/db chown -Rf mongod:mongod /data/db chmod -Rf 755 /data/db

更改MongoDB數(shù)據(jù)庫存儲路徑,修改dbPath

# vim /etc/mongod.conf ... systemLog:destination: filelogAppend: truepath: /var/log/mongodb/mongod.log# Where and how to store data.storage:dbPath: /data/db/ //我們需要指定庫文件的存放目錄journal:enabled: true# how the process runsprocessManagement:fork: true # fork and run in backgroundpidFilePath: /var/run/mongodb/mongod.pid # location of pidfile# network interfacesnet:port: 27017bindIp: 127.0.0.1 ...
  • 啟動Mongodb并加入開機自啟
service mongod start chkconfig mongod on
  • 部署螞蟻筆記

下載螞蟻筆記

cd /data wget https://sourceforge.net/projects/leanote-bin/files/2.5/leanote-linux-amd64-v2.5.bin.tar.gz

解壓文件

tar -zxvf leanote-linux-amd64-v2.5.bin.tar.gz

導入初始化數(shù)據(jù)庫

mongorestore -h localhost -d leanote --dir /data/leanote/mongodb_backup/leanote_install_data/

給mongodb添加數(shù)據(jù)庫用戶

mongo 首先切換到leanote數(shù)據(jù)庫下 > use leanote; 添加一個用戶root, 密碼是abc123,這個密碼是可以自定義的 > db.createUser({user: 'root',pwd: 'abc123',roles: [{role: 'dbOwner', db: 'leanote'}]}); 測試下是否正確 > db.auth("root", "abc123");1 返回1表示正確

修改app.conf

# vim /data/leanote/conf/app.conf ...db.host=localhostdb.port=27017db.dbname=leanotedb.username=rootdb.password=abc123 ...

重啟數(shù)據(jù)庫服務(wù)

service mongod restart

嘗試運行

bash /data/leanote/bin/run.sh

如果終端提示如下就說明配置是正確的

... TRACE 2013/06/06 15:01:27 watcher.go:72: Watching: /home/life/leanote/bin/src/github.com/leanote/leanote/conf/routes Go to /@tests to run the tests. Listening on :9000 ...
  • 嘗試訪問,記得先關(guān)閉下防火墻

恭喜你, 打開瀏覽器輸入: http://localhost:9000體驗leanote吧!

  • 配置支持https

創(chuàng)建證書

首先,創(chuàng)建證書和私鑰的目錄 # mkdir -p /etc/nginx/cert # cd /etc/nginx/cert 創(chuàng)建服務(wù)器私鑰,命令會讓你輸入一個口令: # openssl genrsa -des3 -out nginx.key 2048 創(chuàng)建簽名請求的證書(CSR): # openssl req -new -key nginx.key -out nginx.csr 在加載SSL支持的Nginx并使用上述私鑰時除去必須的口令: # cp nginx.key nginx.key.org # openssl rsa -in nginx.key.org -out nginx.key 最后標記證書使用上述私鑰和CSR: # openssl x509 -req -days 365 -in nginx.csr -signkey nginx.key -out nginx.crt

配置Nginx

配置nginx.conf

# vim /etc/nginx/nginx.conf 添加入一下內(nèi)容 #本配置只有http部分, 不全, 詳細配置請百度Nginx相關(guān)知識 http {include /etc/nginx/mime.types;default_type application/octet-stream;upstream note.cloud.top {server localhost:9000;}# httpserver{listen 80;server_name note.cloud.top;# 強制https# 如果不需要, 請注釋這一行rewriterewrite ^/(.*) https://note.cloud.top/$1 permanent;location / {proxy_pass http://note.cloud.top;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}# httpsserver{listen 443 ssl;server_name note.cloud.top;ssl_certificate /etc/nginx/cert/nginx.crt; # 修改路徑, 到nginx.crt, 下同ssl_certificate_key /etc/nginx/cert/nginx.key;location / {proxy_pass http://note.cloud.top;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}}

啟動Nginx

service nginx start chkconfig nginx on
  • 筆記系統(tǒng)開機自啟

注意

官方文檔并沒有給出這項設(shè)置,其實最簡單的辦法就是向rc.local文件中添加一條命令,開機自動執(zhí)行,但是這里推薦使用supervisor服務(wù)進行管理,supervisor的詳細介紹見:http://www.supervisord.org/**

方法1:

# vim /etc/rc.d/rc.local 添加下面的內(nèi)容,這樣的化開機后就不會有影響 nohup bash /data/leanote/bin/run.sh &

方法2-推薦使用
使用supervisor服務(wù)進行管理的優(yōu)點是服務(wù)異常后自動重啟,可靠性較高

  • 安裝supervisor服務(wù)
yum install epel-release -y && yum install supervisor -y
  • 配置supervisor
vim /etc/supervisord.conf 在文件末尾加入以下內(nèi)容··· [program:webvirtmgr] command=bash /data/leanote/bin/run.sh autostart=true autorestart=true logfile=/dev/null log_stderr=true user=root···

logfile我們定義到磁盤黑洞中,就不用占用磁盤的空間,同時減少部分磁盤IO開銷

  • 啟動supervisor服務(wù)并添加到開機自啟中
# chkconfig supervisord on && service supervisord start
  • 防火墻配置
#清空配置 iptables -F iptables -X #如果是遠程ssh連接配置務(wù)必先執(zhí)行這條命令,否則會斷開ssh連接,無法進行后續(xù)工作 iptables -A INPUT -p tcp --dport 22 -j ACCEPT iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -P FORWARD DROP #允許80、443、9000、53(DNS)端口 iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -A INPUT -p tcp --dport 9000 -j ACCEPT iptables -A INPUT -p tcp --sport 53 -j ACCEPT iptables -A INPUT -p udp --sport 53 -j ACCEPT #允許ping iptables -A INPUT -p icmp -j ACCEPT #允許loopback!(不然會導致DNS無法正常關(guān)閉等問題) iptables -A INPUT -i lo -p all -j ACCEPT #丟棄壞的TCP包 iptables -A FORWARD -p TCP ! --syn -m state --state NEW -j DROP #處理IP碎片數(shù)量,防止攻擊,允許每秒100個 iptables -A FORWARD -f -m limit --limit 100/s --limit-burst 100 -j ACCEPT #設(shè)置ICMP包過濾,允許每秒1個包,限制觸發(fā)條件是10個包 iptables -A FORWARD -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT service iptables save service iptables restart
  • 其它配置

修改leanote運行端口

比如想以8080端口啟動.修改conf/app.conf:

http.port=8080 site.url=http://note.cloud.top:8080

請重啟Leanote, 使用http://note.cloud.top:8080

綁定域名

提示

site.url其實是自己可以自定義的,因為在瀏覽器中我們登錄注銷后url會自動變成這個語句設(shè)置的值,所以務(wù)必設(shè)置正確。

site.url=http://note.cloud.top 或 site.url=https://note.cloud.top 請重啟Leanote, 使用http://note.cloud.top 或者 https:note.cloud.top 進行訪問

轉(zhuǎn)載于:https://www.cnblogs.com/tchroot/p/7732754.html

總結(jié)

以上是生活随笔為你收集整理的蚂蚁笔记私有部署的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。