새로운 SAS Viya(2020.1 상위 버전)에 새로운 커맨드 라인 인터페이스가 있다는 것을 아셨나요?
필수 사항
1.sas라는 .sas 프로그램을 일괄적으로 실행하려는 경우
새로운 SAS Viya(2020.1 상위 버전)에서는 CLI(커맨드 라인 인터페이스) 배치 플러그인을 사용할 수 있습니다.
/opt/sas/viya/home/bin/sas-viya --profile ${SAS_CLI_PROFILE} batch jobs submit-pgm --pgm-path /tmp/1.sas --context default --watch-output --wait-log-list --results-dir /tmp |
과거 SAS Viya 3.5에서는 다음과 같이 작성해야 했습니다.
/opt/sas/spre/home/SASFoundation/sas -autoexec "/opt/sas/viya/config/etc/workspaceserver/default/autoexec_deployment.sas" /tmp/1.sas -log /tmp/1.log |
세부 사항
SAS Batch Command Line Utility는 일괄 처리를 위해 Kubernetes 클러스터에서 실행되는 SAS Viya 환경으로 커맨드 라인에서 SAS 프로그램 또는 명령을 제출할 수 있는 커맨드 라인 인터페이스입니다. 원리는 Command-Line Interface: Overview.를 통해 확인하실 수 있습니다.
최상위 명령문은 sas-viya입니다. Batch 플러그인을 초기화, 인증 및 실행하는 데 사용됩니다. 전체 플러그인 목록은 커 Command-Line Interface: Plug-Ins.을 통해 확인하실 수 있습니다.
예시
sas-viya batch submit-pgm 명령 전 몇 가지 추가 작업이 필요합니다.
프로필 설정
Kubernetes 네임스페이스를 확인합니다. 이 예시에서 SAS Viya는 gelcorp 네임스페이스에서 실행됩니다. Viya가 실행 중인 네임스페이스를 모르는 경우 다음을 입력합니다.
kubectl get ns |
SAS Viya 애플리케이션(예: SAS Environment Manager, SAS Drive 등)은 기본적으로 $INGRESS_URL에 설명된 위치에서 액세스할 수 있습니다.
current_namespace=gelcorp INGRESS_SUFFIX=$(hostname -f) INGRESS_URL=http://${current_namespace}.${INGRESS_SUFFIX} echo ${INGRESS_URL} |
TLS 케이스
CAS는 서버와 클라이언트 간의 암호화된 연결을 지원합니다. TLS를 활성화하여 서버와 클라이언트 간의 통신을 보호할 수 있습니다. 클라이언트 서버 통신에 사용되는 인증서는 모든 잠재적 클라이언트가 신뢰하는 인증 기관의 확인이 필요합니다.
따라서 TLS가 활성화된 SAS Viya 배포가 있는 경우 인증서를 한 번만 불러오면 됩니다. kubectl 관리자 역할이 필요합니다.
mkdir -p ~/.certs kubectl cp $(kubectl get pod -l app=sas-logon-app -o=jsonpath='{.items[0].metadata.name}'):security/trustedcerts.pem ~/.certs/${current_namespace}_trustedcerts.pem |
인증
sas-viya 프로필 및 auth 명령 전 매번 다음 명령이 필요합니다. 이는 CLI에서 인증서 및 TLS(인증 기관 번들)의 위치를 가리킵니다.
export SSL_CERT_FILE=~/.certs/${current_namespace}_trustedcerts.pemexport REQUESTS_CA_BUNDLE=${SSL_CERT_FILE} |
SAS VIYA CLI가 설치된 폴더로 전환합니다. $clidir에 설치되어있다고 가정한 경우입니다.
clidir=/opt/sas/viya/home/bin cd $clidir |
${SAS_CLI_PROFILE}이라는 기능 프로필을 만듭니다. gelcorp을 통해 진행하면 됩니다.
echo ${current_namespace} export SAS_CLI_PROFILE=${current_namespace} ./sas-viya --profile ${SAS_CLI_PROFILE} profile set-endpoint "${INGRESS_URL}" ./sas-viya --profile ${SAS_CLI_PROFILE} profile toggle-color off ./sas-viya --profile ${SAS_CLI_PROFILE} profile set-output fulljson
# login and create a token ./sas-viya --profile ${SAS_CLI_PROFILE} auth login -user sasadm -password ******* |
기본적으로 인증은 12시간 동안 유지됩니다. sas-viya batch auth logout 명령어를 사용하여 로그아웃할 수 있습니다.
.sas 프로그램 실행
/tmp 폴더에 1.sas를 생성합니다.
예시:
echo 'proc setinit; run; quit;' | tee /tmp/1.sas |
프로그램 실행:
cd /tmp/ /opt/sas/viya/home/bin/sas-admin --profile ${SAS_CLI_PROFILE} batch jobs submit-pgm --pgm-path /tmp/1.sas --context default --watch-output --wait-log-list --results-dir /tmp |
cas 문 실행
SAS Environment Manager에서 CAS controller host 및 port를 확인합니다.
크게 보시려면 이미지를 클릭하시기 바랍니다. 모바일 버전: 이미지를 보시려면 페이지 하단의 풀 버전을 선택하세요.
sas 프로그램을 생성한 후 다음을 통해 실행합니다.
echo 'cas casauto host="controller.sas-cas-server-default.gelcorp.svc.cluster.local" port=5570;' | tee /tmp/2.sas echo 'cas casauto terminate;' | tee -a /tmp/2.sas cat /tmp/2.sas |
프로그램 실행:
cd /tmp/ /opt/sas/viya/home/bin/sas-viya --profile ${SAS_CLI_PROFILE} batch jobs submit-pgm --pgm-path /tmp/2.sas --context default --watch-output --wait-log-list --results-dir /tmp |
로그는 다음과 같습니다.
>>> File set created, ID="JOB_20201009_045619_929_1" >>> Uploading "2.sas" >>> Job submitted, ID="64139ca3-84aa-4d6c-bed8-d7c25a3647fd". >>> Waiting for job to complete... >>> Job started .…. 1 cas casauto host="controller.sas-cas-server-default.gelcorp.svc.cluster.local" port=5570; NOTE: The session CASAUTO connected successfully to Cloud Analytic Services controller.sas-cas-server-default.gelcorp.svc.cluster.local using port 5570. The UUID is fc406c5b-3ec4-914c-97b2-48c99121eb1c. The user is sasadm and the active caslib is CASUSER(sasadm). NOTE: The SAS System used: real time 0.40 seconds cpu time 0.06 seconds … <<< Job ended. <<< Downloading files in fileset to "/tmp/JOB_20201009_045619_929_1". <<< Downloading "2.log" <<< Downloading "2.sas" <<< Copying log and list files from "/tmp/JOB_20201009_045619_929_1" to current directory <<< Copying "2.log" <<< Deleting results directory. <<< Deleting batch job. <<< Deleting fileset. |
sas-viya 배치 CLI는 SAS/Connect의 RSUBMIT 명령과 유사합니다. 실행된 작업만 서버 세션에 저장되는 것이 아니라 Kubernetes 클러스터 또한 저장되며 결과와 출력은 클라이언트 세션으로 전달됩니다. .
사용된 옵션
Submit SAS Programs in Batch.을 통해 자세한 사항을 확인하실 수 있습니다.
전제 조건
SAS Viya CLI 설치
배치 명령을 수행하려면 명령을 실행할 시스템에 SAS Viya CLI가 설치되어 있어야 합니다. Gerry Nelson은 자 Keeping the SAS Administration Command-Line interfaces up-to-date에서 자세히 다룬 바 있습니다. 이 포스팅은 SAS Viya 2020.1 상위 버전에서 sas-viya로 대체된 sas-admin 실행 파일에 대해 설명합니다. Nelson에 따르면 sas-admin을 sas-viya로 호환해도 문제가 되지 않습니다.
pyviyatools 설치
authinfo 파일로 인증하려면 pyviyatools가 필요합니다. pyviatools 설치 안내는 INSTALL.md을 통해 확인하실 수 있습니다.
보안
보다 안전한 방법은 자격 증명을 인코딩하지 않는 것입니다. pyviya 도구와 함께 .authinfo 파일을 사용할 수 있습니다. Gerry의 게시물: GEL pyviyatools 소개를 참조하세요.
# Instead of # ./sas-viya --profile ${SAS_CLI_PROFILE} auth login -user sasadm -password *****
# Create .authinfo - replace ***** with real credentials tee ~/.authinfo > /dev/null << EOF default user sasadm password ***** EOF
chmod 600 ~/.authinfo
# Browse to PyViya Tools folder and use the loginviauthinfo command for authentification cd ~/admin/pyviyatools ./loginviauthinfo.py -f ~/.authinfo |
pyviatools 설치 지침은 INSTALL.md .에서 찾을 수 있습니다.
결론
새로운 SAS Viya(2020.1 상위 버전)에서 sas 프로그램을 한번에 실행하려면 sas-viya 일괄 CLI 사용을 추천드립니다. 유일한 옵션은 아니며 관리, 이전, 자동화할 수 있는 다른 CLIs를 사용하셔도 됩니다.
감사 말씀
Ajmal Farzam, Gerry Nelson, Mark Thomas and Stephen Foerster.께 감사 드립니다.
참고문헌
이 포스팅을 읽어주셔서 감사합니다. 도움이 되셨다면 ‘좋아요’를 눌러주세요.
SAS Viya에 대한 경험과 고견을 나눠주시면 감사하겠습니다.
이곳에서 SAS Global Enablement and Learning에서 더 많은 기사를 찾아보실 수 있습니다.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.