系统相关
首页 > 系统相关> > fescar-server安装、运行(ubuntu)

fescar-server安装、运行(ubuntu)

作者:互联网

wiki

https://github.com/alibaba/fescar/wiki/Home_Chinese

 

下载并安装

wget -P /opt/downloads https://github.com/alibaba/fescar/releases/download/v0.3.0/fescar-server-0.3.0.tar.gz
mkdir /opt/fescar-server
tar zxvf /opt/downloads/fescar-server-0.3.0.tar.gz -C /opt/fescar-server

 

确认配置值

vim /opt/fescar-server/conf/nacos-config.txt

一般不用修改

 

vim /opt/fescar-server/conf/nacos-config.sh
for line in $(cat nacos-config.txt)

改为

for line in $(cat /opt/fescar-server/conf/nacos-config.txt)

 

启动fescar-server-nacos-config 

启动格式为sh nacos-config.sh $Nacos-Server-IP

 

命令启动

bash /opt/fescar-server/conf/nacos-config.sh 192.168.1.102

 

守护进程启动

vim /lib/systemd/system/fescar-server-nacos-config.service

文件中填入

[Unit]
Description=fescar-server-nacos-config

[Service]
Type=simple
User=root
ExecStart=bash /opt/fescar-server/conf/nacos-config.sh 192.168.1.102
Restart=always
PrivateTmp=true
WorkingDirectory=/

[Install]
WantedBy=multi-user.target

赋予权限

chmod 777 /lib/systemd/system/fescar-server-nacos-config.service

启用服务

systemctl enable fescar-server-nacos-config.service
systemctl daemon-reload

运行

systemctl start fescar-server-nacos-config.service

查看状态

systemctl status fescar-server-nacos-config.service

查看进程

ps -ef|grep fescar-server-nacos-config

注:因为ubuntu默认用的dash而不是bash,这行命令如果用sh会报sh: let: not found

脚本执行最后输出 "init nacos config finished, please start fescar-server." 说明推送配置成功。若想进一步确认可登陆Nacos控制台->配置列表->筛选查询Group为FESCAR_GROUP的配置项。

 

 

 

启动fescar-server

编辑配置文件

vim /opt/fescar-server/conf/registry.conf

gg dG 清空文件

填入

registry {
  type = "nacos"

  nacos {    
    serverAddr = "192.168.1.102"
    namespace = "public"
    cluster = "default"
  }
}
config {
  type = "nacos"

  nacos {
    serverAddr = "192.168.1.102"
    namespace = "public"
    cluster = "default"
  }
} 

注:serverAddr不要填端口号

创建data文件夹

mkdir /opt/fescar-server/data

 

启动格式sh fescar-server.sh $LISTEN_PORT $PATH_FOR_PERSISTENT_DATA $IP(此参数可选)

$IP参数 用于多IP环境下指定 Fescar-Server 注册服务的IP

 

命令启动

sh /opt/fescar-server/bin/fescar-server.sh 8091 /opt/fescar-server/data

 

守护进程启动

vim /lib/systemd/system/fescar-server.service

文件中填入

[Unit]
Description=fescar-server

[Service]
Type=simple
User=root
ExecStart=sh /opt/fescar-server/bin/fescar-server.sh 8091 /opt/fescar-server/data
Restart=always
PrivateTmp=true
WorkingDirectory=/

[Install]
WantedBy=multi-user.target

赋予权限

chmod 777 /lib/systemd/system/fescar-server.service

启用服务

systemctl enable fescar-server.service
systemctl daemon-reload

运行

systemctl start fescar-server.service

查看状态

systemctl status fescar-server.service

查看进程

ps -ef|grep fescar-server

 

 

运行成功后可在Nacos控制台的 服务列表 看到 服务名serverAddr的条目

 

 

 

 

 

 

创建数据表,(创建mysql数据库略)
UNDO_LOG table is required by FESCAR AT mode.

-- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
CREATE TABLE `undo_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`branch_id` bigint(20) NOT NULL,
`xid` varchar(100) NOT NULL,
`rollback_info` longblob NOT NULL,
`log_status` int(11) NOT NULL,
`log_created` datetime NOT NULL,
`log_modified` datetime NOT NULL,
`ext` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

每个业务数据库都要建一个undo_log表

标签:opt,nacos,server,fescar,sh,ubuntu,config
来源: https://www.cnblogs.com/wintersoft/p/10548177.html