腾讯轻量云主机,Docker容器部署Chemex IT资产管理系统
系统简介
☕咖啡壶(Chemex)是一个免费、开源、高效且漂亮的运维资产管理平台。软硬件资产管理、归属/使用者追溯、盘点以及可靠的服务器状态管理面板。基于优雅的Laravel框架和DcatAdmin开发
前期准备工作,云主机安装操作系统
环境:CentOS Linux release 7.6.1810 (Core),Mysql-5.7.38
一、安装操作系统
1.1重置系统密码
安装系统后先重置下密码
1.2使用终端工具连接系统
使用XSHELL或其它终端连接工具,连接腾讯云主机,查看系统信息
二、准备Mysql安装包
一、下载Mysql安装包至目录mysql_download
2.1、下载Mysql安装包
1、新建目录:
mkdir mysql_download
2、切换到mysql_download目录:
cd mysql_download
3、下载Mysql安装包
清华大学开源软件镜像站源下载
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar --no-check-certificate
#--no-check-certificate 不认证网站证书,不加这个下载不下来
官方链接下载
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
2个下载地址2选一,都可以,清华大学的下载速度快一点
2.2、解压安装包
新建一个mysql文件夹,将安装文件解压到mysql目录下
mkdir mysql
解压到mysql目录
tar -xvf mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar -C ./mysql
2.3、查看解压后的文件
进入mysql目录,查看解压后的文件对不对
切换到mysql目录
cd mysql
三、安装设置Mysql
3.1安装mysql
在mysql目录下执行下列命令进行安装
sudo yum install mysql-community-{server,client,common,libs}-*
# 执行过程
[root@VM-12-12-centos mysql]# sudo yum install mysql-community-{server,client,common,libs}-*
Loaded plugins: fastestmirror, langpacks
Examining mysql-community-server-5.7.38-1.el7.x86_64.rpm: mysql-community-server-5.7.38-1.el7.x86_64
Marking mysql-community-server-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-client-5.7.38-1.el7.x86_64.rpm: mysql-community-client-5.7.38-1.el7.x86_64
Marking mysql-community-client-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-common-5.7.38-1.el7.x86_64.rpm: mysql-community-common-5.7.38-1.el7.x86_64
Marking mysql-community-common-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-libs-5.7.38-1.el7.x86_64.rpm: mysql-community-libs-5.7.38-1.el7.x86_64
Marking mysql-community-libs-5.7.38-1.el7.x86_64.rpm to be installed
Examining mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm: mysql-community-libs-compat-5.7.38-1.el7.x86_64
Marking mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.65-1.el7 will be obsoleted
---> Package mysql-community-client.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-common.x86_64 0:5.7.38-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:5.7.38-1.el7 will be obsoleting
---> Package mysql-community-libs-compat.x86_64 0:5.7.38-1.el7 will be obsoleting
---> Package mysql-community-server.x86_64 0:5.7.38-1.el7 will be installed
--> Finished Dependency Resolution
docker-ce-stable/7/x86_64 | 3.5 kB 00:00:00
docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
docker-ce-stable/7/x86_64/primary_db | 80 kB 00:00:00
epel/7/x86_64 | 4.7 kB 00:00:00
epel/7/x86_64/group_gz | 97 kB 00:00:00
epel/7/x86_64/updateinfo | 1.1 MB 00:00:00
epel/7/x86_64/primary_db | 7.0 MB 00:00:00
extras/7/x86_64 | 2.9 kB 00:00:00
extras/7/x86_64/primary_db | 247 kB 00:00:00
os/7/x86_64 | 3.6 kB 00:00:00
os/7/x86_64/group_gz | 153 kB 00:00:00
os/7/x86_64/primary_db | 6.1 MB 00:00:00
updates/7/x86_64 | 2.9 kB 00:00:00
updates/7/x86_64/primary_db | 17 MB 00:00:00
Dependencies Resolved
================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
mysql-community-client x86_64 5.7.38-1.el7 /mysql-community-client-5.7.38-1.el7.x86_64 106 M
mysql-community-common x86_64 5.7.38-1.el7 /mysql-community-common-5.7.38-1.el7.x86_64 2.8 M
mysql-community-libs x86_64 5.7.38-1.el7 /mysql-community-libs-5.7.38-1.el7.x86_64 9.9 M
replacing mariadb-libs.x86_64 1:5.5.65-1.el7
mysql-community-libs-compat x86_64 5.7.38-1.el7 /mysql-community-libs-compat-5.7.38-1.el7.x86_64 6.0 M
replacing mariadb-libs.x86_64 1:5.5.65-1.el7
mysql-community-server x86_64 5.7.38-1.el7 /mysql-community-server-5.7.38-1.el7.x86_64 771 M
Transaction Summary
================================================================================================================================================
Install 5 Packages
Total size: 896 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
rdma-core-devel-51mlnx1-1.51066.x86_64 has missing requires of ibacm(x86-64) = ('0', '51mlnx1', '1.51066')
Installing : mysql-community-common-5.7.38-1.el7.x86_64 1/6
Installing : mysql-community-libs-5.7.38-1.el7.x86_64 2/6
Installing : mysql-community-client-5.7.38-1.el7.x86_64 3/6
Installing : mysql-community-server-5.7.38-1.el7.x86_64 4/6
Installing : mysql-community-libs-compat-5.7.38-1.el7.x86_64 5/6
Erasing : 1:mariadb-libs-5.5.65-1.el7.x86_64 6/6
Verifying : mysql-community-libs-compat-5.7.38-1.el7.x86_64 1/6
Verifying : mysql-community-server-5.7.38-1.el7.x86_64 2/6
Verifying : mysql-community-client-5.7.38-1.el7.x86_64 3/6
Verifying : mysql-community-common-5.7.38-1.el7.x86_64 4/6
Verifying : mysql-community-libs-5.7.38-1.el7.x86_64 5/6
Verifying : 1:mariadb-libs-5.5.65-1.el7.x86_64 6/6
Installed:
mysql-community-client.x86_64 0:5.7.38-1.el7 mysql-community-common.x86_64 0:5.7.38-1.el7 mysql-community-libs.x86_64 0:5.7.38-1.el7
mysql-community-libs-compat.x86_64 0:5.7.38-1.el7 mysql-community-server.x86_64 0:5.7.38-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.65-1.el7
Complete!
[root@VM-12-12-centos mysql]#
启动MySQL:
service mysqld start
重启MySQL:
service mysqld restart
停止MySQL:
service mysqld stop
查看MySQL状态:
service mysqld status
3.2 安装完毕后之后的设置
启动MySQL:
service mysqld start
查看MySQL状态:
service mysqld status
查看root的临时密码并登陆
sudo grep 'temporary password' /var/log/mysqld.log #查看密码
mysql -uroot -p #登录数据库
以下操作可以不做,使用默认规则也可以
登录数据库后
更改mysql密码策略级别为低,这样就可以设置简单密码了
set global validate_password_policy=LOW;
设置密码有效长度 4 位及以上,默认长度为最短8位数
set global validate_password_length=4;
修改root用户密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'chemex';
创建数据库,库名:chemex,一定要是chemex这个库名,不能用其他的
create database chemex;
退出mysql,操作完数据库后记得退出
exit
可选步骤
新建用户
CREATE USER 'chemex'@'%' IDENTIFIED BY 'chemex'; #创建用户chemex,设置密码为chemex,用户名跟密码请自定义,不想折腾的直接用root用户连接也行
用户授权
GRANT ALL PRIVILEGES ON *.* TO 'chemex'@'%' IDENTIFIED BY 'chemex' WITH GRANT OPTION;
命令解释:
GRANT:赋权命令
ALL PRIVILEGES:当前用户的所有权限
ON:介词
*.*:当前用户对所有数据库和表的相应操作权限
TO:介词
'chemex'@'%':权限赋给chemex用户,所有ip都能连接
IDENTIFIED BY 'chemex':连接时输入密码,密码为chemex
WITH GRANT OPTION:允许级联赋权
四、部署Chemex
4.1 拉取docker镜像
Docker 部署方式不会建立数据库容器,也意味着你必须有一个已有的数据库,在启动 chemex 时候通过参数注入的方式连接数据库。
1、拉取chemex镜像
docker pull celaraze/chemex:latest
2、查看镜像
docker images
4.2 启动容器
启动Docker容器
docker run -itd --restart=always -p 80:80 \
-e DB_HOST=数据库地址 \
-e DB_PORT=数据库端口 \
-e DB_DATABASE=数据库名称 \
-e DB_USERNAME=数据库账户 \
-e DB_PASSWORD=数据库密码 \
-e INSTALL=true \
celaraze/chemex
直接复制第2条的命令去启动容器即可
1、如果数据库连接地址设置为本地地址,则容器网络模式要设置为host模式:--net=host,命令如下:
docker run -itd --restart=always --net=host \
-e DB_HOST=127.0.0.1 \
-e DB_PORT=3306 \
-e DB_DATABASE=chemex \
-e DB_USERNAME=chemex \
-e DB_PASSWORD=chemex \
-e INSTALL=true \
celaraze/chemex
2、如果数据库连接地址设置为腾讯云主机公网IP地址,则不需要改变容器网络模式,命令如下:
记得填入ip地址
docker run -itd --restart=always -p 80:80 \
-e DB_HOST=云主机公网IP \
-e DB_PORT=3306 \
-e DB_DATABASE=chemex \
-e DB_USERNAME=chemex \
-e DB_PASSWORD=chemex \
-e INSTALL=true \
celaraze/chemex
五、登录系统
在任意一台可以访问外网的电脑上,通过 http://腾讯云公网ip,即可 访问 chemex。,例如http://1.10.10.1
用户名与密码默认为admin
六、相关链接
项目Github地址:https://github.com/celaraze/chemex
官方说明文档:https://chemex-docs.celaraze.com/
清华大学开源软件镜像站下载mysql地址:https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/
Mysql官方下载地址: https://downloads.mysql.com/archives/community/
MYSQL官方页面,可以下载完后上传安装包到云主机,进行安装
配完公网IP打开是Welcome to nginx!界面