服务器功耗计算器。

华为服务器功耗计算
https://info.support.huawei.com/computing/ftpa/

浪潮服务器功耗计算
https://www.inspur.com/lcjtww/ghjsq11/index.html

华3服务器功耗计算
https://iconfig-chl.h3c.com/iconfig/PowerCalIndex

戴尔服务器功耗计算
https://dell-ui-eipt.azurewebsites.net/

联想服务器功耗计算
https://download.lenovo.com/servers/lnvgy_sw_capacity_v1.5.9_anyos_32-64/start.html

ansible常用模块

1、command

command 作为 Ansible 的默认模块,可以运行远程权限范围所有的 shell 命令,不支持管道符。

ansible Client -m command -a "free -m"

2、script

远程执行本地脚本
script 的功能是在远程主机执行主控端存储的 shell 脚本文件,相当于 scp + shell 组合。

ansible all -m script -a "/home/test.sh 12 34

3、shell

shell模块基本和command相同,但是shell支持管道符

ansible Client -m shell -a "/home/test.sh" 

4、copy模块

向 Client 组中主机拷贝 test.sh 到 /tmp 下,属主、组为 root ,权限为 0755,src为本地目录,dest目标路径

ansible all -m copy -a "src=/home/test.sh dest=/tmp/ owner=root group=root mode=0755"  

5、stat模块-获取远程文件状态信息

ansible all -m st   at -a "path=/etc/syctl.conf"

6、get_url 实现在远程主机下载指定URL到本地,支持sha256sum文件校验

ansible all -m get_url -a "url=http://www.baidu.com dest=/tmp/index.html mode=0440 force=yes"

7、yum 软件包管理

ansible all -m yum -a "name=curl state=latest"

8、corn 远程控制住进得crontab配置

ansible all -m cron -a "name='check dirs' hour='5,2' job='ls -alh > /dev/null'"

9、mount 远程主机分区挂载

ansible all -m mount -a "name=/mnt/data src=/dev/sd0 fstype=ext4 opts=ro state=present"

10、service 远程主机系统服务管理

ansible all -m service -a "name=nginx state=stoped"
ansible all -m service -a "name=nginx state=restarted"
ansible all -m service -a "name=nginx state=reloaded"

11、user 远程主机用户管理

ansible all -m user -a "name=wang comment='user wang'"
ansible all -m user -a "name=wang state=absent remove=yes" #添加删除用户

Centos7.9安装SQL Server 2019

准备工作
操作系统:Centos7.9 内存:4G 硬盘:40G CPU:2U
SQL Server版本:SQL Server 2019
软件安装包:下载地址

关闭SELinux

sed -i '/^SELINUX/s/enforcing/disabled/g' /etc/selinux/config && setenforce 0

添加软件源&保留原有网络源

curl https://packages.microsoft.com/config/rhel/7/prod.repo -o /etc/yum.repos.d/msprod.repo

安装依赖包

yum -y install mssql-tools unixODBC-devel bzip2 gdb libsss_nss_idmap cyrus-sasl cyrus-sasl-gssapi

安装SQL Server2019
下载文章上面提供的SQL Server2019,上传到服务器并安装

rpm -ivh mssql-server-15.0.4003.23-3.x86_64.rpm

运行初始化配制

/opt/mssql/bin/mssql-conf setup 
usermod: no changes
Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID) - CPU Core utilization restricted to 20 physical/40 hyperthreaded
  7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum
  8) I bought a license through a retail sales channel and have a product key to enter.

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=2109348&clcid=0x409

Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.

Enter your edition(1-8): 3      #这里选择了Express版本
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=2104294&clcid=0x409

The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409

Do you accept the license terms? [Yes/No]:Yes   #输入Yes接受许可条目

Enter the SQL Server system administrator password:         #设置SA管理员密码
Confirm the SQL Server system administrator password: 
Configuring SQL Server...

The licensing PID was successfully processed. The new edition is [Express Edition].
ForceFlush is enabled for this instance. 
ForceFlush feature is enabled for log durability.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.

