在Windows操作系統(tǒng)中,"link"命令用于創(chuàng)建符號(hào)鏈接或硬鏈接。
符號(hào)鏈接(Symbolic Link)是一種特殊的文件類型,它包含指向另一個(gè)文件或目錄的路徑。當(dāng)訪問符號(hào)鏈接時(shí),系統(tǒng)會(huì)跟隨路徑找到實(shí)際的文件或目錄。符號(hào)鏈接可以是相對(duì)路徑或絕對(duì)路徑,并且可以跨越不同的驅(qū)動(dòng)器和文件系統(tǒng)。
硬鏈接(Hard Link)是在文件系統(tǒng)中創(chuàng)建一個(gè)新的文件名,與原文件名指向同一個(gè)索引節(jié)點(diǎn)(inode),實(shí)際上它們是同一個(gè)文件。對(duì)其中一個(gè)文件所做的更改都會(huì)反映在另一個(gè)文件上。與符號(hào)鏈接不同,硬鏈接只能鏈接到文件而不能鏈接到目錄,并且只能在同一個(gè)驅(qū)動(dòng)器上創(chuàng)建。
"link"命令的原理和機(jī)制是基于文件系統(tǒng)的數(shù)據(jù)結(jié)構(gòu)。在Windows文件系統(tǒng)中,每個(gè)文件都有一個(gè)唯一的File ID(文件標(biāo)識(shí)符),用來表示文件的元數(shù)據(jù)信息。當(dāng)創(chuàng)建一個(gè)硬鏈接時(shí),實(shí)際上是在文件系統(tǒng)中創(chuàng)建了一個(gè)新的文件名,并將這個(gè)文件名與原文件的File ID 關(guān)聯(lián)起來,使它們指向同一個(gè)文件。創(chuàng)建符號(hào)鏈接時(shí),也是在文件系統(tǒng)中創(chuàng)建一個(gè)新的文件名,并將這個(gè)文件名與指向的文件或目錄的路徑關(guān)聯(lián)起來。
link命令可以用于創(chuàng)建符號(hào)鏈接和硬鏈接,它們有各自的應(yīng)用場景:
符號(hào)鏈接
符號(hào)鏈接適用于以下場景:
需要在不同的文件系統(tǒng)之間鏈接文件:由于符號(hào)鏈接可以跨越不同驅(qū)動(dòng)器和文件系統(tǒng),所以可以使用符號(hào)鏈接將一個(gè)文件鏈接到另一個(gè)文件系統(tǒng)中。
需要鏈接目錄:硬鏈接只能鏈接文件,而符號(hào)鏈接可以鏈接目錄,這使得它們?cè)谝恍┨囟ㄇ闆r下非常有用。
需要鏈接到相對(duì)路徑:相對(duì)路徑是相對(duì)于當(dāng)前位置而言的。符號(hào)鏈接可以鏈接到相對(duì)路徑,這使得它們?cè)谝恍┨囟ㄇ闆r下非常有用。
硬鏈接
硬鏈接適用于以下場景:
需要在同一文件系統(tǒng)上鏈接文件:由于硬鏈接只能鏈接同一文件系統(tǒng)上的文件,因此它們通常用于在同一磁盤分區(qū)上鏈接文件。
需要多個(gè)文件名同時(shí)指向同一個(gè)文件:硬鏈接允許多個(gè)文件名指向同一個(gè)文件,這意味著可以在不同的位置上使用不同的文件名訪問同一個(gè)文件。
需要共享數(shù)據(jù):當(dāng)多個(gè)用戶需要同時(shí)訪問同一個(gè)文件時(shí),使用硬鏈接可以避免復(fù)制多份相同的文件。這樣可以節(jié)省磁盤空間,并且保證數(shù)據(jù)一致性。
link命令
用法:link [OPTION]... TARGET LINK_NAME
創(chuàng)建一個(gè)名為LINK_NAME的硬鏈接,鏈接到文件TARGET。
選項(xiàng):
-d, --directory 創(chuàng)建一個(gè)目錄的硬鏈接
-f, --force 如果LINK_NAME已經(jīng)存在,則強(qiáng)制覆蓋它
-i, --interactive 覆蓋現(xiàn)有文件之前進(jìn)行交互式確認(rèn)
-n, --no-dereference 將符號(hào)鏈接視為常規(guī)文件
-s, --symbolic 創(chuàng)建一個(gè)符號(hào)鏈接而不是硬鏈接
-v, --verbose 顯示詳細(xì)輸出
-V, --version 顯示版本信息并退出
-h, --help 顯示幫助信息并退出
使用示例:
創(chuàng)建一個(gè)硬鏈接:link file1 link1
創(chuàng)建一個(gè)目錄的硬鏈接:link -d directory1 link1
創(chuàng)建一個(gè)符號(hào)鏈接:link -s file1 link1
參考:
參考【后端編譯 | Apache Linkis】】
<mysql.connector.scope>compile</mysql.connector.scope>
<!--<mysql.connector.scope>test</mysql.connector.scope>-->
如果您是本地第一次使用,必須在最外層工程pom.xml所在目錄先執(zhí)行以下命令:
mvn -N install
在最外層工程pom.xml所在目錄執(zhí)行以下命令
mvn clean install -DskipTests
參考【管理臺(tái)編譯 | Apache Linkis】
在 Linkis 源碼文件夾下,子目錄 linkis-dist/package/conf 中,是 Linkis 的一些默認(rèn)配置文件,將配置文件復(fù)制到自己的配置文件目錄,如D:\linkis\linkis-package\conf
增加日志輸出到控制臺(tái)的配置,修改后內(nèi)容如下:
<configuration status="error" monitorInterval="30">
<properties>
<property name="LOG_PATH">logs</property>
<property name="LOG_FILE">linkis</property>
</properties>
<appenders>
<RollingFile name="RollingFile" append="true" fileName="${LOG_PATH}/${LOG_FILE}.log"
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${LOG_FILE}/linkis-log-%d{yyyy-MM-dd-hh}-%i.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%-40t] %c{1.} (%L) [%M] [JobId-%X{jobId}] - %msg%xEx%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="100MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<console name="Console-Plain" target="SYSTEM_OUT">
<!--輸出日志的格式-->
<PatternLayout pattern="%m%n"/>
</console>
</appenders>
<loggers>
<root level="INFO">
<appender-ref ref="Console-Plain"/>
</root>
<logger name="com.netflix.loadbalancer.DynamicServerListLoadBalancer" level="warn" additivity="true">
<appender-ref ref="Console-Plain"/>
</logger>
</loggers>
</configuration>
創(chuàng)建數(shù)據(jù)庫,并執(zhí)行l(wèi)inkis數(shù)據(jù)庫腳本,修改linkis.properties配置文件。
所有微服務(wù)名稱如下:
├── linkis-cg-engineconnmanager 引擎管理服務(wù)
├── linkis-cg-engineplugin 引擎插件管理服務(wù)
├── linkis-cg-entrance 計(jì)算治理入口服務(wù)
├── linkis-cg-linkismanager 計(jì)算治理管理服務(wù)
├── linkis-mg-eureka 微服務(wù)注冊(cè)中心服務(wù)
├── linkis-mg-gateway Linkis網(wǎng)關(guān)服務(wù)
├── linkis-ps-publicservice 公共服務(wù)
Linkis 和 DSS 的服務(wù)都依賴 Eureka,所以我們需要首先啟動(dòng) Eureka 服務(wù),Eureka 服務(wù)可以在本地啟動(dòng),也可以使用遠(yuǎn)程啟動(dòng)的服務(wù)。保證各個(gè)服務(wù)都能訪問到 Eureka 的 IP 和端口之后,就可以開始著手啟動(dòng)其他微服務(wù)了。
在 Linkis 內(nèi)部是通過-DserviceName 參數(shù)設(shè)置應(yīng)用名以及使用配置文件,所以-DserviceName 是必須要指定的 VM 啟動(dòng)參數(shù)。
可以通過 “-Xbootclasspath/a:配置文件路徑”命令,將配置文件追加到引導(dǎo)程序類的路徑末尾,即將依賴的配置文件加到 classpath 中。
通過勾選 Include dependencies with “Provided” scope ,可以在調(diào)試時(shí),引入 provided 級(jí)別的依賴包。
服務(wù)名:
linkis-mg-eureka
啟動(dòng)類:
org.apache.linkis.eureka.SpringCloudEurekaApplication
VM參數(shù):
-DserviceName=linkis-mg-eureka -Xbootclasspath/a\:D:\linkis\linkis-package\conf
program參數(shù):
--spring.profiles.active=eureka --eureka.instance.preferIpAddress=true
直接運(yùn)行此Application,成功啟動(dòng)后可以通過http://localhost:20303/ 查看 eureka 服務(wù)列表。
附:如果服務(wù)器已有l(wèi)inkis-mg-eureka服務(wù),可以使用nginx作為代理訪問(端口不能直接訪問)。修改nginx.conf,配置如下
upstream eureka-host {
server eurake服務(wù)器IP:20303;
}
location /eureka {
proxy_pass http://eurake服務(wù)器IP:20303;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /eureka/js/wro.js {
proxy_pass http://eureka-host/eureka/js/wro.js;
}
location /eureka/css/wro.css {
proxy_pass http://eureka-host/eureka/css/wro.css;
}
location /eureka/images/spring-logo-eureka.png {
proxy_pass http://eureka-host/eureka/images/spring-logo-eureka.png;
}
location /eureka/fonts/montserrat-webfont.woff {
proxy_pass http://eureka-host/eureka/fonts/montserrat-webfont.woff;
}
location /eureka/fonts/varela_round-webfont.woff {
proxy_pass http://eureka-host/eureka/fonts/varela_round-webfont.woff;
}
location /eureka/fonts/montserrat-webfont.ttf {
proxy_pass http://eureka-host/eureka/fonts/montserrat-webfont.ttf;
}
location /eureka/fonts/varela_round-webfont.ttf {
proxy_pass http://eureka-host/eureka/fonts/varela_round-webfont.ttf;
}
location ^~/eureka-state {
proxy_pass http://eureka-host/;
}
可通過http://代理IP:代理端口/eureka-state 訪問eurake web
其他服務(wù)訪問eurake,修改application-linkis.yml中eurake配置
defaultZone: http://代理IP:代理端口/eureka
linkis-mg-gateway 是 Linkis 的服務(wù)網(wǎng)關(guān),所有的請(qǐng)求都會(huì)經(jīng)由 gateway 來轉(zhuǎn)發(fā)到對(duì)應(yīng)的服務(wù)上。
啟動(dòng)服務(wù)器前,首先需要編輯 conf/linkis-mg-gateway.properties 配置文件,增加管理員用戶名和密碼,【用戶名需要與你當(dāng)前登錄的機(jī)器用戶名保持一致?待驗(yàn)證】。我配置為如下,用于dss登錄。
wds.linkis.admin.user=hadoop
wds.linkis.admin.password=123456
設(shè)置 linkis-mg-gateway的啟動(dòng)Application:
服務(wù)名:
linkis-mg-gateway
啟動(dòng)類:
org.apache.linkis.gateway.springcloud.LinkisGatewayApplication
VM參數(shù):
-DserviceName=linkis-mg-gateway -Xbootclasspath/a\:D:\linkis\linkis-package\conf
啟動(dòng)服務(wù),可正常啟動(dòng),不過,在服務(wù)調(diào)用時(shí),會(huì)報(bào)gatewayParsers空異常?
參考【關(guān)于linkis-spring-cloud-gateway 服務(wù)的空指針以及gatewayProperties無法賦值問題 · Issue #1086 · apache/linkis (github.com)】,做如下調(diào)整:
1.修改linkis-spring-cloud-gateway模塊下的pom.xml。添加如下內(nèi)容,并修改reactor-netty包版本,重新import。(不先import,下面修改Project Structure的修改會(huì)丟失)。
<!-- only for debug -->
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<!-- <version>0.9.7.RELEASE</version>-->
<version>0.9.20.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-pes-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-jobhistory</artifactId>
<version>${project.version}</version>
</dependency>
<!-- instance label -->
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-instance-label-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- only for debug -->
2.打開Project Structrue,刪除linkis-engineplugin-openlookeng、linkis-eureka、linkis-metadata模塊下重復(fù)的Source Folders和Resource Folders。【沒有重復(fù)則跳過此步驟】。
3.linkis-spring-cloud-gateway模塊添加linkis-gateway-server-support-1.5.0-SNAPSHOT.jar到classpath。
4.修改linkis-mg-gateway.properties文件,在mybatis包掃描配置中添加jobhistory模塊bean和entity包掃描。
5.保存設(shè)置,重新啟動(dòng)linkis-mg-gateway服務(wù)。調(diào)試gatewayParsers不為null。
publicservice 是 Linkis 的公共增強(qiáng)服務(wù),為其他微服務(wù)模塊提供統(tǒng)一配置管理、上下文服務(wù)、物料庫、數(shù)據(jù)源管理、微服務(wù)管理和歷史任務(wù)查詢等功能的模塊。
設(shè)置linkis-ps-publicservice的啟動(dòng)Application:
服務(wù)名:
linkis-ps-publicservice
啟動(dòng)類:
org.apache.linkis.filesystem.LinkisPublicServiceApp
VM參數(shù):
-DserviceName=linkis-ps-publicservice -Xbootclasspath/a\:D:\linkis\linkis-package\conf
如果需要物料上傳需求,做以下調(diào)整:
<!-- only for debug -->
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-datasource-manager-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-bmlserver</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-metadata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-cs-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-instance-label-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-udf-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-jobhistory</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-configuration</artifactId>
<version>${project.version}</version>
</dependency>
<!-- only for debug -->
服務(wù)名:
linkis-cg-linkismanager
啟動(dòng)類:
org.apache.linkis.manager.LinkisManagerApplication
VM參數(shù):
-DserviceName=linkis-cg-linkismanager -Xbootclasspath/a:D:\linkis\linkis-package\conf
修改linkis-cg-linkismanager.properties,配置wds.linkis.engineconn.home參數(shù)【需解壓linkis安裝包到指定目錄】
#wds.linkis.engineconn.home=/appcom/Install/LinkisInstall/lib/linkis-engineconn-plugins
#wds.linkis.engineconn.plugin.loader.store.path=/appcom/Install/LinkisInstall/lib/linkis-engineconn-plugins
wds.linkis.engineconn.home=D:\\linkis\\linkis-package\\lib\\linkis-engineconn-plugins
服務(wù)名:
linkis-cg-entrance
啟動(dòng)類:
org.apache.linkis.entrance.LinkisEntranceApplication
VM參數(shù):
-DserviceName=linkis-cg-entrance -Xbootclasspath/a:D:\linkis\linkis-package\conf
服務(wù)名:
linkis-cg-engineconnmanager
啟動(dòng)類:
org.apache.linkis.ecm.server.LinkisECMApplication
VM參數(shù):
-DserviceName=linkis-cg-engineconnmanager -Xbootclasspath/a:D:\linkis\linkis-package\conf
linkis-cg-engineconnmanager模塊調(diào)試暫只支持Mac OS 和 Linux系統(tǒng)。【可參考官方文檔調(diào)試 Debug 指引 | Apache Linkis進(jìn)行遠(yuǎn)程調(diào)試】
啟動(dòng)控制臺(tái)可以看到如下異常:
start register ecm
RPC-Sender-Asyn-Thread-ListenerBus add a new listener=> class org.apache.linkis.rpc.BaseRPCSender$$anon$1
Flipping property: linkis-cg-linkismanager.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit=2147483647
Shutdown hook installed for: NFLoadBalancer-PingTimer-linkis-cg-linkismanager
Client: linkis-cg-linkismanager instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=linkis-cg-linkismanager,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
Flipping property: linkis-cg-linkismanager.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit=2147483647
Start to linkis-ec-clear shell
Shell linkis-ec-clear.sh execution failed, msg:Cannot run program "sh": CreateProcess error=2, 系統(tǒng)找不到指定的文件。
End to linkis-ec-clear shell
Flipping property: linkis-cg-linkismanager.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit=2147483647
org.apache.linkis.ecm.server.service.impl.DefaultECMHealthService@251b3e8a changed status Starting=> Running.
ECM:ServiceInstance(linkis-cg-engineconnmanager, DIGITAL-MAYANJ:9102, 0) is ready
SpringCloudInstanceLabelClient app state ACCEPTING_TRAFFIC
SpringCloudInstanceLabelClient init
至此,查看eureka界面,查看服務(wù)列表:
新建數(shù)據(jù)庫dss,前后執(zhí)行db目錄下的dss_ddl.sql、dss_dml.sql腳本文件
如果您是本地第一次使用,必須在最外層工程pom.xml所在目錄先執(zhí)行以下命令:
mvn -N install
在最外層工程pom.xml所在目錄執(zhí)行以下命令
mvn clean install -DskipTests
在 DSS 源碼文件夾下,子目錄conf 中,是 dss 的一些默認(rèn)配置文件,將配置文件復(fù)制到自己的配置文件目錄,如D:\dss\dss-1.1.2\conf
增加日志輸出到控制臺(tái)的配置,修改內(nèi)容如下:
<configuration status="error" monitorInterval="30">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %logger{36} %L %M - %msg%xEx%n"/>
</Console>
</appenders>
<loggers>
<root level="INFO">
<appender-ref ref="Console"/>
</root>
</loggers>
</configuration>
服務(wù)名:
dss-server
啟動(dòng)類:
com.webank.wedatasphere.dss.DSSServerApplication
VM參數(shù):
-DserviceName=dss-framework-orchestrator-server -DDSS\_HOME=D:\\dss\\dss-1.1.2 -Xbootclasspath/a\:D:\\dss\\dss-1.1.2\\conf
修改dss-server模塊下的pom.xml,添加如下內(nèi)容:
<!-- only for debug -->
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-rpc</artifactId>
<version>${linkis.version}</version>
</dependency>
<dependency>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>${spring.cloud.version}</version>
</dependency>
<dependency>
<groupId>com.webank.wedatasphere.dss</groupId>
<artifactId>dss-sender-service</artifactId>
<version>${dss.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<!-- only for debug -->
由于dss-server啟動(dòng),com.webank.wedatasphere.dss.common.utils.ZipHelper會(huì)使用到zip命令,需要安裝zip和unzip命令【下載地址zip and unzip for the windows command line (stahlworks.com)】,直接下載安裝即可。
修改com.webank.wedatasphere.dss.common.utils.ZipHelper 源碼。將源碼中String[] strArr=dirPath.split(File.separator);修改為如下代碼:
String[] strArr=null;
if (FsPath.WINDOWS) {
strArr=dirPath.split("\\" + File.separator);
} else {
strArr=dirPath.split(File.separator);
}
修改linkis項(xiàng)目中org.apache.linkis.storage.fs.impl.LocalFileSystem源碼:
@Override
public boolean create(String dest) throws IOException {
LOG.info("try to create file with path:" + dest);
File file=new File(dest);
if (!FsPath.WINDOWS && !isOwner(file.getParent())) {
throw new IOException("you have no permission to create file " + dest);
}
try {
boolean created=file.createNewFile();
if (created && !FsPath.WINDOWS) {
setPermission(new FsPath(dest), this.getDefaultFilePerm());
if (!user.equals(getOwner(dest))) {
setOwner(new FsPath(dest), user, null);
}
}
return created;
} catch (Throwable e) {
file.delete();
if (e instanceof IOException) {
throw (IOException) e;
} else {
throw new IOException(e);
}
}
}
服務(wù)名:
dss-apps-server
啟動(dòng)類:
com.webank.wedatasphere.dss.apps.DSSAppsServerApplication
VM參數(shù):
-DserviceName=dss-apps-server -DDSS\_HOME=D:\\dss\\dss-1.1.2 -Xbootclasspath/a\:D:\\dss\\dss-1.1.2\\conf
修改dss-server模塊下的pom.xml,添加如下內(nèi)容:
<!-- only for debug -->
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-rpc</artifactId>
<version>${linkis.version}</version>
</dependency>
<dependency>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>${spring.cloud.version}</version>
</dependency>
<dependency>
<groupId>com.webank.wedatasphere.dss</groupId>
<artifactId>dss-sender-service</artifactId>
<version>${dss.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<!-- only for debug -->
至此,查看eurake服務(wù)列表:
參考【DataSphereStudio-Doc/zh_CN/開發(fā)文檔/前端編譯文檔.md at main · WeDataSphere/DataSphereStudio-Doc (github.com)】
本地編譯node版本為16.15.1 ,learna版本為 6.4.0
編譯啟動(dòng),瀏覽器打開http://localhost:8080。使用1.4.2中配置的用戶名和密碼登錄。
本文中調(diào)試過程基于linkis和DSS的master分支,由于社區(qū)活躍,代碼變化頻繁,部分內(nèi)容會(huì)有一些出入,可按需和調(diào)試日志做適當(dāng)調(diào)整。還有很多功能沒有進(jìn)行調(diào)試,如任務(wù)創(chuàng)建、執(zhí)行等,各種appcon集成等。