Prepare a virtual machine: memory 3g cpu2
192.168.19.132
[root@localhost ~]# systemctl stop firewalld;setenforce 0
[root@localhost ~]# vim /etc/yum.repos.d/gitlab.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever
gpgcheck=0
enabled=1
[root@localhost ~]# yum install -y postfix curl policycoreutils-python openssh-server gitlab-ce
[root@localhost ~]# systemctl start sshd
[root@localhost ~]# systemctl start postfix
#配置gitlab登录链接
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
#添加对外的域名(gitlab.papamk.com请添加A记录指向本服务器的公网IP):将原来的修改为
external_url 'http://192.168.19.132'
#设置地区
gitlab_rails['time_zone'] = 'Asia/Shanghai'
#将数据路径的注释去掉,可以更改
git_data_dirs({
"default" => {
"path" => "/mnt/nfs-01/git-data"
}
})
#开启ssh服务
gitlab_rails['gitlab_shell_ssh_port'] = 22
#初始化Gitlab
[root@localhost ~]# gitlab-ctl reconfigure #重新加载,需要等很长时间
#启动Gitlab服务
[root@localhost ~]# gitlab-ctl restart
Visit 192.168.19.132 to test
Enter the password you want to set
Default account root
[External chain image transfer failed, the source site may have an anti-theft chain mechanism, it is recommended to save the image and upload it directly (img-PROaewGc-1585730761071) (https://upload-images.jianshu.io/upload_images/21294643- 196039a055c5d2b6.png? ImageMogr2 / auto-orient / strip% 7CimageView2 / 2 / w / 1240)]Login page, click Register to create an ordinary user
Log in with root to create a project
Create a key on the client
[root@localhost ~]# cd .ssh/ [root@localhost .ssh]# cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsfrz1U1+X96DVT0w79AzbHkHvsKZVEPyLJqtpHi4GOmoNcn7K8f8ILQKXJNJhDlz8BNJ2VOaqsxn2TnidVhMrtmZEXd25nT6wJP/puf73vCII/b6f9jk+dlRrkFXMxhz1+b8l9dxhX4Lo9RrbNWbnnCmOu7QoylHz/hwCZ1S11k7UmBwJ2xXv/xpYbH708q+OxutP9fKnN32S2Dtu6nemp6T9WQribLNrZf/l0gEhi9thVDKecC09v8ehS7O6Jdq/XyWJ9EJNxySlo0kRpOTIGCw/vyep+3QX5XFt0SXHvX9b9iqHA82iQIRtijphxdg19NUg29rT4vm2JZ8p7D31 [email protected]
View project information
(External chain image transfer failed, the source site may have an anti-theft chain mechanism, it is recommended to save the image and upload it directly (img-Dy82tG9K-1585730761072) (https://upload-images.jianshu.io/upload_images/21294643- d73bb873c7e27ae4.png? imageMogr2 / auto-orient / strip% 7CimageView2 / 2 / w / 1240)]Create file
[External chain image transfer failed, the source site may have an anti-theft chain mechanism, it is recommended to save the image and upload it directly (img-wUqJ2Z1Q-1585730761072) (https://upload-images.jianshu.io/upload_images/21294643-a1ef99a4874d265f .png? imageMogr2 / auto-orient / strip% 7CimageView2 / 2 / w / 1240)]
upload files
### Client operation clone to local:
[root@localhost ~]# git clone [email protected]:root/testapp.git
Cloning into 'testapp'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
[root@client ~]# ls
testapp
[root@client ~]# cd testapp/
[root@client testapp]# ls
test.txt
##### Using HTTP:
[root@client testapp]# cd
[root@localhost ~]# rm -rf testapp/
[root@localhost ~]# git clone http://192.168.19.132/root/testapp.git
正克隆到 'testapp'...
Username for 'http://192.168.19.132': root #root账户
Password for 'http://[email protected]': #root密码
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
[root@localhost ~]# ls
anaconda-ks.cfg testapp
[root@localhost ~]# cd testapp/
[root@localhost testapp]# ls
test.txt
##### Submit to the remote gitlab warehouse:
[root@localhost testapp]# vim date.txt
2020/03/26
[root@localhost testapp]# git add .
[root@localhost testapp]# git commit -m "date1"
[master 91cf03f] date1
1 file changed, 1 insertion(+)
create mode 100644 date.txt
[root@localhost testapp]# git push origin master
Username for 'http://192.168.19.132': root
Password for 'http://[email protected]':
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 265 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.19.132/root/testapp.git
2f415d3..91cf03f master -> master
##### Visit:
#####expand:
1.cat /proc/swaps 查看swap分区是否启动(无)
2.创建 :
dd if=/dev/zero of=/data/swap bs=512 count=8388616
创建swap大小为bs*count=4294971392(4G);
/data/swap目录若无则找/mnt/swap
3.通过mkswap命令将上述空间制作成swap分区:
mkswap /data/swap
4.查看内核参数vm.swappiness中的数值是否为0,如果为0则根据实际需要调 整成60:
查看: cat /proc/sys/vm/swappiness
设置: sysctl -w vm.swappiness=60 #内存到60%启用swap分区
若想永久修改,则编辑/etc/sysctl.conf文件,改文件中有vm.swappiness变量配置,默认为0
5.启用分区:
swapon /data/swap
echo “/data/swap swap swap defaults 0 0” >> /etc/fstab
6.再次使用cat /proc/swaps 查看swap分区是否启动