初始化脚本(Os_Init_Optimization.sh)

#!/bin/bash

#解压缩startup.tar.gz包
cd /tmp && tar -zxf startup.tar.gz

#初始化YUM源
rm -rf /etc/yum.repos.d/*
cp -ap ./file/*.repo /etc/yum.repos.d/
/bin/rpm --import ./file/RPM-GPG-KEY.dag.txt
/bin/rpm --import ./file/RPM-GPG-KEY-CentOS-6
/usr/bin/yum clean all
/usr/bin/yum makecache

#下载工具及时间同步工具
/usr/bin/yum install -y wget
/usr/bin/yum install -y ntp
ntpdate -d cn.pool.ntp.org
date

echo "##### update server time #####" >> /var/spool/cron/root
echo "*/10 * * * * /usr/sbin/ntpdate cn.pool.ntp.org > /dev/null 2>&1 && /sbin/clock -w > /dev/null 2>&1" >> /var/spool/cron/root
echo "" >> /var/spool/cron/root
echo "##### history #####" >> /var/spool/cron/root
echo "*/5 * * * * /usr/local/gacp/worksh/history.sh > /dev/null 2>&1" >> /var/spool/cron/root
echo "" >> /var/spool/cron/root
echo "##### Logs #####" >> /var/spool/cron/root
echo "00 00 * * * /usr/local/gacp/worksh/del_100day_before_logs.sh > /dev/null 2>&1" >> /var/spool/cron/root
echo "00 00 * * * /usr/local/gacp/worksh/log_rotate.sh > /dev/null 2>&1" >> /var/spool/cron/root
echo "" >> /var/spool/cron/root

#下载必要系统工具
/usr/bin/yum install -y lsof htop nmap iotop telnet iptraf iftop vim-enhanced logrotate ntsysv bind-utils sysstat irqbalance microcode_ctl dstat net-snmp rsync openssh-clients

#selinux is disabled
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
echo "selinux is disabled,you must reboot!"

#vim
sed -i "8 s/^/alias vi='vim'/" /root/.bashrc
sed -i "9 s/^/alias dstat='dstat -cdlmnpsy'\n/" /root/.bashrc
sed -i "10 s/^/alias grep='grep --color=auto'\n\n/" /root/.bashrc
echo 'syntax on' > /root/.vimrc

source ~/.bashrc

mv /etc/security/limits.d/90-nproc.conf /etc/security/limits.d/90-nproc

#file size
echo 'ulimit -SHn 65535' >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
*                     soft     nofile             60000
*                     hard     nofile             65535
EOF

#sysctl.conf
cat >> /etc/sysctl.conf <<eof

# NEW ADD
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_max_tw_buckets = 65535

net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 131070
net.core.somaxconn = 20480
eof

/sbin/sysctl -p

#init
for sun in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 2345 $sun off;done
for sun in crond irqbalance network sysstat sshd rsyslog iptables;do chkconfig --level 2345 $sun on;done

DATE=`date +%Y%m%H`

#add lsyw user
/usr/sbin/useradd lsyw
echo "lishen@123" | passwd lsyw --stdin

#ssh
ssh_cf="/etc/ssh/sshd_config"

cp $ssh_cf $ssh_cf.$DATE
sed -i "s/#Port 22/Port 50000/" $ssh_cf
sed -i "s/#UseDNS yes/UseDNS no/" $ssh_cf
sed -i "/X11Forwarding yes/d" $ssh_cf
sed -i "s/#X11Forwarding no/X11Forwarding no/g" $ssh_cf
sed -i "s/#PrintMotd yes/PrintMotd no/g" $ssh_cf
sed -i "s/#PrintLastLog yes/PrintLastLog no/g" $ssh_cf
sed -i 's/^#PermitRootLogin yes/PermitRootLogin no/' $ssh_cf
sed -i '$aAllowUsers lsyw' $ssh_cf
/etc/init.d/sshd reload

#iptables添加规则放通50000端口
sed -i '/dport 22/{ s/22/50000/g }' /etc/sysconfig/iptables
/etc/init.d/iptables reload

#清空信息信息为了安全
ISSUE=/etc/issue
ISSUE_NET=/etc/issue.net
RELEASE=/etc/redhat-release

cp $ISSUE $ISSUE.$DATE
cp $ISSUE_NET $ISSUE_NET.$DATE
cp $RELEASE $RELEASE.$DATE

>$ISSUE
>$ISSUE_NET
>$RELEASE

#snmp
snmp_cf="/etc/snmp/snmpd.conf"
cp $snmp_cf $snmp_cf.$DATE
rm -rf $snmp_cf
cp -a ./etc/snmpd.conf $snmp_cf

#deluser
userdel uucp
userdel operator
userdel games
userdel gopher
userdel ftp

#防爆破登录
yum install -y fail2ban

mv /etc/fail2ban/jail.conf /etc/fail2ban/jail.conf.$DATE
cp -ap ./file/jail.conf /etc/fail2ban/

mkdir /usr/local/gacp/worksh -p
cp -ap ./file/history.sh ./file/log_rotate.sh ./file/del_100day_before_logs.sh /usr/local/gacp/worksh/

转载于:https://www.cnblogs.com/zhaojonjon/p/5830503.html

# 定义一个类,表示 Critic 网络 class CriticNetwork(object): def __init__(self, sess, state_dim, learning_rate): # 初始化 Critic 网络的一些参数 self.sess = sess self.s_dim = state_dim self.lr_rate = learning_rate # 创建 Critic 网络 self.inputs, self.out = self.create_critic_network() # 获取 Critic 网络中所有的参数 self.network_params = tf.compat.v1.get_collection(tf.compat.v1.GraphKeys.TRAINABLE_VARIABLES, scope='critic') # 定义一个占位符,表示 Critic 网络的输入参数 self.input_network_params = [] for param in self.network_params: self.input_network_params.append(tf.compat.v1.placeholder(tf.float32, shape=param.get_shape())) # 定义一个操作,用于设置 Critic 网络的所有参数 self.set_network_params_op = [] for idx, param in enumerate(self.input_network_params): self.set_network_params_op.append(self.network_params[idx].assign(param)) # 定义一个占位符,表示 Critic 网络的目标输出 self.td_target = tf.compat.v1.placeholder(tf.float32, [None, 1]) # 计算 Critic 网络的 Temporal Difference self.td = tf.subtract(self.td_target, self.out) # 定义 Critic 网络的损失函数,使用均方误差 self.loss = tflearn.mean_square(self.td_target, self.out) # 计算 Critic 网络的梯度 self.critic_gradients = tf.gradients(self.loss, self.network_params) # 定义 Critic 网络的优化器 self.optimize = tf.compat.v1.train.RMSPropOptimizer(self.lr_rate).apply_gradients(zip(self.critic_gradients, self.network_params))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值