1.mongodb
cat >>/etc/systemd/system/mongodb_master.service<<EOF
[Unit]
Description=mongodb_master
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/opt/mongodb_master/bin/mongod --config /opt/mongodb_master/data/conf/mongod.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/opt/mongodb_master/bin/mongod --shutdown --config /opt/mongodb_master/data/conf/mongod.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
$ systemctl start mongodb_master.service
$ systemctl enable mongodb_master.service
2.elasticsearch
$ cat > /usr/lib/systemd/system/elasticsearch.service << EOF
[Unit]
Description=Elasticsearch
Wants=network-online.target
After=network-online.target
[Service]
User=es
Group=es
ExecStart=/opt/elasticsearch/bin/elasticsearch
ExecReload=/bin/kill -HUP \$MAINPID
LimitNOFILE=65535
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
$ systemctl start elasticsearch
$ systemctl enable elasticsearch
3.nginx
cat > /usr/lib/systemd/system/nginx.service << EOF
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/opt/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
$ systemctl start nginx
$ systemctl enable nginx