vi /etc/nginx/conf.d/default.conf
stream {
upstream web{
server 192.168.187.10:80 up;
server 192.168.187.11:80 up;
}
server {
listen 80;
proxy_connect_timeout 5s;
proxy_timeout 300s;
proxy_pass web;
}
upstream ide{
server 192.168.187.10:5000 up;
server 192.168.187.11:5000 up;
}
server {
listen 5000;
proxy_connect_timeout 5s;
proxy_timeout 300s;
proxy_pass ide;
}
}
systemctl restart nginx
systemctl enable nginx
systemctl status nginx
tar xf keepalived.tar.gz
rpm -Uvh keepalived/*.rpm --nodeps --force
vim /etc/keepalived/keepalived.conf (记得改成自己的ip 192.168.187.10)
! Configuration File for keepalived
global_defs { //主要是配置故障发生时的通知对象以及机器标识
router_id db01 //标识本节点的字符串, 通常为hostname
}
vrrp_instance VI_1 {
//VRRP 实例state MASTER // MASTER 或BACKUP
state MASTER //表示主服务器
interface ens33 //节点固有IP(非VIP)的网卡,用来发VRRP包
virtual_router_id 51 //虚拟路由器的ID号,每一个keep组都不同,同组一致
priority 100 //优先级,数值越大优先级越高
advert_int 1// MASTER 与BACKUP 负载均衡器之间>同步检查的时间间隔,单位为秒。
advert_int 1 // MASTER 与BACKUP 负载均衡器之间同步检查的时间间隔,单位为秒。
authentication { //认证信息
auth_type PASS //认证类型
auth_pass 1111 //密码字串
}
virtual_ipaddress {
//虚拟ip 地址,可以有多个地址,每个地址占一行,不需要子网掩码
192.168.187.16
}
}
virtual_server 192.168.187.16 80 {
delay_loop 6 //健康检查间隔,单位为秒
persistence_timeout 50 // 会话保持时间,就是把用户请求转发给同一个服务器
protocol TCP //转发协议,有TCP 和UDP 两种,一般用TCP
real_server 192.168.187.8 80 {
notify_down /etc/keepalived/kill_keepalived.sh
TCP_CHECK { //通过tcpcheck 判断RealServer 的健康状态
connect_timeout 3 //连接超时时间
nb_get_retry 3 //重连次数
connect_port 80 //连接接口
delay_before_retry 3 //重连间隔时间
}
}
}
:wq
systemctl start keepalived
ip a |grep 192.168.187.16
vi /etc/nginx/conf.d/default.conf
server {
listen 5000;
root /usr/share/nginx/html/ide;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /amis {
proxy_read_timeout 300;
proxy_pass http://cm-ide-server-service;
client_max_body_size 0;
}
}
vim /etc/nginx/conf.d/ip_vs.conf
upstream cm-mgmt-server-service {
ip_hash;
server 192.168.187.13:9999 weight=1;
server 192.168.187.12:9999 weight=1;
}
vim /etc/nginx/conf.d/ide.conf
upstream cm-ide-server-service {
ip_hash;
server 192.168.187.13:13000 weight=1;
server 192.168.187.12:13000 weight=1;
}
systemctl restart nginx
systemctl enable nginx
systemctl status nginx
vim mgmt-server/mgmt-server/configs/config.yml
db:
host: 192.168.187.17 //MySQL虚拟ip
port: 3306 //端口
database: chainmaker //可以使用的数据库
user: chainmaker //数据库用户
passwd: a123456 //密码
chmod +x mgmt-server/mgmt-server/bin/startup.sh
sh mgmt-server/mgmt-server/bin/startup.sh
ps -ef | grep mgmt
vim /etc/profile
source /etc/profile
mvn clean package -DskipTests -Dgitinfo.skip=true
cp target/cp cm-ide-server-1.0.tar.gz /usr/local/
tar xf /usr/local/cm-ide-server-1.0.tar.gz
sh /usr/local/cm-ide-server-1.0/bin/app.sh
mvn clean package -DskipTests
cp target/cm-api-1.0.tar.gz /usr/local/
tar xf cm-api-1.0.tar.gz
sh cm-api-1.0/bin/app.sh
sh setup4.sh
vim /etc/my.cnf
[mysqld]
port=3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
disable-partition-engine-check=1
#只能用IP地址检查客户端的登录,不用主机名
skip_name_resolve=1
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
#设置client连接mysql时的字符集,防止乱码
init_connect=‘SET NAMES utf8mb4’
#是否对sql语句大小写敏感,1表示不敏感
lower_case_table_names=1
#最大连接数
max_connections=400
##最大错误连接数
max_connect_errors=1000
max_allowed_packet=200M
#MySQL连接闲置超过一定时间后(单位:秒)将会被强行关闭
#MySQL默认的wait_timeout值为8个小时, interactive_timeout参数需要同时配置才能生效
interactive_timeout=1800
wait_timeout=1800
#mysql binlog日志文件保存的过期时间,过期后自动删除
expire_logs_days=5
############################主从复制 设置########################################
#开启mysql binlog功能
log-bin=mysql-bin
#binlog记录内容的方式,记录被操作的每一行
#binlog_format = ROW
##作为从库时生效,想进行级联复制,则需要此参数
log_slave_updates = on
#作为从库时生效,中继日志relay-log可以自我修复
#relay_log_recovery = 1
server-id=1
#任意自然数n,只要保证两台MySQL主机不重复就可以
auto_increment_increment=2
#步进值auto_imcrement。一般有n台主MySQL就填n
auto_increment_offset=1
#起始值。一般填第n台主MySQL。此时为第一台主MySQL
systemctl restart mysqld
systemctl enable mysqld
grep password /var/log/mysqld.log
mysql -uroot -p 输入上面的临时密码
SET GLOBAL validate_password_policy=0;
SET GLOBAL validate_password_length=4;
ALTER USER user() IDENTIFIED BY ‘a123456’;
grant replication slave on . to ‘root’@‘192.168.187.%’ identified by ‘a123456’;
FLUSH PRIVILEGES;
quit
systemctl restart mysqld
mysql -uroot -pa123456
show master status;
change master to master_host=‘192.168.187.14’,master_user=‘root’,master_password=‘a123456’,master_log_file=‘mysql-bin.000003’,master_log_pos=154;
start slave;
show slave status\G;
reset slave;
CREATE DATABASE IF NOT EXISTS chainmaker DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
##修改字符集为utf8mb4,它utf8的超集并完全兼容utf8,能够用四个字节存储更多的字符。utf8mb4_unicode_ci是基于标准的Unicode来排序和比较,能够在各种语言之间精确排序
CREATE USER ‘chainmaker’@‘%’ IDENTIFIED BY ‘a123456’;
GRANT ALL ON chainmaker.* TO ‘chainmaker’@‘%’;
vim /etc/keepalived/keepalived.conf (记得改成自己的ip 192.168.187.14)
! Configuration File for keepalived
global_defs { //主要是配置故障发生时的通知对象以及机器标识
router_id db01 //标识本节点的字符串, 通常为hostname
}
vrrp_instance VI_2 {
//VRRP 实例state MASTER // MASTER 或BACKUP,为了防止脑裂现象,主备均需要设置为backup 模式,master 模式会抢占VIP
state BACKUP
interface ens33 //节点固有IP(非VIP)的网卡,用来发VRRP包
virtual_router_id 52 //取值在0-255 之间,用来区分多个instance的VRRP组
priority 100 //优先级,同一个vrrp_instance 的MASTER优先级必须比BACKUP 高
nopreempt //非抢占,配合backup,防止切换后,主库服务恢复正常后,IP 漂移过来
advert_int 1// MASTER 与BACKUP 负载均衡器之间>同步检查的时间间隔,单位为秒。
advert_int 1 // MASTER 与BACKUP 负载均衡器之间同步检查的时间间隔,单位为秒。
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
//虚拟ip 地址,可以有多个地址,每个地址占一行,不需要子网掩码
192.168.187.17
}
}
virtual_server 192.168.187.17 3306 {
delay_loop 6 //健康检查间隔,单位为秒
persistence_timeout 50 // 会话保持时间,就是把用户请求转发给同一个服务器
protocol TCP //转发协议,有TCP 和UDP 两种,一般用TCP
real_server 192.168.187.14 3306 {
notify_down /etc/keepalived/kill_keepalived.sh
TCP_CHECK { //通过tcpcheck 判断RealServer 的健康状态
connect_timeout 3 //连接超时时间
nb_get_retry 3 //重连次数
connect_port 3306 //连接接口
delay_before_retry 3 //检测端口
}
}
}
:wq
vim /etc/keepalived/kill_keepalived.sh
#!/bin/bash
systemctl stop keepalived
echo -e “$(ip a |grep ens32 |grep inet |awk ‘{print $2}’|awk -F’/’ ‘{print $1}’) (httpd) is down on $(date +%F-%T)” >>/root/check_httpd.log
:wq
chmod 755 /etc/keepalived/kill_keepalived.sh
systemctl start keepalived
ip a |grep 192.168.187.17
sh setup5.sh
mkdir -p /etc/docker
vi daemon.json
{
“registry-mirrors”: [“https://v16stybc.mirror.aliyuncs.com”]
}
systemctl daemon-reload
systemctl restart docker
cd /usr/local/ansible/awx-10.0.0/installer
ansible-playbook -i inventory install.yml
docker ps
cd /var/lib/awx/projects/
mv /usr/local/ansible/consensus.playbook ./
vi consensus.playbook/consensus.yml
systemctl stop firewalld
systemctl disable firewalld
sed -i ‘s/enforcing/disabled/g’ /etc/selinux/config
rpm -Uvh grafana/*.rpm --force --nodeps
systemctl enable grafana-server
systemctl start grafana-server