云原生

20230115-Gogs入门到实践

2023-01-15  本文已影响0人  負笈在线

1.Git安装

git安装
# dnf install -y git

2.数据库安装(MySQL8)

依赖包安装

# dnf -y install wget  cmake gcc gcc-c++ ncurses  ncurses-devel  libaio-devel  openssl openssl-devel perl

创建mysql用户

# groupadd mysql
# useradd mysql -d /var/lib/mysql/ -g mysql
# tail -1  /etc/passwd
mysql:x:1000:1000::/var/lib/mysql/:/bin/bash

获取mysql-8.0.31安装包

# wget -c https://dev.mysql.com/get/mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar
# tar -xvf mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar

安装mysql

# rpm -ivh mysql-community-common-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-client-plugins-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-libs-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-client-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-icu-data-files-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-server-8.0.31-1.el8.x86_64.rpm 

初始化mysql数据库

# mysqld --initialize --console

查看数据库初始化密码

# cat /var/log/mysqld.log  | grep localhost
2023-01-13T19:01:34.497431Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: yl)TpkEQj9B6

启动mysql服务

# chmod 777 /var/lib/mysql/auto.cnf
# chown -R mysql:mysql /var/lib/mysql/
# systemctl start mysqld
# systemctl status mysqld
# systemctl enable mysqld

确认数据库版本

# mysqladmin --version
mysqladmin  Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)

确认mysql版本

# mysqladmin --version
mysqladmin  Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)

修改mysql数据库root密码

# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> 

开启开启mysql的远程访问

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> 

3.安装Gogs服务

创建git用户

# groupadd git
# useradd git -d /home/git/ -g git
# tail -1  /etc/passwd
git:x:1001:1001::/home/git/:/bin/bash

下载Gogs安装程序

# wget https://dl.gogs.io/0.12.9/gogs_0.12.9_linux_amd64.tar.gz
# tar xvf gogs_0.12.9_linux_amd64.tar.gz
# ll gogs
total 44560
-rwxrwxr-x 1 mysql mysql 45608848 Jun  8  2022 gogs
-rw-rw-r-- 1 mysql mysql     1054 Jun  8  2022 LICENSE
-rw-rw-r-- 1 mysql mysql     7021 Jun  8  2022 README.md
-rw-rw-r-- 1 mysql mysql     5372 Jun  8  2022 README_ZH.md
drwxrwxr-x 7 mysql mysql      112 Jun  8  2022 scripts

创建gogs数据库并导入数据

# cd gogs/
# mysql -uroot -p < scripts/mysql.sql
Enter password: 

确认gogs数据库

# mysql -uroot -p
Enter password: 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| gogs               |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)
mysql> use gogs;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> exit

创建git用户

# groupadd git
# useradd git -d /home/git/ -g git
# tail -1  /etc/passwd
git:x:1001:1001::/home/git/:/bin/bash

将gogs安装包所有者改为git

# chown -R git:git ~/gogs
# mv ~/gogs /home/git/

配置gogs自启动文件

# cp /home/git/gogs/scripts/systemd/gogs.service /lib/systemd/system/
# systemctl start gogs
# systemctl enable gogs
# systemctl status gogs

4.首次登录Gogs,并配置

首次登录Gogs:http://172.26.37.127:3000/ ,并配置

1)配置数据库信息



2)配置应用基本设置



3)配置可选设置

4)配置管理员用户

5)确认配置文件

# cat /home/git/gogs/custom/conf/app.ini

6)登录gogs

5.在Gogs中创建项目并利用

1)创建CMDB仓库



2)first commit

$ git clone http://172.26.37.127:3000/luorf/CMDB.git
$ touch README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin http://172.26.37.127:3000/luorf/CMDB.git
$ git push -u origin master

参考URL

https://gpu.xuandashi.com/31361.html
https://dev.mysql.com/downloads/mysql/
https://www.jianshu.com/p/c25fba32b4f0
https://dev.mysql.com/doc/refman/8.0/en/server-option-variable-reference.html
https://blog.csdn.net/u013618714/article/details/126179117
https://gogs.io/
https://dl.gogs.io/
https://gogs.io/docs
https://blog.51cto.com/u_8406447/5769472

上一篇下一篇

猜你喜欢

热点阅读