#!/bin/bash
#mongo部署
cd /data/install-page/
tar -zxvf mongodb-linux-x86_64-4.0.0.tgz
mv mongodb-linux-x86_64-4.0.0 /data/mongodb
cd /data/mongodb
mkdir /data/mongodb/mongodata
mkdir /data/mongodb/logs
mkdir /data/mongodb/PID
touch /data/mongodb/logs/mongodb.log
touch /data/mongodb/mongodb.conf
echo 'port=27017
bind_ip=0.0.0.0
dbpath=/data/mongodb/mongodata/
logpath=/data/mongodb/logs/mongodb.log
pidfilepath=/data/mongodb/mongo.pid
fork=true
logappend=true
auth=false
#auth=true' > /data/mongodb/mongodb.conf
touch /lib/systemd/system/mongodb.service
echo '[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/data/mongodb/bin/mongod --config /data/mongodb/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/data/mongodb/bin/mongod --shutdown --config /data/mongodb/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target' > /lib/systemd/system/mongodb.service
chmod 755 /lib/systemd/system/mongodb.service
systemctl enable mongodb.service
systemctl start mongodb.service
systemctl status mongodb.service
echo '#ES
#MONGODB
export ES_HOME=/data/mongodb
export PATH=$ES_HOME/bin:$PATH' >> /etc/profile