我对 Ubuntu 中的脚本编写还有些陌生,我正在执行以下脚本,但收到“权限被拒绝”消息。任何帮助都非常感谢!
具体顺序如下:
剧本:
!/tm/local/bin/bash
blockdev --setra 16384 /dev/sd[bcdefghijkl]
echo 1024 > /sys/block/sdb/queue/read_ahead_kb
echo 1024 > /sys/block/sdc/queue/read_ahead_kb
echo 1024 > /sys/block/sdd/queue/read_ahead_kb
echo 1024 > /sys/block/sde/queue/read_ahead_kb
echo 1024 > /sys/block/sdf/queue/read_ahead_kb
echo 1024 > /sys/block/sdg/queue/read_ahead_kb
echo 1024 > /sys/block/sdh/queue/read_ahead_kb
echo 1024 > /sys/block/sdi/queue/read_ahead_kb
echo 1024 > /sys/block/sdj/queue/read_ahead_kb
echo 1024 > /sys/block/sdk/queue/read_ahead_kb
echo 256 > /sys/block/sdb/queue/nr_requests
echo 256 > /sys/block/sdc/queue/nr_requests
echo 256 > /sys/block/sdd/queue/nr_requests
echo 256 > /sys/block/sde/queue/nr_requests
echo 256 > /sys/block/sdf/queue/nr_requests
echo 256 > /sys/block/sdg/queue/nr_requests
echo 256 > /sys/block/sdh/queue/nr_requests
echo 256 > /sys/block/sdi/queue/nr_requests
echo 256 > /sys/block/sdj/queue/nr_requests
echo 256 > /sys/block/sdk/queue/nr_requests
# Set read-ahead.
echo "Setting read-ahead to 64 MiB for /dev/md0"
blockdev --setra 65536 /dev/md0
# Set stripe-cache_size for RAID6.
echo "Setting stripe_cache_size to 16 MiB for /dev/md0"
echo 16384 > /sys/block/md0/md/stripe_cache_size
echo 8192 > /sys/block/md0/md/stripe_cache_active
# Disable NCQ on all disks.
echo "Disabling NCQ on all disks..."
echo 1 > /sys/block/sdb/device/queue_depth
echo 1 > /sys/block/sdc/device/queue_depth
echo 1 > /sys/block/sdd/device/queue_depth
echo 1 > /sys/block/sde/device/queue_depth
echo 1 > /sys/block/sdf/device/queue_depth
echo 1 > /sys/block/sdg/device/queue_depth
echo 1 > /sys/block/sdh/device/queue_depth
echo 1 > /sys/block/sdi/device/queue_depth
echo 1 > /sys/block/sdj/device/queue_depth
echo 1 > /sys/block/sdk/device/queue_depth
我授予每个人执行权限如下:
chmod a+x /home/tm/raid-sync.sh
我像这样执行它:
root@LSERVER:~# sh /home/tm/raid-sync.sh
它返回的是:
/home/tm/raid-sync.sh: 1: /home/tm/raid-sync.sh: !/tm/local/bin/bash: not found
Setting read-ahead to 64 MiB for /dev/md0
Setting stripe_cache_size to 16 MiB for /dev/md0
/home/tm/raid-sync.sh: 29: /home/tm/raid-sync.sh: cannot create /sys/block/md0/md/stripe_cache_active: Permission denied
Disabling NCQ on all disks...
答案1
答案2
您的第一行似乎有错误。(从您的错误可以看出),我将首先修复它,也许将其更改为
#!/bin/bash
然后再试一次,我们可以看看下一个错误