This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Create the repo for MongoDB | |
cd /etc/yum.repos.d/ | |
fpath=$(pwd) | |
printf "\n Working diretory is: %s \n" $fpath | |
printf "\n%s\n" "Creating .repo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: /var/log/mongodb/mongod.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Grouping sets where count is > than 1 | |
db.BatchItemStatus.aggregate( [ | |
{ $group: { _id: { | |
"field1": "$field1", | |
"field2": "$field2" , | |
"field3" : "$field3" | |
}, | |
count: { $sum: 1 } } }, | |
{ $match: { count: { $gt: 1 } } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By _id | |
db.BatchItemStatus.remove( {"_id": "a0ab0222-777f-4e10-9b5c-f0fac96b7281"}); | |
// Delete one by field filters | |
db.BatchItemStatus.deleteOne({"SomeId" : "6174b095-fbtd-44a5-a304-4482f32aa33c", "SomeOtherId" : "a1f35ac3-2155-4c47-aa3b-ee2667d28fb6"}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select j.name | |
,js.step_name | |
,jh.sql_severity | |
,jh.message | |
,jh.run_date | |
,jh.run_time | |
,js.step_id | |
,js.command | |
,js.database_name | |
,js.output_file_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Check Database DBCC status | |
SELECT TOP 1 DB_Name(s.dbid), | |
percent_complete, | |
session_id, | |
start_time, | |
r.status, | |
command, | |
wait_type, | |
last_wait_type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Open terminal and run: | |
ssh-keygen -t rsa | |
//Hit enter to accept the default location | |
//Enter a pass phrase - be sure to save phrase to your key managment app | |
//Note the paths of the private/public keys as well as the key fingerprintGenerating Public-Private SSH keys on MacOS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create keyfile with openssl | |
openssl rand -base64 756 > //<path-to-keyfile> | |
//Change permissions to read permissions for file owner only | |
chmod 600 //<path-to-keyfile> | |
//Change owner and group of file to user running the mongo service | |
chown vagrant:vagrant //<path-and-keyfilename> | |
//Copy the keyfile to each replica set | |
//Change owner of the file to the owner of the mongod process | |
//Shutodown all replica set memebers, secondary to primary | |
//Modify config file for each replica set member: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Simple log queries | |
sudo journalctl -u docker.service -n 100 | |
sudo docker container logs <container ID> --details | |
#Delete all dangling images referenced in a layer or anything which has no container running | |
docker rmi $(docker images --filter "dangling=true" -q --no-trunc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Backups | |
//untar | |
tar -zxvf backups.tgz | |
//mongorestore | |
/usr/bin/mongorestore backups.tgz | |
////////////////////////// | |
//Server level |
NewerOlder