How to install redis in Mac OSX using home brew
Answer:
To install redis on Mac OSX using homebrew, use
# brew install redis
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to install redis in Mac OSX using home brew
Answer:
To install redis on Mac OSX using homebrew, use
# brew install redis
How to disable MySQL from autostart when Ubuntu bootup
Answer:
A newer version of MySQL use upstart to autostart when system bootup, to disable it
# sudo mkdir /etc/init.disabled # sudo mv /etc/init/mysql.conf /etc/init.disabled/
Generate random data in MongoDB
Answer:
You can use the following method to generate random string into a collection in MongoDB:
function randomString() {
var chars =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var randomstring = '';
var string_length = 100;
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
return randomstring;
}
for(var i=0; i<2000000; i++){db.test.save({x:i, data:randomString()});}
How to get the total database index size of my MongoDB
Answer:
In you mongo shell, execute the following command:
var sum = 0; db.getMongo().getDBs()["databases"].forEach(function(x) { sum += db.getMongo().getDB(x.name).stats().indexSize }); print(sum)
Check how long a MongoDB instance was running
Answer:
To see how long a MongoDB instance was running, you can login into the mongo shell, and enter
db.serverStatus().uptime / 3600
The above command reply the value in term of hours.