From:
如何匯出&匯入DHCP Server領域中的保留區資料
關鍵:
1.匯出
netsh dhcp server serverip scope scopeip dump > C:\reserve.txt
2.匯入
最後再把該文字檔copy到你的總公司DHCP Server上面..然後進行下面的動作匯入 (匯入前請先將DHCP Server進行備份以防萬一)
netsh exec C:\reserve.txt
From:
關鍵:
1.匯出
netsh dhcp server serverip scope scopeip dump > C:\reserve.txt
2.匯入
最後再把該文字檔copy到你的總公司DHCP Server上面..然後進行下面的動作匯入 (匯入前請先將DHCP Server進行備份以防萬一)
netsh exec C:\reserve.txt
SELECT r.scheduler_id as 排程器識別碼,
status as 要求的狀態,
r.session_id as SPID,
r.blocking_session_id as BlkBy,
substring(
ltrim(q.text),
r.statement_start_offset/2+1,
(CASE
WHEN r.statement_end_offset = -1
THEN LEN(CONVERT(nvarchar(MAX), q.text)) * 2
ELSE r.statement_end_offset
END - r.statement_start_offset)/2)
AS [正在執行的 T-SQL 命令],
r.cpu_time as [CPU Time(ms)],
r.start_time as [開始時間],
r.total_elapsed_time as [執行總時間],
r.reads as [讀取數],
r.writes as [寫入數],
r.logical_reads as [邏輯讀取數],
-- q.text, /* 完整的 T-SQL 指令碼 */
d.name as [資料庫名稱]
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS q
LEFT JOIN sys.databases d ON (r.database_id=d.database_id)
WHERE r.session_id > 50 AND r.session_id <> @@SPID
ORDER BY r.total_elapsed_time desc
補充:而在我管理的SQL Server2000系統裡, 執行時間超過30分鐘的進程都時常會出現。
從那篇文章裡學到可以從[master].[dbo].[sysprocesses]裡獲取,阻塞並且等待時間是1800秒(30分鐘)的進程信息:
select * from
[master].[dbo].[sysprocesses]
where blocked > 0 and waittime >1800
yum -y install nano zip unzip libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
vi /etc/httpd/conf.d/redmine.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.53
PassengerDefaultRuby /usr/bin/ruby
</IfModule>
RailsBaseURI /redmine
<Directory /var/www/redmine/public>
# This relaxes Apache security settings.
AllowOverride all
Options -MultiViews
</Directory>
在DocumentRoot的路徑下加上redmine的symbolic linkln -s /var/www/redmine/public /var/www/html/redmine
這個設定過程很重要,因為 redmine 官方只提供了以 virtual host 的方式跟 apache 整合,但我們希望用 http://localhost/redmine/ 的網址方式,連結 redmine,努力兩天後,得到上面的解決方案。インストール
“SELinuxを無効にする”の項は無視し、SELinuxをPermissiveモード(監視はするがアクセス制御はしない)にします。
以降、最新版インストールガイド に従い、Redmineを構築します。
1setenforce 0
SELinuxの有効化と権限の付与
Redmineを構築し終えたら、以下のコマンドを実行します。
Redmineのルートフォルダに対して「httpd_tというラベル付けがされたファイルから読み出される権限」を適用し、httpdによるファイルへの書き込み許可を設定しています。
1 2chcon -R -t httpd_sys_content_t /var/www/redmine/ setsebool -P httpd_unified on
最後に、SELinuxをEnforcingモードに戻します。
以上です。
1setenforce 1
因為LDAP帶來的資料有中文(或者輸入資料有中文問題),需要使用utf-8編碼,但是會遇到index太長的問題# grep PassengerAgent /var/log/audit/audit.log | audit2allow -M passengeragent # semodule -i passengeragent.pp # grep ruby /var/log/audit/audit.log | audit2allow -M ruby # semodule -i ruby.pp # grep utils.rb:108 /var/log/audit/audit.log | audit2allow -M utils # semodule -i utils.pp
得出的結論是:對於創建innodb的組合索引,如果各個列中的長度不超過767,則不再計算所有列的總長度,如果有超過767的,則給出報警,索引最後 創建成功,但是對於超過767字節的列取前綴索引;對於innodb的單列索引,超過767的,給出warning,最終索引創建成功,取前綴索引(取前 255字節)解決方式:http://se-suganuma.blogspot.tw/2014/02/ruby-redmine-unicorninstallalminium.html
# vi /etc/my.cnf無事完了。
# for Redmine# /etc/rc.d/init.d/mysqld restart
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix
# vi config/initializers/adapt_utf8mb.rb
ActiveSupport.on_load :active_record doTry Again
module ActiveRecord::ConnectionAdapters
class AbstractMysqlAdapter
def create_table_with_innodb_row_format(table_name, options = {})
table_options = options.reverse_merge(:options => 'ENGINE=InnoDB ROW_FORMAT=DYNAMIC')
create_table_without_innodb_row_format(table_name, table_options) do |td|
yield td if block_given?
end
end
alias_method_chain :create_table, :innodb_row_format
end
end
end
# RAILS_ENV=production bundle exec rake db:migrate
# Install dependencies (On Debian/Ubuntu) root# apt-get install build-essential libssh2-1 libssh2-1-dev cmake libgpg-error-dev # Install dependencies (On Fedora/CentoS/RedHat) root# yum groupinstall "Development Tools" root# yum install libssh2 libssh2-devel cmake libgpg-error-devel
.........# Switch user root# su - redmine # First git clone Bootstrap Kit redmine$ cd REDMINE_ROOT/plugins redmine$ git clone https://github.com/jbox-web/redmine_bootstrap_kit.git redmine$ cd redmine_bootstrap_kit/ redmine$ git checkout 0.2.3 # Then Redmine Git Hosting plugin redmine$ cd REDMINE_ROOT/plugins redmine$ git clone https://github.com/jbox-web/redmine_git_hosting.git redmine$ cd redmine_git_hosting/ redmine$ git checkout 1.1.4 # Install gems and migrate database redmine$ cd REDMINE_ROOT redmine$ bundle install --without development test redmine$ bundle exec rake redmine:plugins:migrate RAILS_ENV=production NAME=redmine_git_hosting
出于安全的考虑,我们最好限制用户只能进行git push/pull,但无法登陆。这可以使用git-shell来完成。
- cp -Rf /usr/local/share/git-XXXX/contrib/git-shell-commands .
- # 再來改變權限
- chown -R git: git-shell-commands/
- chmod +x git-shell-commands/help
- chmod +x git-shell-commands/list
PS:selinux 再補充
The測試結果:殘念.....XD not working..passenger_temp_diroption (Nginx) and thePassengerTempDiroption (Apache) have been replaced by two config options. On Nginx they arepassenger_instance_registry_dirandpassenger_data_buffer_dir. On Apache they arePassengerInstanceRegistryDirandPassengerDataBufferDir. On Apache,PassengerUploadBufferDirhas been replaced byPassengerDataBufferDir.
My repository seems empty but I’m sure it is not!
Agit cloneof the repository gives me files!
root$ su - redmine redmine$ cd REDMINE_ROOT redmine$ bundle exec rake redmine_git_hosting:fetch_changesets RAILS_ENV=production
yum -y install mariadb mariadb-server mariadb-libsyum -y install httpd mod_dav_svnyum -y install php php-bcmath php-cli php-common php-enchant
php-gd php-intl php-ldap php-mbstring php-mysql php-pdo php-pear
php-process php-pspell php-recode php-soap php-xml php-xmlrpc
rrdtool-php uuid-php php-pecl-memcache php-develmkdir /usr/share/fonts/truetypewget http://www.study-area.org/apt/firefly-font/fireflysung-1.3.0.tar.gz
tar xvzf fireflysung-1.3.0.tar.gz
cp fireflysung-1.3.0/fireflysung.ttf /usr/share/fonts/truetype/arial.ttf=====================================chcon -R -t httpd_sys_rw_content_t /var/www/html/mantis
setsebool -P httpd_can_sendmail on
setsebool -P httpd_can_network_connect on
chcon -R --reference /var/www/html/mantis /usr/share/fonts
PS:解決SYSTEM WARNING: 'opendir(/var/www/html/mantis/plugins/): failed to open dir: Permission denied' in
=====================================#mv admin admin-old
PS:web提示安全性問題
使用ADsiedit來找AD資訊,後來改用ldp.exe查資料 # 檔案上傳設定
$g_allow_file_upload = ON; # 允許上傳檔案
$g_max_file_size = 20000000; # 設定上傳檔案的大小限制 (最大20M), 除此之外, 前面章節的 php.ini 亦需有相對應的設定
$g_file_upload_max_num = 10; # 最多可同時上傳10個檔案
$g_file_upload_method = DATABASE; # 上傳檔案放置的位置為資料庫. 若想放在 File System, 則設為 DISK
$g_absolute_path_default_upload_folder = '/var/www/html/mantis/attachment'; # 上傳檔案的目錄, $g_file_upload_method = DISK 時需要設定
$g_preview_attachments_inline_max_size = 5120000; # 超過 512KB 的圖形檔不允許預覽
# 打開 Time Tracking 功能 (負責解決 Issue 的人可以輸入處理 Issue 所耗的工時)
$g_time_tracking_with_billing = ON;
$g_time_tracking_enabled = ON;
$g_time_tracking_stopwatch = ON;
$g_time_tracking_view_threshold = DEVELOPER;
$g_time_tracking_edit_threshold = DEVELOPER;
$g_time_tracking_reporting_threshold = MANAGER;
$g_time_tracking_without_note = OFF;
# 其他設定
#$g_path = 'http://webproject.axman.com.tw/mantis/'; # 網址
$g_max_failed_login_count = 5; # 登入失敗最多五次, 超過鎖帳 (Mantis 的帳號)
$g_show_version = OFF; # 不要顯示 Mantis 版本 (網路安全考慮)
$g_default_language = 'english'; # 新建立的使用者預設語系 (若要改為中文則設定為 'chinese_traditional')
$g_window_title = ' <顯示在瀏覽器上方的文字>'; # 瀏覽器標題顯示的文字
$g_show_realname = ON; # 顯示使用者的顯示名稱 (預設是顯示登入帳號, 通常是一串難記的號碼)
$g_short_date_format = 'Y/m/d'; # 短日期格式
$g_normal_date_format = 'Y/m/d H:i'; # 一般日期格式
$g_complete_date_format = 'Y/m/d H:i'; # 長日期格式
$g_default_language = 'chinese_traditional'; ##預設繁體中文
注意一點:
只要用 Windows Domain 的帳號與密碼登入, Mantis 會自動建立新的使用者, 並賦予 Reporter 的權限, 因此不需要 Administrator 再手動建立. 惟若有專案的需要比較高的機密, 則該專案應該設定為 "非公開", 並明確指定哪些帳號才有權限, 以避免任意的 Domain User 登入後都可以看到所有專案的內容
semodule -i mysemanage.pp
SELinux errors are logged to syslog by default in Cenntos they are logged to the following file locations:其中audit2allow在setroubleshoot套件中
- /var/log/audit/audit.log
- /var/log/messages
chcon
傳統的 chmod 指令是用來設定檔案或目錄的權限的,而同樣的 chcon 指令則是用來設定 SELinux 對檔案或目錄的 content 標籤的
產生 SELinux 允許的政策模組。 [root@ip180 ~]# audit2allow -a -M mycertwatch ******************** IMPORTANT *********************** To make this policy package active, execute: semodule -i mycertwatch.pp查看產生的模組。 [root@ip180 ~]# ll mycertwatch* -rw-r--r--. 1 root root 885 Jul 1 09:39 mycertwatch.pp -rw-r--r--. 1 root root 211 Jul 1 09:39 mycertwatch.te加入新產生的 SELinux 政策模組。 [root@ip180 ~]# semodule -i mycertwatch.pp查詢 SELinux 模組 [root@ip180 ~]# semodule -l | grep mycert mycertwatch 1.0上述的政策允許某一拒絕,執行時可能還會出現新的拒絕。依同樣的方式再做一次,直到可以為止。 [root@ip180 ~]# audit2allow -a -M mycertwatch2 ******************** IMPORTANT *********************** To make this policy package active, execute: semodule -i mycertwatch2.pp [root@ip180 ~]# semodule -i mycertwatch2.pp
public abstract class ServerObject {
protected final static HashMap<String,Thread> threadPoolHashMap=new HashMap<String, Thread>();
protected final static HashMap<String,Object> threadPoolSessionObjectHashMap=new HashMap<String, Object>();
protected Transaction tx;
protected org.hibernate.Session Hibernatesession;
protected void reloadProperty() throws FileNotFoundException, IOException {
Hibernatesession=(Session) threadPoolSessionObjectHashMap.get(Thread.currentThread().getName()+"hibernate-session");
tx= (Transaction) threadPoolSessionObjectHashMap.get(Thread.currentThread().getName()+"hibernate-transaction");
}
}
Hibernatesession = HibernateSessionFactory.getSession();
threadPoolSessionObjectHashMap.put(Thread.currentThread().getName()+"hibernate-session", Hibernatesession);
tx = Hibernatesession.beginTransaction();
threadPoolSessionObjectHashMap.put(Thread.currentThread().getName()+"hibernate-transaction", tx);
yum install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | shvi ~/.zshrc
ZSH_THEME="ys"
plugins=(git textmate ruby autojump osx mvn gradle)
[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u
bindkey -s "^[Op" "0"
bindkey -s "^[On" "."
bindkey -s "^[Oq" "1"
bindkey -s "^[Or" "2"
bindkey -s "^[Os" "3"
bindkey -s "^[Ot" "4"
bindkey -s "^[Ou" "5"
bindkey -s "^[Ov" "6"
bindkey -s "^[Ow" "7"
bindkey -s "^[Ox" "8"
bindkey -s "^[Oy" "9"
bindkey -s "^[Ol" "+"
bindkey -s "^[Om" "-"
for pietty:(not working............)
option-->detail-->
Terminal -> Keyboard"The Function keys and keypad"
When I copy some code from webpages and paste it to VIM,I find it becomes a mess style like a ladder as follows
Since it messed so regularly so I think maybe there's something wrong with myxxxxxx xxxxxx xxxxxx xxxxxxxxxx.vimrcwhich is as below:
Do this before:
Then after::set paste
:set nopaste
Installation:change to:
1) compile the source using:
Code:gcc -o maillog_watcher maillog_watcher.c -lpthread
2) move the executable and the maillog_watcher_read.sh file to /opt/maillog_watcher/
3) add the following lines to your snmpd.conf
Code:exec .1.3.6.1.4.100.2 maillog_received /opt/maillog_watcher/maillog_watcher_read.sh received
exec .1.3.6.1.4.100.4 maillog_sent /opt/maillog_watcher/maillog_watcher_read.sh sent
exec .1.3.6.1.4.100.5 maillog_virus /opt/maillog_watcher/maillog_watcher_read.sh virus
exec .1.3.6.1.4.100.6 maillog_spam /opt/maillog_watcher/maillog_watcher_read.sh spam
exec .1.3.6.1.4.100.7 maillog_rejected /opt/maillog_watcher/maillog_watcher_read.sh rejected
4) for logrotate to work, modify your /etc/logrotate.d/syslog file to send a HUP signal to maillog_watcher. mine looks like this:
Code:/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
/bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
/bin/kill -HUP `cat /var/run/maillog_watcher.pid 2> /dev/null` 2> /dev/null || true
endscript
}
5) You can now start the maillog_watcher
| Attachments: |
| File comment: maillog_watcher_read.sh file used to read the stats Downloaded 196 times |
| File comment: maillog_watcher source file Downloaded 209 times |
| File comment: maillog_watcher graph and data templates Downloaded 167 times |
1.首先找一下 com2sec notConfigUser default public 這一段,然後改成如下所示:(其中 10.16.25.25 是 SNMP server 的 IP address)
#com2sec notConfigUser default public2. 再來是找 group notConfigGroup v1 notConfigUser 這一段,然後改成如下所示:
com2sec local localhost public
com2sec mynetwork 10.16.25.25 public
#group notConfigGroup v1 notConfigUser3. 接著是找 view all included .1 80 這一段,然後改成如下所示:(把前面的 # 去掉)
#group notConfigGroup v2c notConfigUser
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork
## incl/excl subtree mask4. 找到 #access MyROGroup "" any noauth 0 all none none 這一段,改成如下所示:
view all included .1 80
#access MyROGroup "" any noauth 0 all none none5. 再找一下 syslocation Unknown (configure /etc/snmp/snmp.conf)這一段,改成如下所示:(其中 syslocation 用來告知你機器所在的位置)
#access MyRWGroup "" any noauth 0 all all all
access MyROGroup "" any noauth prefix all none none
access MyRWGroup "" any noauth prefix all all all
syslocation GangShan
syscontact Root (configure /etc/snmp/snmp.local.conf)
Code:pass .1.3.6.1.4.1.2021.255 /usr/local/bin/fetch_mail_statistics.pl /var/log/mail.log /var/log/mailstats.db .1.3.6.1.4.1.2021.255
type=AVC msg=audit(1430250421.774:158725): avc: denied { read } for pid=22972 comm="fetch_mail_stat" name="maillog" dev=dm-0 ino=1444277 scontext=unconfined_u:system_r:snmpd_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=fileHOW DO I FIX(SKIP) this security Deny?
type=SYSCALL msg=audit(1430250421.774:158725): arch=c000003e syscall=2 success=no exit=-13 a0=1813590 a1=0 a2=1b6 a3=7f65bb021d50 items=0 ppid=2219 pid=22972 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=21015 comm="fetch_mail_stat" exe="/usr/bin/perl" subj=unconfined_u:system_r:snmpd_t:s0 key=(null)
type=AVC msg=audit(1430250421.781:158726): avc: denied { read } for pid=22973 comm="fetch_mail_stat" name="maillog" dev=dm-0 ino=1444277 scontext=unconfined_u:system_r:snmpd_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=file
=================================================================================================
- The snmpd process only has access to files in /var/log labeled snmpd_log_t. The fix is to label the the file it needs to access correctly
- If its a single file then change the label on the file it needs to access. If its multiple files, then put these files in the /var/log/snmpd directory
# chcon -t snmpd_log_t /path/to/file
Process Types
SELinux defines process types (domains) for each process running on the system
You can see the context of a process using the -Z option to ps
Policy governs the access confined processes have to files. SELinux snmpd policy is very flexible allowing users to setup their snmpd processes in as secure a method as possible.
The following process types are defined for snmpd:
snmpd_t
Note: semanage permissive -a snmpd_t
can be used to make the process type snmpd_t permissive. Permissive process types are not denied access by SELinux. AVC messages will still be generated.
File Contexts
SELinux requires files to have an extended attribute to define the file type.
You can see the context of a file using the -Z option to ls
Policy governs the access confined processes have to these files. SELinux snmpd policy is very flexible allowing users to setup their snmpd processes in as secure a method as possible.
The following file types are defined for snmpd:
snmpd_exec_t
- Set files with the snmpd_exec_t type, if you want to transition an executable to the snmpd_t domain.
snmpd_initrc_exec_t
- Set files with the snmpd_initrc_exec_t type, if you want to transition an executable to the snmpd_initrc_t domain.
snmpd_log_t
- Set files with the snmpd_log_t type, if you want to treat the data as snmpd log data, usually stored under the /var/log directory.
snmpd_var_lib_t
- Set files with the snmpd_var_lib_t type, if you want to store the snmpd files under the /var/lib directory.
snmpd_var_run_t
- Set files with the snmpd_var_run_t type, if you want to store the snmpd files under the /run directory.
Note: File context can be temporarily modified with the chcon command. If you want to permanently change the file context you need to use the semanage fcontext command. This will modify the SELinux labeling database. You will need to use restorecon to apply the labels.