简体   繁体   English

有没有办法运行 .NET Core 服务,该服务使用操作系统身份验证将 RMAN 备份作为 systemd 运行?

[英]Is there a way to run a .NET Core Service that uses OS authentication to run RMAN backups as systemd?

I have a service set up in C#/.NET Core and part of its functionality is to launch RMAN for Oracle at a specified time each day.我在 C#/.NET Core 中设置了一个服务,它的部分功能是在每天的指定时间为 Oracle 启动 RMAN。 These functionalities all work perfectly running as the Oracle user but not as root or running as systemd(even if I include the parameter to run as oracle in the init file).这些功能都可以完美地以 Oracle 用户身份运行,但不能以 root 身份或以 systemd 身份运行(即使我在 init 文件中包含了作为 oracle 运行的参数)。

Error when trying to run RMAN as root: Error as Root尝试以 root 身份运行 RMAN 时出错Error as Root

ORA-12162: TNS:net service name is incorrectly specified ORA-12162: TNS:net 服务名称指定不正确

The code in C#: C#中的代码:

string oraHome = Environment.GetEnvironmentVariable("ORACLE_HOME");
            //execute powershell cmdlets or scripts using command arguments as process
            ProcessStartInfo processInfo = new ProcessStartInfo
            {
                FileName = $"{oraHome}/bin/rman",
                Arguments = $"NOCATALOG TARGET  / CMDFILE {RMANObjects.Backup}RMAN_{RMANObjects.sn}.rcv LOG {RMANObjects.Backup}backup_log_{RMANObjects.sn}.txt",
                RedirectStandardError = true,
                RedirectStandardOutput = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };

            //start powershell process using process start info
            Process process = new Process();
            process.StartInfo = processInfo;
            process.Start();

RMANandLogMover init/service file RMANandLogMover 初始化/服务文件

 [Unit] Description=RMANandLogMover DefaultDependencies=no [Service] Type=notify WorkingDirectory=/home/oracle/app/RMANandLogMover/8.25Logmover ExecStart=/home/oracle/app/RMANandLogMover/8.25Logmover/RMANandLogMover Environment=ORACLE_HOME=/home/oracle/app/product/19.0.0/dbhome_1 User=oracle Group=backupdba RemainAfterExit=yes [Install] WantedBy=default.target

the problem here is not all environment variables are set.这里的问题不是所有的环境变量都被设置了。 I suggest you to invoke oraenv first and make sure that you are using oracle's os user, not any other我建议您先调用oraenv并确保您使用的是 oracle 的 os 用户,而不是任何其他用户

export ORACLE_HOME=<path>
export ORACLE_SID=orcl
export ORAENV_ASK=NO
. oraenv

first code this, then run RMAN :)首先对此进行编码,然后运行 ​​RMAN :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法在具有 .net 内核的计时器上运行 DI 范围服务? - Is there a way to run a DI scoped service on a timer with .net core? 在 Linux 作为服务运行时防止 a.Net Core 5 控制台应用程序结束的推荐方法 - Recommended way to prevent a .Net Core 5 console app from ending when run on Linux as a service 将 asp.net 核心运行操作系统从 windows 切换到 linux - switch asp.net core run os from windows to linux 作为单个条目运行Oracle RMAN脚本 - run Oracle RMAN scripts as a single entry .Net Core 3.0 on Linux, systemd服务启动独立进程 - .Net Core 3.0 on Linux, systemd service start a independent process 如何在.net core windows后台服务每5分钟运行一次方法 - How to run method in every 5 minute in .net core windows background service 如何在一天中的特定时间运行 .net Core IHosted 服务? - How to run .net Core IHosted Service at specific time Of the day? 有什么方法可以在Linux容器中运行.NET Core App? - Is there any way to run a .NET Core App inside a Linux container? 有没有调试模式运行.net核心Web应用程序的方法? - Any way to run .net core web app without debug mode? 如何运行在.net Core中使用依赖注入的非静态代码 - How to run non-static code that uses dependency injection in .net core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM