蚂蚁笔记平台搭建
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了蚂蚁笔记平台搭建相关的知识,希望对你有一定的参考价值。
一. centos6.5_X86_64最小化安装(这一步不多说,直接安装就可以,记得配置IP地址等信息。)
要求:不要使用系统默认的分区,采用以下分区格式:
将默认的逻辑卷组重新配置:
1. 将root卷组大小分配缩小到20G,
2. home卷组重命名为data,直接使用剩下所有空间(会有提示最多可以分配多大空间),
3. 交换分区和boot默认不用动.
二. 对于centos6.5的优化
1.接下里关闭防火墙和selinux,用这个安全,但是麻烦,懒得配置,用起来还要占用一定资源。
#service iptables stop
#chkconfig iptables off
#sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘/etc/selinux/config
或者直接修改selinux的config
#vim /etc/selinux/config
#yum install wget -y
#yum install vim -y
2.开机最简化:
- # 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;do chkconfig --level 3 $root on;done
- # chkconfig --list|grep 3:on
3.安装更新
- #yum update -y??
4.安装nginx和MongoDB
安装nginx:
- # rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
- #yum install nginx -y ??
三、安装MongoDB:
配置yum源:
vi /etc/yum.repos.d/mongodb-org-3.4.repo
- [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.asc ??
#yum instalgl mongodb-or??
安装完成mongodb后我们要在/data下创建一个mongodb用来存储库文件的文件夹,并赋权限给mongodb
#mkdir -p /data/db/
#chown -Rf mongod:mongod /data/db
#chmod -Rf 755 /data/db
下面我们修改mongodb的配置文件,指定一个库存放地址
#vi /etc/mongod.conf
- systemLog:
- destination: file
- logAppend: true
- path: /var/log/mongodb/mongod.log
- # Where and how to store data.
- storage:
- dbPath: /data/db/ //我们需要指定库文件的存放目录
- journal:
- enabled: true
- # how the process runs
- processManagement:
- fork: true # fork and run in background
- pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
- # network interfaces
- net:
- port: 27017
- bindIp: 127.0.0.1
启动mongod
#service mongod start
四、安装LeaNote
1.下载leanote
#cd /data
#wget https://sourceforge.net/projects/leanote-bin/files/2.4/leanote-linux-amd64-v2.4.bin.tar.gz
tar -zxvf leanote-linux-amd64-v2.4.bin.tar.gz
2.导入初始数据
- mongorestore -h localhost -d leanote --dir /data/leanote/mongodb_backup/leanote_install_data/?
3.为mongodb添加用户
mognodb v2与v3创建用户命令有所不同
mongodb v2 创建用户如下:
- # 首先切换到leanote数据库下
- > use leanote;
- # 添加一个用户root, 密码是abc123
- > db.addUser("root", "abc123");
- {
- "_id" : ObjectId("53688d1950cc1813efb9564c"),
- "user" : "root",
- "readOnly" : false,
- "pwd" : "e014bfea4a9c3c27ab34e50bd1ef0955"
- }
- # 测试下是否正确
- > db.auth("root", "abc123");
- 1 # 返回1表示正确
mongodb v3 创建用户如下:
- # 首先切换到leanote数据库下
- > use leanote;
- # 添加一个用户root, 密码是abc123
- > db.createUser({
- user: ‘root‘,
- pwd: ‘abc123‘,
- roles: [{role: ‘dbOwner‘, db: ‘leanote‘}]
- });
- # 测试下是否正确
- > db.auth("root", "abc123");
- 1 # 返回1表示正确
用户添加好后重新运行下mongodb, 并开启权限验证. 在mongod的终端按ctrl+c即可退出mongodb.
重新启动mongodb:
还要修改配置文件 : 修改 leanote/conf/app.conf:
- db.host=localhost
- db.port=27017
- db.dbname=leanote
- db.username=root
- db.password=abc123
ok,我们需要测试下是否配置正确
bash /data/leanote/bin/run.sh
如果提示错误,可能是下面的问题
1.0版之前(beta版)会遇到这个问题, 1.0采用revel-0.12, 所以不会遇到这个问题.
- Failed to load module. Import of github.com/revel/revel/modules/testrunner failed: cannot find package "github.com/revel/revel/modules/testrunner" in any of:
- /Users/life/app/go1.4/src/github.com/revel/revel/modules/testrunner (from $GOROOT)
- /Users/life/Documents/Go/package_base/src/github.com/revel/revel/modules/testrunner (from $GOPATH)
revel 0.12 版配置不一样, 请修改app.conf
- module.static=github.com/revel/modules/static
- module.testrunner=github.com/revel/modules/testrunner
五、配置nginx代理
生成证书
- 可以通过以下步骤生成一个简单的证书:
- 首先,进入你想创建证书和私钥的目录,
- [[email protected] /]# mkdir -p /etc/nginx/cert
- [[email protected] /]# cd /etc/nginx/cert
- 创建服务器私钥,命令会让你输入一个口令:
- [[email protected] /]# openssl genrsa -des3 -out nginx.key 2048
- 创建签名请求的证书(CSR):
- [[email protected] /]# openssl req -new -key nginx.key -out nginx.csr
- 在加载SSL支持的Nginx并使用上述私钥时除去必须的口令:
- [[email protected] /] # cp nginx.key nginx.key.org
- [[email protected] /] # openssl rsa -in nginx.key.org -out nginx.key
- 最后标记证书使用上述私钥和CSR:
- [[email protected] /] # openssl x509 -req -days 365 -in nginx.csr -signkey nginx.key -out nginx.crt
- 配置nginx??
vim /etc/nginx/nginx.conf
添加
- upstream note.cloud.top {
- server localhost:9000;
- }
nginx.conf整个配置如下
- user nginx;
- worker_processes 1;
- error_log /var/log/nginx/error.log warn;
- pid /var/run/nginx.pid;
- events {
- worker_connections 1024;
- }
- http {
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
- log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
- ‘$status $body_bytes_sent "$http_referer" ‘
- ‘"$http_user_agent" "$http_x_forwarded_for"‘;
- upstream note.cloud.top { //我们添加的内容
- server localhost:9000;
- } //结束
- access_log /var/log/nginx/access.log main;
- sendfile on;
- #tcp_nopush on;
- keepalive_timeout 65;
- #gzip on;
- include /etc/nginx/conf.d/*.conf;
- }
# cd /etc/nginx/conf.d
#mv default.conf default.conf.bak
#vim leanote.conf
- server {
- listen 443;
- server_name note.cloud.top;
- ssl on;
- ssl_certificate /etc/nginx/cert/nginx.crt;
- ssl_certificate_key /etc/nginx/cert/nginx.key;
- ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2;
- ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
- ssl_prefer_server_ciphers on;
- 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;
- }
- error_page 404 /404.html;
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
- }
#vim.leanote2.conf
- server {
- listen 80;
- server_name note.cloud.top;
- rewrite ^(.*)$ https://$host$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;
- }
- }
最后的配置:
#chkconfig mongod on
#chkconfig nginx on
#vim /etc/rc.d/rc.local 添加下面的一条命令
nohup bash /data/leanote/bin/run.sh &
这样开机的时候就能正常开机自启了,并且在后台不受影响,官方文档中给的命令关闭掉终端后就服务停止了
#reboot验证
--------------------------------------
文档中如有不正确的地方,请大家提出并且加以修改
以上是关于蚂蚁笔记平台搭建的主要内容,如果未能解决你的问题,请参考以下文章
搭建ELK日志分析平台(下)—— 搭建kibana和logstash服务器