Gitlab cluster deployment related services
1.Gitlab server
- System:
ubuntu 14.04 x86_64
- Gitlab master:
10.100.136.62
- Gitlab slave:
10.100.136.63
- Gitlab version:
GitLab Community Edition 8.13.5
- Location:
/var/opt/gitlab
2.redis/pgsql
- System:
centos 6.8 x86_64
- Redis:
10.100.17.25:6380
- Pgsql:
10.100.17.25:5432
- Version:
redis:2.8,pgsql:9.6
- Location:
/data/redis,/var/lib/pgsql/9.6
3.DRBD & keepalived & nfs
- System:
centos 6.8 x86_64
- DRBD master:
10.100.17.31
- DRBD slave:
10.100.17.32
- Version:
8.9.6
- Location:
/usr/loca/etc/drbd
/keepalived
/etc/exports
4.gitlab cluser config
- MASTER1234567891011121314151617181920# vi /etc/gitlab/gitlab.rb# Disable the built-in Postgrespostgresql['enable'] = false# Fill in the values for database.ymlgitlab_rails['db_adapter'] = "postgresql"gitlab_rails['db_encoding'] = "unicode"gitlab_rails['db_database'] = "gitlabhq_production"gitlab_rails['db_host'] = '10.100.17.25'gitlab_rails['db_port'] = '5432'gitlab_rails['db_username'] = 'gitlab'gitlab_rails['db_password'] = '123456'# Redis connection detailsredis['enable'] = falsegitlab_rails['redis_port'] = '6380'gitlab_rails['redis_host'] = '10.100.17.25'#gitlab_rails['redis_password'] = '123456'
- SLAVE123456789101112131415161718192021222324252627# vi /etc/gitlab/gitlab.rb# Disable the built-in Postgrespostgresql['enable'] = false# Fill in the values for database.ymlgitlab_rails['db_adapter'] = "postgresql"gitlab_rails['db_encoding'] = "unicode"gitlab_rails['db_database'] = "gitlabhq_production"gitlab_rails['db_host'] = '10.100.17.25'gitlab_rails['db_port'] = '5432'gitlab_rails['db_username'] = 'gitlab'gitlab_rails['db_password'] = '123456'# Redis connection detailsredis['enable'] = falsegitlab_rails['redis_port'] = '6380'gitlab_rails['redis_host'] = '10.100.17.25'#gitlab_rails['redis_password'] = '123456'gitlab_shell['secret_token'] = '4f008660152b2b649352ddf41f1d2d8098f98b1f5c23a0cb48a5ffbb3f065a9d8a11f8c7f70459f08a028d2048bab1ad3b370fcda732e315ed2b08a6ae707c87'gitlab_rails['otp_key_base'] = '89d90e3f7a9cc257f6ec8f88b78d0f072c5795154398387dbb5cbee90c1ccded855d8df03f1d5ea5b5dbec488f13bd02643b9c44c084331aa0184cf80a527f3d'gitlab_rails['secret_key_base'] = '370fb2996bbef6b13e11694f50d25b2cd2d3213697fe53afee5e6b154e364a9ab52f5f78a701903a858f975b6c51eb541f8d97bd0996813d30ab9ec0d0858fba'gitlab_rails['db_key_base'] = '7c58a519b10b167496364100f0cc12f188cd8823aaef915656626f29a7132defda3135c220fef449ae4d7dd3e49780de4b33dde77eda05855ef843a58467126d'
|
|
- COMMAND123sudo gitlab-ctl status/stop/restartsudo gitlab-ctl tail # view log
5.keepalived & DRBD config
MASTER
12345678910111213141516171819202122232425262728293031323334353637383940414243444546! Configuration File for keepalivedglobal_defs {notification_email {heyatao@imooc.com}notification_email_from op@imooc.comsmtp_server 127.0.0.1smtp_connect_timeout 30router_id nfs_drbd0vrrp_skip_check_adv_addrvrrp_strictvrrp_garp_interval 0vrrp_gna_interval 0}vrrp_script check_nfs {script "/keepalived/script/check_nfs.sh"interval 2weight -60}vrrp_instance nfs_drbd0 {state MASTERinterface eth1virtual_router_id 222priority 100advert_int 1authentication {auth_type PASSauth_pass Nfs_DrBd}track_script {check_nfs}virtual_ipaddress {10.100.17.9}notify_stop "/keepalived/script/nfs_stop.sh"notify_master "/keepalived/script/change_drbd_to_primary.sh"notify_backup "/keepalived/script/change_drbd_to_secondary.sh"}SLAVE
12345678910111213141516171819202122232425262728293031323334353637383940414243444546! Configuration File for keepalivedglobal_defs {notification_email {heyatao@imooc.com}notification_email_from op@imooc.comsmtp_server 127.0.0.1smtp_connect_timeout 30router_id nfs_drbd0vrrp_skip_check_adv_addrvrrp_strictvrrp_garp_interval 0vrrp_gna_interval 0}vrrp_script check_nfs {script "/keepalived/script/check_nfs.sh"interval 2weight -60}vrrp_instance nfs_drbd0 {state BACKUPinterface eth2virtual_router_id 222priority 50advert_int 1authentication {auth_type PASSauth_pass Nfs_DrBd}track_script {check_nfs}virtual_ipaddress {10.100.17.9}notify_stop "/keepalived/script/nfs_stop.sh"notify_master "/keepalived/script/change_drbd_to_primary.sh"notify_backup "/keepalived/script/change_drbd_to_secondary.sh"}
master priority > slave priority
one or more vip address,virtual_router_id should be different
NFS FAILOVER
123456789101112131415161718192021222324252627282930log_name='check_nfs'log_dir='/keepalived/log'nfs_flag="nfsd"VIP="10.100.17.9"flag_exists=$(ps -ef | grep "${nfs_flag}" | grep -v grep | wc -l)drbd_role=$(drbdsetup status |head -1 | awk -F':' '{print $2}')time=` date "+%F %H:%M:%S"`echo -e "----------${time} check nfs start ------------\n" >> ${log_dir}/${log_name}.logif [ "${flag_exists}" -eq 0 ];then# Try to reboot onceecho -e "----------${time} restart nfs ------------\n" >> ${log_dir}/${log_name}.log/sbin/service nfs restart &>> ${log_dir}/${log_name}.logflag_exists=$(ps -ef | grep "${nfs_flag}" | grep -v grep | wc -l)if [ "${flag_exists}" -eq 0 ];thenif [ "${drbd_role}" == "Primary" ];thenecho -e "----------${time} ${log_name} ------------\n" >> ${log_dir}/${log_name}.logcd /keepalived/script/ && bash change_drbd_to_secondary.sh &>> ${log_dir}/${log_name}.logcd /keepalived && bash load_keepalived.sh stop &>> ${log_dir}/${log_name}.logecho -e "----------The End--------------------------\n" >> ${log_dir}/${log_name}.logfififiecho -e "----------${time} check nfs end ------------\n" >> ${log_dir}/${log_name}.logCOMMAND
1234567drbdadm status drbd_disk0drbdadm up/down drbd_disk0drbdadm --force primary drbd_disk0service nfs restart/start/stopManual sovled split brain
drdbadm disconnect resource
drbdadm secondary resource
drbdadm connect --discard-my-data resource
On the other node (the split brain survivor), if its connection state is also StandAlone, you would enter:
drbdadm disconnect resource
drbdadm connect resource
6.NFS mount
Server
1/nfs_disk0 10.100.*(rw,no_root_squash)Client
110.100.17.9:/nfs_disk0/gitlab/git-data/repositories /var/opt/gitlab/git-data/repositories nfs4 defaults 0 0