Last active
November 17, 2020 14:08
-
-
Save cokia/5d5491c83888e0e10fa7530ea0a3154a to your computer and use it in GitHub Desktop.
mongodb-install.sh
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
sudo apt-get install gnupg | |
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - | |
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list | |
sudo apt-get update | |
sudo apt-get install -y awscli | |
sudo apt-get install -y jq | |
sudo apt-get install -y mongodb-org | |
get_param() { | |
P=$(aws ssm get-parameter --region ap-northeast-2 --with-decryption --name "$1" | jq -r '.Parameter.Value') | |
echo "$P" | |
} | |
PASSWORD=$(get_param "pointing-dev-db-password") | |
echo $PASSWORD >> password.txt | |
sudo chown -R mongodb:mongodb /data | |
sudo sed -i 's!/var/lib/mongodb!/data!' /etc/mongod.conf | |
sudo sed -i 's!/var/log/mongodb/mongod.log!/data/log/mongod.log!' /etc/mongod.conf | |
sudo systemctl daemon-reload | |
sudo systemctl start mongod | |
mongo admin --eval "db.createUser({user: 'root', pwd: '${password}', roles:['root']});" | |
sudo service mongod stop | |
sudo echo 'security:' >> /etc/mongod.conf | |
sudo echo ' authorization: enabled' >> /etc/mongod.conf | |
sudo sed -i 's/127.0.0.1/0.0.0.0/' /etc/mongod.conf | |
#sudo ln -s /data /var/lib/mongodb | |
sudo chown mongodb:mongodb /data | |
sudo systemctl start mongod | |
#mongodb-mms (cloud ops) install code | |
curl -OL https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_10.21.1.6639-1_amd64.ubuntu1604.deb | |
sudo dpkg -i mongodb-mms-automation-agent-manager_10.21.1.6639-1_amd64.ubuntu1604.deb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment