The basic procedure is to start the mongod instances that will become members of the replica set, configure the replica set itself, and then add the mongod instances to it.
Before you can deploy a replica set, you must install MongoDB on each system that will be part of your replica set.
1、在每台机器上下载解压mongodb安装包
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.21.tgz tar -zxvf mongodb-linux-x86_64-rhel70-3.4.21.tgz mv mongodb-linux-x86_64-rhel70-3.4.21/ /usr/local/mongodb
注:Copy the keyfile to each server hosting the replica set members. Ensure that the user running the mongod instances is the owner of the file and can access the keyfile.
The following db.updateUser() method completely replaces the user’s customData and roles data:
use products
db.updateUser( “appClient01”,
{
customData : { employeeId : “0x3039” },
roles : [
{ role : “read”, db : “assets” }
]
}
)
The user appClient01 in the products database now has the following user information:
{
“_id” : “products.appClient01”,
“user” : “appClient01”,
“db” : “products”,
“customData” : { “employeeId” : “0x3039” },
“roles” : [
{ “role” : “read”,
“db” : “assets”
}
]
}
5.分配用户更多权限:
Example
Given a user accountUser01 in the products database with the following roles:
“roles” : [
{ “role” : “assetsReader”,
“db” : “assets”
}
]
The following grantRolesToUser() operation gives accountUser01 the readWrite role on the products database and the read role on the stock database.
use products
db.grantRolesToUser(
“accountUser01”,
[ “readWrite” , { role: “read”, db: “stock” } ],
{ w: “majority” , wtimeout: 4000 }
)
The user accountUser01 in the products database now has the following roles:
“roles” : [
{ “role” : “assetsReader”,
“db” : “assets”
},
{ “role” : “read”,
“db” : “stock”
},
{ “role” : “readWrite”,
“db” : “products”
}
]
6.撤销用户相关权限:
Example
The accountUser01 user in the products database has the following roles:
“roles” : [
{ “role” : “assetsReader”,
“db” : “assets”
},
{ “role” : “read”,
“db” : “stock”
},
{ “role” : “readWrite”,
“db” : “products”
}
]
The following db.revokeRolesFromUser() method removes the two of the user’s roles: the read role on the stock database and the readWrite role on the products database, which is also the database on which the method runs:
use products
db.revokeRolesFromUser( “accountUser01”,
[ { role: “read”, db: “stock” }, “readWrite” ],
{ w: “majority” }
)
The user accountUser01 user in the products database now has only one remaining role:
All GitLab packages are posted to our package server and can be downloaded.
GitLab EE: for official Enterprise Edition releases
GitLab CE: for official Community Edition releases
Unstable: for release candidates and other unstable versions
Browse to the repository for the type of package you would like, in order to see the list of packages that are available. There are multiple packages for a single version, one for each supported distribution type. Next to the filename is a label indicating the distribution, as the file names may be the same.
Locate the desired package for the version and distribution you want to use, and click on the filename to download.
2.Installing the GitLab Package
With the desired package downloaded, use your systems package management tool to install it. For example:
Change http://gitlab.example.com to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL.
On your first visit, you’ll be redirected to a password reset screen. Provide the password for the initial administrator account and you will be redirected back to the login screen. Use the default account’s username root to login.
注:若修改了redis.conf文件中的bind地址之后,重启redis出现Could not connect to Redis at 127.0.0.1:6379: Connection refused错误,需要修改脚本(例如/etc/init.d/redis),找到如下字符串$CLIEXE -p $REDISPORT shutdown,修改为$CLIEXEC -h ip -a “password” -p $REDISPORT shutdown(即添加-h ip,ip应与上述bind地址保持一致)
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
解决:
修改/etc/sysctl.conf文件,增加一行:
net.core.somaxconn = 1024
然后执行命令:sysctl -p
告警2:
2865:M 01 Nov 17:36:36.055 # WARNING overcommit_memory is set to 0! Background save may fail
under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect.
解决:
修改/etc/sysctl.conf文件,增加一行:
vm.overcommit_memory = 1
然后执行命令:sysctl -p
告警3:
2865:M 01 Nov 17:36:36.055 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled’ as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.