添加环境变量

echo 'export PATH=$PATH:/opt/mssql-tools/bin' > /etc/profile.d/mssql.sh
source !$
source /etc/profile.d/mssql.sh

防火墙添加服务

firewall-cmd --permanent --add-service=mssql 
firewall-cmd --zone=public --add-port=1433/tcp --permanent
firewall-cmd --reload

命令行工具连接测试

sqlcmd -S localhost -U sa
Password:      #输入密码

Centos7 创建NFS服务&客户端挂载

Centos7 创建NFS服务&客户端挂载


服务端操作:

1、安装NFS服务

yum -y install rpcbind nfs-utils

2、创建共享目录并赋予权限

mkdir /data/
chmod 777 -R /data

3、配置NFS文件目录&客户端IP

vi /etc/exports

/data 10.127.0.53(rw,no_root_squash,no_all_squash,sync)
/data 10.127.0.54(rw,no_root_squash,no_all_squash,sync)
/data 10.127.0.55(rw,no_root_squash,no_all_squash,sync)
/data 10.127.0.XXX(rw,no_root_squash,no_all_squash,sync)
  • rw 表示设置目录可读写。
  • sync 表示数据会同步写入到内存和硬盘中,相反 rsync 表示数据会先暂存于内存中,而非直接写入到硬盘中。
  • no_root_squash NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,也拥有root权限。
  • no_all_squash 不论NFS客户端连接服务端时使用什么用户,对服务端分享的目录来说都不会拥有匿名用户权限。

使配置立即生效

exportfs -r

4、设置防火墙

检查防火墙状态

systemctl status firewalld.service

如果是关闭状态则不需要做如下配置,否则需要打开这部分端口;

  1. NFS服务的端口配置文件 修改/etc/sysconfig/nfs文件,将下列内容的注释去掉,如果没有则添加
    vi /etc/sysconfig/nfs

    RQUOTAD_PORT=1001
    LOCKD_TCPPORT=30001
    LOCKD_UDPPORT=30002
    MOUNTD_PORT=1002
  2. 保存好后,将端口加入到防火墙允许策略中。执行:
    firewall-cmd --zone=public --add-port=111/tcp --add-port=111/udp --add-port=2049/tcp --add-port=2049/udp --add-port=1001/tcp --add-port=1001/udp --add-port=1002/tcp --add-port=1002/udp --add-port=30001/tcp --add-port=30002/udp --permanent

  3. 重新加载防火墙
    firewall-cmd --reload

5、启动服务

按顺序启动rpcbind和nfs服务

systemctl start rpcbind
systemctl start nfs

加入开机启动:

systemctl enable rpcbind
systemctl enable nfs


客户端操作:

1、安装NFS服务

yum -y install nfs-utils rpcbind

2、查看服务端已共享的目录

showmount -e 10.127.0.52 ##10.127.0.52为服务端IP

3、建立挂载目录,执行挂载命令:

mkdir /data
mount -t nfs4 10.127.0.52:/data /data

如果要解除挂载,可执行命令:
umount /data

4、开机自动挂载

vi /etc/fstab

10.127.0.52:/data /data nfs4 rw,tcp,intr 0 1

保存,通过mount&umount测试;最后重启测试

Centos搭建企业YUM仓库

Centos

一、源服务器的系统环境。最小化安装

[root@yumserver ~]#cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

源服务器IP地址:192.168.0.200

二、放开系统防火墙,关闭selinux

[root@yumserver ~]#firewall-cmd --add-port=80/tcp --permanent
success
[root@yumserver ~]# firewall-cmd --reload
success

