目录
Mongo
基本使用
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org --allow-unauthenticated
sudo service mongod start
更多MongoDB安装 可以参考
Install MongoDB Community Edition on Ubuntu
sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2018-12-11 09:38:18 CST; 29s ago
Docs: https://docs.mongodb.org/manual
Process: 9756 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=62)
Main PID: 9756 (code=exited, status=62)
sudo rm -rf /var/lib/mongodb
sudo mkdir /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo service mongod start
关于上述问题详细可以参考MongoDB - shutting down with code:62
设置访问
sudo vim /etc/mongod.conf
# bindIp: 0.0.0.0
sudo service mongod restart
netstat -lnpt | grep 27017
# tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN -
设置权限
mongo
use admin
db.createUser({user: 'root', pwd: '123456', roles: ['root']})
# Successfully added user: { "user" : "root", "roles" : [ "root" ] }
db.auth('root', '123456')
# 1
use cronsun
db.createUser({user: "cronsun", pwd: "123456", roles: [ { role: "readWrite", db: "cronsun" } ]});
# Successfully added user
db.auth('cronsun', '123456')
# 1
sudo vim /etc/mongod.conf
security:
authorization: enabled
sudo service mongod restart
关于Mongo更多配置可以参考security Options
Etcd
基本使用
curl -L https://github.com/coreos/etcd/releases/download/v3.3.1/etcd-v3.3.1-linux-amd64.tar.gz -o etcd-v3.3.1-linux-amd64.tar.gz
tar xzvf etcd-v3.3.1-linux-amd64.tar.gz
cd etcd-v3.3.1-linux-amd64
sudo cp etcd /usr/local/bin/
sudo cp etcdctl /usr/local/bin/
nohup etcd &
jobs -l
# [1]+ 10276 Running nohup etcd &
关于Etcd安装 详细可以参考Install etcd On Ubuntu 16.04.md
设置访问
sudo kill -9 10276
sudo mkdir -p /opt/etcd/default.etcd
sudo vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=etcd
[Service]
Type=notify
Restart=always
RestartSec=10s
LimitNOFILE=40000
Environment=ETCD_DATA_DIR=/opt/etcd/default.etcd
Environment=ETCD_NAME=%m
Environment=ETCD_ELECTION_TIMEOUT=1200
Environment="ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379"
Environment="ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379"
Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://0.0.0.0:2380"
Environment="ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380"
ExecStart=/usr/local/bin/etcd
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start etcd
netstat -lnpt | grep 2379
# tcp6 0 0 :::2379 :::* LISTEN -
关于Etcd更多配置可以参考etcd基础和etcd3 multi-node cluster
设置权限
etcdctl --endpoints http://127.0.0.1:2379 user add root
# 设置root密码
关于Etcd权限控制更多可以参考Etcd访问控制
Cronsun
基本使用
sudo apt install -y unzip
unzip cronsun-v0.3.5-linux-amd64.zip
sudo mv cronsun-v0.3.5 /opt/
cd /opt/cronsun-v0.3.5
vim conf/db.json
# "cronsun:123456@127.0.0.1:27017"
nohup sudo ./cronnode -conf conf/base.json >> /tmp/cronsun-node.log 2>&1 &
nohup sudo ./cronweb -conf conf/base.json >> /tmp/cronsun-web.log 2>&1 &
sudo vim /etc/nginx/sites-enabled/cronsun.conf
server {
listen 80;
server_name cron.zeaho.com;
location / {
proxy_pass http://localhost:7079/;
}
}
sudo nginx -t
sudo nginx -s reload
添加节点
vim conf/db.json
# "cronsun:123456@{{server.ip}}:27017"
vim conf/etcd.json
# "http://{{server.ip}}:2379"
上述{{server.ip}}配置要改成MongoDB和Etcd服务实际地址
nohup sudo ./cronnode -conf conf/base.json >> /tmp/cronsun-node.log 2>&1 &
Todo
- Etcd账号管理和访问控制
网友评论