<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>运维 on YuYoung&#39;s Blog</title>
    <link>https://yuyoung32.github.io/categories/%E8%BF%90%E7%BB%B4/</link>
    <description>Recent content in 运维 on YuYoung&#39;s Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh</language>
    <lastBuildDate>Tue, 25 Apr 2023 13:27:19 +0800</lastBuildDate><atom:link href="https://yuyoung32.github.io/categories/%E8%BF%90%E7%BB%B4/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Nginx简述与业务场景指引</title>
      <link>https://yuyoung32.github.io/post/nginx%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF/</link>
      <pubDate>Tue, 25 Apr 2023 13:27:19 +0800</pubDate>
      
      <guid>https://yuyoung32.github.io/post/nginx%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF/</guid>
      <description>概念与安装 Nginx-安装和配置详解
#ubuntu apt install nginx 主配置文件：/etc/nginx/nginx.conf 日志默认存放位置：/var/log/nginx/access.log与/var/log/nginx/error.log 配置文件大纲
#main # 全局配置 events { # nginx工作模式配置 } http { # http设置 .... server { # 服务器主机配置 .... location { # 路由配置 .... } location path { .... } location otherpath { .... } } server { .... location { .... } } upstream name { # 负载均衡配置 .... } } 业务场景 子域名http://admin.domain.name:80导向前端server 以vue-cli构建的dist目录，使用hash history为例
server { listen 80; server_name admin.domain.name; root /home/www/dist; index index.</description>
    </item>
    
    <item>
      <title>如何把某个应用包装成服务aka后台运行</title>
      <link>https://yuyoung32.github.io/post/%E5%A6%82%E4%BD%95%E6%8A%8A%E6%9F%90%E4%B8%AA%E5%BA%94%E7%94%A8%E5%8C%85%E8%A3%85%E6%88%90%E6%9C%8D%E5%8A%A1aka%E5%90%8E%E5%8F%B0%E8%BF%90%E8%A1%8C/</link>
      <pubDate>Sun, 23 Apr 2023 16:06:34 +0800</pubDate>
      
      <guid>https://yuyoung32.github.io/post/%E5%A6%82%E4%BD%95%E6%8A%8A%E6%9F%90%E4%B8%AA%E5%BA%94%E7%94%A8%E5%8C%85%E8%A3%85%E6%88%90%E6%9C%8D%E5%8A%A1aka%E5%90%8E%E5%8F%B0%E8%BF%90%E8%A1%8C/</guid>
      <description>将某个应用包装成服务（后台运行） 简要说明 在指定目录下创建服务说明文件
vim /etc/systemd/system/myapp.service 输入相关信息
[Unit] Description=My Application After=network.target [Service] User=yourusername WorkingDirectory=/opt/myapp ExecStart=/opt/myapp/run.sh Restart=always [Install] WantedBy=multi-user.target 保存配置
systemctl daemon-reload 启动服务和检查状态
systemctl start myapp.service &amp;amp;&amp;amp; systemctl status myapp.service 设置开机自启动【可选】
systemctl enable myapp.service systemctl disable my_service #关闭自启动 如有出错可检查详细日志文件
tail /var/log/syslog tail /var/log/messages 详细说明 .service文件可选择在以下目录创建 /etc/systemd/system/：这是系统级服务文件存放的目录。在这个目录下创建服务文件需要超级用户权限。 /usr/lib/systemd/system/：这是系统默认服务文件存放的目录。通常在这个目录下安装软件包时会自动创建相应的服务文件。 /run/systemd/system/：这个目录包含了运行时系统所使用的服务文件，通常由 systemd 自动管理。 [service]下的User 可以接受一个用户名或用户ID（UID）或用户组名或用户组ID (GID)作为参数，以标识服务所运行的用户和组。如果未指定，则默认情况下服务将以 root 用户身份运行。
[service]下的WorkingDirectory，如果没有正确地设置 WorkingDirectory ，那么服务可能无法正常启动或运行，因为服务可能会试图在不正确的目录中寻找需要的文件或资源。在服务文件的配置中， WorkingDirectory 可以使用相对路径或绝对路径指定服务的工作目录。如果该选项未设置，则默认情况下服务将在 / 根目录下运行。
[service]下的Restart，当 Restart=always 选项设置在服务文件中时，如果系统检测到服务已经停止（无论是由于任何原因），systemd 将自动尝试重新启动该服务。它将一直尝试重新启动服务，直到服务成功启动为止。
除了 always，Restart 选项还支持其他几个值：
no：服务退出时不会重启。 on-abnormal：仅当服务以非正常方式退出时才会重启。 on-failure：仅当服务以错误状态（退出代码非零）退出时才会重启。 on-success：仅当服务以成功状态（退出代码为零）退出时才会重启。 on-watchdog：仅当服务未及时响应守护程序时才会重启。这个选项需要服务内部有守护程序的支持。 </description>
    </item>
    
    <item>
      <title>运维的问题其他汇总</title>
      <link>https://yuyoung32.github.io/post/%E8%BF%90%E7%BB%B4%E7%9A%84%E9%97%AE%E9%A2%98%E5%85%B6%E4%BB%96%E6%B1%87%E6%80%BB/</link>
      <pubDate>Sun, 23 Apr 2023 16:03:50 +0800</pubDate>
      
      <guid>https://yuyoung32.github.io/post/%E8%BF%90%E7%BB%B4%E7%9A%84%E9%97%AE%E9%A2%98%E5%85%B6%E4%BB%96%E6%B1%87%E6%80%BB/</guid>
      <description>网络防火墙 放通20000到30000之间的端口连接 在 Linux 中放通 20000 到 30000 之间的端口连接，可以通过修改防火墙规则实现。
以下是通过 iptables 命令添加规则的步骤：
打开终端，并以管理员权限登录系统； 输入以下命令以列出当前的防火墙规则： iptables -L 如果已存在 DROP 或 REJECT 策略，则需要添加允许策略。输入以下命令以添加策略： iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT 输入以下命令以开放端口： iptables -A INPUT -p tcp --dport 20000:30000 -j ACCEPT 这条命令将允许从任何来源 IP 地址访问在 20000 到 30000 范围内的 TCP 端口。如果需要允许 UDP 端口，请将 -p tcp 改为 -p udp。
最后保存规则，输入以下命令以使之生效： iptables-save &amp;gt; /etc/sysconfig/iptables 以上命令将当前的防火墙规则保存到 /etc/sysconfig/iptables 文件中。这样也可以保证在系统重启后该规则依然有效。
查看端口占用 lsof -i :28081 性能 查看整体配置 查看CPU信息：cat /proc/cpuinfo 查看内存信息：cat /proc/meminfo 查看硬盘信息：sudo fdisk -l 查看网络设备信息：ifconfig -a 查看系统版本信息：uname -a 查看CPU/内存使用情况 实时</description>
    </item>
    
    <item>
      <title>Linux快速配置MySQL&amp;Redis指引</title>
      <link>https://yuyoung32.github.io/post/linux%E5%BF%AB%E9%80%9F%E9%85%8D%E7%BD%AEmysqlredis%E6%8C%87%E5%BC%95/</link>
      <pubDate>Sun, 23 Apr 2023 15:56:47 +0800</pubDate>
      
      <guid>https://yuyoung32.github.io/post/linux%E5%BF%AB%E9%80%9F%E9%85%8D%E7%BD%AEmysqlredis%E6%8C%87%E5%BC%95/</guid>
      <description>安装与配置MySQL 安装 ubuntu
apt update apt install mysql-server systemctl start mysql systemctl status mysql 修改与设置root密码 mysql -u root -p 进入MySQL命令行后
ALTER USER &amp;#39;root&amp;#39;@&amp;#39;localhost&amp;#39; IDENTIFIED WITH mysql_native_password BY &amp;#39;yourpassword&amp;#39;; FLUSH PRIVILEGES; exit; 再次使用mysql -u root -p进入验证密码是否已经更改。
设置外网可访问 修改配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf 修改端口【可选】，修改防止简单被猜到。
port = 23306 修改绑定IP为全部网卡。
注释掉bind-address
#bind-address = 127.0.0.1 重启服务
systemctl restart mysql 查看是否成功
netstat -an | grep 23306 修改权限
登陆
mysql -u root -p mysql&amp;gt; use mysql; 查询
mysql&amp;gt; select user,host from user; 修改</description>
    </item>
    
  </channel>
</rss>
