微服务部署

lishihuan大约 5 分钟

微服务部署

查询内存使用

free -h

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           7.6G        4.8G        886M         38M        1.9G        2.4G
Swap:          2.0G          0B        2.0G

CentOS 7 替换镜像源

参考open in new window

CentOS 7 的官方支持已经结束,部分仓库已被移至归档库

进入/etc/yum.repos.d目录下找到 CentOS-Base.repo

cd /etc/yum.repos.d

编辑 CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

然后wq保存下,依次执行:

sudo yum clean all 
sudo yum makecache

如果yum 安装软件 失败或者提示版本冲突

#修改服务器的DNS为阿里云的公共DNS服务器
echo "nameserver=223.5.5.5" >/etc/resolv.conf
#备份Base及epel源文件
mv /etc/yum.repos.d/CentOS-Base.repo{,.bak}
mv /etc/yum.repos.d/epel.repo{,.bak}
#获取阿里云的源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
#更新缓存
yum makecache
#安装软件
yum -y install gcc zlib zlib-devel pcre pcre-devel openssl openssl-devel automake autoconf libtool make

安装虚拟机

CentOS安装

安装oracle

安装oracle

安装java环境

Linux 下安装java

MySQL安装

MySql卸载和安装

如果数据库名称有特殊字符,则使用反引号 例如: yjydxj-config

CREATE DATABASE IF NOT EXISTS mydatabase
    CHARACTER SET utf8mb4
    COLLATE utf8mb4_general_ci;
systemctl status mysqld ## 检查开机启动情况,确定是否正常启动

systemctl start mysqld # 启动
systemctl restart mysqld;
systemctl stop mysqld; ## 关闭
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Semdo@2021';
lower_case_table_names=1 ## 忽略大小写
# 解决 ONLY_FULL_GROUP_BY 问题
sql_mode =STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

navicat

docker安装

docker

systemctl start docker # 启动
sudo systemctl stop docker # 关闭

RabbitMQ

http://192.168.74.131:15672open in new window

docker start rabbitmq
# 检查是否启动
docker ps -a

## 启动docker
systemctl start docker

nacos

http://192.168.75.129:8848/nacos/index.htmlopen in new window

sys /123456

数据库连接如果失败添加: useSSL=false

cd /home/yjwyy/nacos/bin
sh startup.sh -m standalone

# 或者
sh /home/yjwyy/nacos/bin/startup.sh -m standalone

redis

Linux下安装redis

# 关闭
pkill redis

/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf  ## 前台启动

nginx

Nginx

# 启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 

cd /usr/local/nginx/sbin/     #进入nginx安装目录nginx 所在位置
./nginx  # 启动
./nginx -s stop  # 停止
./nginx -s quit  # 安全退出
kill -9 # 进程号
./nginx -s reload  #重新加载配置文件
ps aux|grep nginx  # 查看nginx进程

禅道

如果启动不成功,可能是/opt/zbox/tmp/apache/httpd.pid 中的 pid被占用,只要删除 httpd.pid 文件即可

http://192.168.75.129:8080/zentaoopen in new window admin/semdo@2022

https://www.cnblogs.com/shireenlee4testing/p/9044150.htmlopen in new window

https://blog.csdn.net/wanyanwanyan_/article/details/131246667open in new window

https://blog.csdn.net/wyz0516071128/article/details/116447957open in new window

https://blog.csdn.net/loveweitaming/article/details/89372972open in new window 连接数据库

tar -zxvf zbox.tar.gz -C /opt
## 启动命令
/opt/zbox/zbox start 
/opt/zbox/zbox stop
/opt/zbox/zbox restart 

数据库管理界面:http://192.168.1.130:8080/open in new window 点击 数据库管理

登录: 需要先登录 admin/semdo@2022

/opt/zbox/app/zentao/config/my.php

是一个 PHP 的配置文件,其中包含了禅道系统的一些配置信息。具体来说:

  • 第一行 $config->installed = true; 表示该禅道系统已经安装完成。
  • 第二行 $config->debug = false; 表示禅道系统的调试模式已关闭。如果需要调试,可以将其改为 true。
  • 第三行 $config->requestType = 'PATH_INFO'; 表示禅道系统使用的请求类型是 PATH_INFO,即 URL 后面会带上一个路径参数来表示具体的请求内容。
  • 第四行 $config->db->host = '127.0.0.1'; 表示数据库的主机地址是 127.0.0.1,即本机。
  • 第五行 $config->db->port = '3309'; 表示数据库的端口号是 3309。
  • 第六行 $config->db->user = 'root'; 表示连接数据库时使用的用户名是 root。
  • 第七行 $config->db->prefix = 'zt_'; 表示数据库表名的前缀是 zt_。
  • 第八行 $config->webRoot = getWebRoot(); 表示禅道系统的根目录。getWebRoot() 是一个函数,用于获取当前网站的根目录。
  • 第九行 $config->db->name = 'zentao'; 表示连接的数据库名称是 zentao。
  • 第十行 $config->db->password = '123456'; 表示连接数据库时使用的密码是 123456。
  • 第十一行 $config->default->lang = 'zh-cn'; 表示禅道系统的默认语言是中文。
image-20231030165429187
image-20231030165429187

数据库:root/root @ zentao

支持远程连接

https://blog.csdn.net/haveqing/article/details/142492664open in new window

1、创建'root'@'%'用户,并授权

cd /opt/zbox/run/mysql/
./mysql -u root
./mysql -u root -p #默认密码123456
 
MariaDB [(none)]> use mysql
MariaDB [mysql]> select user,authentication_string,host from user;
MariaDB [mysql]> update user set host = '%' where user = 'root';
ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
MariaDB [mysql]> CREATE USER 'root'@'%' IDENTIFIED BY '123456';
MariaDB [mysql]> select user,authentication_string,host from user;
MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' with grant option;

2、打开防火墙端口3306

firewall-cmd --permanent --zone=public --add-port=3306/tcp

firewall-cmd --reload

CentOS 7 防火墙配置,添加规则,删除规则,查看规则_centos7删除防火墙规则

3、my.cnf修改mysql绑定的IP

/opt/zbox/etc/mysql/my.cnf

注释掉

#bind-address            = 127.0.0.1
或改为
bind-address            = 0.0.0.0

4、重启禅道服务

/opt/zbox/zbox restart
/opt/zbox/zbox stop
/opt/zbox/zbox start

测试是否能连接上mysql

	public static void main(String[] args) {
		String jdbcUrl = "jdbc:mysql://192.168.75.129:3306/yjydxj-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&allowMultiQueries=true";
		String username = "root";
		String password = "root";

		try {
			// 加载MySQL JDBC驱动
			Class.forName("com.mysql.jdbc.Driver"); // com.mysql.cj.jdbc.Driver
			// 建立数据库连接
			Connection connection = DriverManager.getConnection(jdbcUrl, username, password);
			System.out.println("成功连接到数据库!");
			connection.close();
		} catch (Exception e) {
			System.err.println("连接数据库时发生异常:" + e.getMessage());
		}
	}