gogs的安装配置

最近的工作之一,搭建持续集成平台jenkins,主要是为开发人员提供一个持续集成测试和发布的平台,jenkins平台的功能强大,拥有1800+的插件,chinese汉化插件,gitlab和gogs代码管理平台插件,cppcheck代码静态扫描插件等,jenkins平台的配置实用不在此介绍了。为什么单独介绍gogs的安装配置,是因为我用的是CentOS 7.2,在配置jenkins+gogs的环境的时候,用自带的mariadb数据库无法安装gogs,会出现column的大小超过了767 bytes,想办法设置相关的变量,还是不能成功,索性弃用mariadb,直接上MySQL,后续再研究column长度的问题。

Index column size too large. The maximum column size is 767 bytes.

MySQL有商业版和社区版本,下载社区版本,我选择了8.0版本的MySQL,MySQL下载地址为https://dev.mysql.com/downloads/mysql/,我的测试机是CentOS7.2,选择redhat版本,下载的包有mysql-community-client-8.0.23-1.el7.x86_64.rpm、mysql-community-common-8.0.23-1.el7.x86_64.rpm、mysql-community-server-8.0.23-1.el7.x86_64.rpm、mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm和mysql-community-libs-8.0.23-1.el7.x86_64.rpm

mkdir MySQL8.0
mv mysql-community-client-8.0.23-1.el7.x86_64.rpm \
mysql-community-common-8.0.23-1.el7.x86_64.rpm \
mysql-community-server-8.0.23-1.el7.x86_64.rpm \
mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm \
mysql-community-libs-8.0.23-1.el7.x86_64.rpm MySQL8.0
cd MySQL8.0 && yum install ./* -y
systemctl start mysqld && systemctl enable mysqld

这时候用mysql命令打开数据库会出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO),这是因为mysql8需要root账号密码登录,第一次安装并没有设置密码,这里不能用度娘出来的那些在/etc/my.cnf中添加skip-grant-tables参数,正确的方式是打开/var/log/mysqld.log获取安装过程中产生的随机密码

mysql -uroot 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 
vi /var/log/mysqld.log 
2021-02-04T02:58:06.246120Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 2243 
2021-02-04T02:58:06.264256Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 
2021-02-04T02:58:08.069739Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 
2021-02-04T02:58:11.092716Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: dopIw#uuW1hO 
mysql -uroot -p'dopIw#uuW1hO' 
mysql>create user 'root'@'%' identified by 'password'; 
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql5.7之后的版本就有较为严格的密码设置策略了,使用第一次随机产生的密码并不能进行太多的操作,需要修改密码,新密码的设置策略如下,所以可以先按照安全要求设置一个复杂的密码,因为是测试环境,在此选择关闭密码安全设置,设置简单密码,生产环境不建议这样操作

mysql> alter user root@localhost identified by 'password';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> show variables like 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
validate_password.dictionary_file //插件用于验证密码强度的字典文件路径
validate_password.length //最短密码长度
validate_password.mixed_case_count //密码最少要包含大小写字符的个数
validate_password.number_count //密码最少要包含的数字字符个数
validate_password.policy //密码强度检查,0/LOW只检查长度,1/MEDIUM检查大小写,各种字符长度,2/STRONG校验字典文件
validate_password.special_char_count //特殊字符最少个数
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user root@localhost identified by 'easy-password';
Query OK, 0 rows affected (0.04 sec)
mysql> create user 'root'@'%' identified by 'easy-password';
Query OK, 0 rows affected (0.08 sec)

搞定MySQL数据库相关的问题,下面正式进入gogs的安装,首先创建一个gogs账号

mysql> create user 'root'@'%' identified by '123456!a';
Query OK, 0 rows affected (0.08 sec)

mysql> create user 'gogs'@'%' identified by '123456!a';
Query OK, 0 rows affected (0.28 sec)

mysql> grant all privileges on gogs.* to 'gogs'@'%';
Query OK, 0 rows affected (0.06 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)

为gogs创建一个名为git的用户,下载gogs的安装包gogs_0.12.3_linux_amd64.tar.gz,导入scripts目录下的mysql.sql脚本,再运行./gogs web,根据输出信息用浏览器连接3000端口,进行配置。

useradd git && passwd git
cp gogs_0.12.3_linux_amd64.tar.gz /home/git/
su - git
tar -zxvf gogs_0.12.3_linux_amd64.tar.gz
mysql -uroot -p'password' < /home/git/gogs/scripts/mysql.sql
/home/git/gogs/gogs web
2021/02/04 02:27:21 [ WARN] Custom config "/home/git/gogs/custom/conf/app.ini" not found. Ignore this warning if you're running for the first time
2021/02/04 02:27:21 [TRACE] Log mode: Console (Trace)
2021/02/04 02:27:21 [ INFO] Gogs 0.12.3
2021/02/04 02:27:21 [TRACE] Work directory: /home/git/gogs
2021/02/04 02:27:21 [TRACE] Custom path: /home/git/gogs/custom
2021/02/04 02:27:21 [TRACE] Custom config: /home/git/gogs/custom/conf/app.ini
2021/02/04 02:27:21 [TRACE] Log path: /home/git/gogs/log
2021/02/04 02:27:21 [TRACE] Build time: 2020-10-07 03:03:48 UTC
2021/02/04 02:27:21 [TRACE] Build commit: f0e3cd90f8d7695960eeef2e4e54b2e717302f6c
2021/02/04 02:27:21 [ INFO] Run mode: Development
2021/02/04 02:27:22 [ INFO] Listen on http://0.0.0.0:3000

因为对贴图还不是很熟悉,也觉得很麻烦,不重要的图就不贴了,在web页面上正确填写好数据库登录的相关信息,其他默认即可。

这个时候gogs的服务是刚刚./gogs web终端开启的,关闭之后服务就关闭了,这时候复制安装包下的服务脚本导/etc/init.d/目录下,启动服务即可。

cp /home/git/gogs/scripts/init/centos/gogs /etc/init.d/
chmod a+x /etc/init.d/gogs
chkconfig --add gogs
/etc/init.d/gogs start
'● gogs.service - LSB: Start gogs at boot time.
   Loaded: loaded (/etc/rc.d/init.d/gogs)
   Active: active (running) since Thu 2021-02-04 20:59:52 EST; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 13064 ExecStart=/etc/rc.d/init.d/gogs start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/gogs.service
           └─13070 /home/git/gogs/gogs web

Feb 04 20:59:52 localhost.localdomain systemd[1]: Starting LSB: Start gogs at boot time....
Feb 04 20:59:52 localhost.localdomain runuser[13068]: pam_unix(runuser:session): session opened for user git by (uid=0)
Feb 04 20:59:52 localhost.localdomain runuser[13068]: pam_unix(runuser:session): session closed for user git
Feb 04 20:59:52 localhost.localdomain gogs[13064]: Starting Gogs: [  OK  ]
Feb 04 20:59:52 localhost.localdomain systemd[1]: Started LSB: Start gogs at boot time..

这里有一句口头禅想脱口而出,gogs已经安装成功了,可是页面却跳出来一个大大的404符号,提示有问题请连接github查看,要不是有注册登录的选项,都以为自己安装失败了,给作者的幽默点个赞,不过第一时间还是心里骂了一句,哈哈。

一个mariadb折磨了我好几天,难受哇,前路漫漫,希望本篇博文对于你有所帮助,有问题可以邮件联系我。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