[root@yumserver ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted – Targeted processes are protected,
# minimum – Modification of targeted policy. Only selected processes are protected.
# mls – Multi Level Security protection.
SELINUXTYPE=targeted

三.添加阿里云yum源并检查

备份好原系统的repo

[root@yumserver ~]#cd /etc/yum.repos.d
[root@yumserver ~]#mkdir backup
[root@yumserver yum.repos.d]# mv *.repo backup/

下载阿里云repo

[root@yumserver yum.repos.d]#curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@yumserver yum.repos.d]#curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@yumserver yum.repos.d]#yum makecache
[root@yumserver yum.repos.d]#yum repolist

四.安装相关软件

yum install -y wget make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel httpd yum-utils createrepo

注释:

  • yum-utils:reposync同步工具
  • createrepo:编辑yum库工具
  • httpd:通过Apache软件提供web服务,也可以使用nginx

五、同步阿里云yum源软件包到本地服务器指定目录

/mirror(自定义目录)

[root@yumserver ~]#mkdir -p /mirror
[root@yumserver ~]#chown -R apache:apache /mirror
[root@yumserver ~]#chmod -R 755 /mirror
[root@yumserver ~]#reposync -n --repoid=extras --repoid=updates --repoid=base --repoid=epel -p /mirror

参数注释:-n指下载最新软件包,-p指定目录,指定本地的源--repoid(如果不指定就同步本地服务器所有的源),下载过程比较久

六.创建仓库索引

[root@yumserver ~]#createrepo -po /mirror/base/ /mirror/base/
[root@yumserver ~]#createrepo -po /mirror/extras/ /mirror/extras/
[root@yumserver ~]#createrepo -po /mirror/updates/ /mirror/updates/
[root@yumserver ~]#createrepo -po /mirror/epel/ /mirror/epel/

七.更新数据源

[root@yumserver ~]#createrepo --update /mirror/base/
[root@yumserver ~]#createrepo --update /mirror/extras/
[root@yumserver ~]#createrepo --update /mirror/updates/
[root@yumserver ~]#createrepo --update /mirror/epel/

八.启动并配置Apache服务

[root@yumserver ~]#systemctl start httpd
[root@yumserver ~]#systemctl enable httpd
[root@yumserver ~]#systemctl status httpd
[root@yumserver ~]#vim /etc/httpd/conf/httpd.conf

DocumentRoot "/mirror/"
<Directory "/mirror/">
Options Indexes FollowSymLinks
AllowOverride  None
Order allow,deny
Allow from all
Require all granted
</Directory>

九.编写yum源客户端配置文件

[root@yumserver repo]#vim /mirror/repo/CentOS-Base.repo

[base]
name=CentOS- - Base - 192.168.0.200
failovermethod=priority
baseurl=http://192.168.0.200/base/
enable=1
gpgcheck=0
[updates]
name=CentOS- - Updates - 192.168.0.200
failovermethod=priority
baseurl=http://192.168.0.200/updates/
enable=1
gpgcheck=0
[extras]
name=CentOS- - Extras - 192.168.0.200
failovermethod=priority
baseurl=http://192.168.0.200/extras/
enable=1
gpgcheck=0
[epel]
name=CentOS- - Epel - 192.168.0.200
failovermethod=priority
baseurl=http://192.168.0.200/epel/
enable=1
gpgcheck=0

十.客户端配置yum源

用户可以浏览器访问192.168.0.200查看配置客户端yum源的方法

[root@servera ~]#curl -o /etc/yum.repos.d/CentOS-Base.repo http:/ /192.168.0.200/repo/CentOS-Base.repo
[root@servera ~]#yum makecache

十一.设置定时同步yum源的任务

[root@yumserver ~]#vim /mirror/script/centos_yum_update.sh

#!/bin/bash
echo 'Updating Aliyum Source'
DATETIME=`date +%F_%T`
exec > /var/log/aliyumrepo_$DATETIME.log
reposync -np /mirror
if [ $? -eq 0 ];then
createrepo --update /mirror/base
createrepo --update /mirror/extras
createrepo --update /mirror/updates
createrepo --update /mirror/epel
echo "SUCESS: $DATETIME aliyum_yum update successful"
else
echo "ERROR: $DATETIME aliyum_yum update failed"
fi

添加定时任务,每周一凌晨1点执行添加定时任务,每周一凌晨1点执行

[root@yumserver ~]#crontab -l
0 1 1 /bin/bash /mirror/script/centos_yum_update.sh