惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
N
News | PayPal Newsroom
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
博客园 - Franky
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
The Register - Security
The Register - Security
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
S
Security Affairs
博客园 - 司徒正美
S
Schneier on Security
I
InfoQ
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
腾讯CDC
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
V
Vulnerabilities – Threatpost
C
Check Point Blog
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
Schneier on Security
Schneier on Security
O
OpenAI News
K
Kaspersky official blog

博客园 - 努力&快乐

springboot 手动开启事务及手动提交事务 js MD5包含中文串时加密结果与JAVA结果不一致的解决方案 JavaScript通过递归合并JSON linux系统关闭指定服务的方式 Dart 语言简易教程系列 查看java内存情况命令 JAVA用QRCode生成二维码 安装redis时Newer version of jemalloc required错误解决 代码指标工具 spring mvc接收ajax提交的JSON数据,并反序列化为对象 二进制样式的字符串与byte数组互转函数示例 .net运行时dll的查找路径顺序 WebStorm11 注册 MSSql使用SQL语句快速查看表对的就说明,及表字段描述及字段类型 多个App间传递数据 cordova混合开发:Android中native调用javascript cordova plugin数据传递概要 javascript不用new关键字创建对象示例 .Net事件管道详解图
mongodb配置、启动、备份
努力&快乐 · 2018-09-11 · via 博客园 - 努力&快乐
Mongodb:
启动:
/usr/bin/mongod --config /data/mydata/mongodb/mongodb.conf

停止Mongodb:
方法一:$ mongod --shutdown --dbpath 数据路径
方法二:查看进程,使用kill命令;不能使用kill -9,可用kill -2 或kill-15
方法三:在客户端进去,使用shutdown命令
> use admin;
switched to db admin
> db.shutdownServer();
server should be down..

自动备份脚本:
/data/mydata/mongodb/mongodb_bak.sh
配置定时任务:crontab;


//mongod.conf:
# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /data/mydata/mongodb/logs/mongodb.log

# Where and how to store data.
storage:
  dbPath: /data/mydata/mongodb/db
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongod.pid  # location of pidfile


# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:
 



//mongodb_bak.sh:
#!/bin/bash  
#backup MongoDB  

#mongodump命令路径  
DUMP=mongodump  
#临时备份目录  
OUT_DIR=/data/mydata/mongodb/bak/bak_tmp
#备份存放路径  
TAR_DIR=/data/mydata/mongodb/bak/bak_list  
#获取当前系统时间  
DATE=`date +%Y_%m_%d`  
#数据库账号  
DB_USER=  
#数据库密码  
DB_PASS=123  
#DAYS=15代表删除15天前的备份,即只保留近15天的备份  
DAYS=15  
#最终保存的数据库备份文件  
TAR_BAK="mongodb_bak_$DATE.tar.gz"  

cd $OUT_DIR  
rm -rf $OUT_DIR/*  
mkdir -p $OUT_DIR/$DATE  
#备份全部数据库  
#$DUMP -h 10.168.1.10:27017 -u $DB_USER -p $DB_PASS --authenticationDatabase "admin" -o $OUT_DIR/$DATE  
$DUMP -o $OUT_DIR/$DATE  
#压缩为.tar.gz格式  
tar -zcvf $TAR_DIR/$TAR_BAK $OUT_DIR/$DATE  
#删除15天前的备份文件  
find $TAR_DIR/ -mtime +$DAYS -delete  

exit  

posted on 2018-09-11 17:39  努力&快乐  阅读(323)  评论()    收藏  举报