пятница, 16 апреля 2010 г.

LPI exam 102 prep: Shells, scripting, programming, and compiling

Краткие заметки, сделанные при подготовке к сдаче экзамена LPI 117-102 (Junior Level Linux Professional (LPIC-1)).

Shell customization

POSIX is the Portable Operating System Interface for uniX.
Well known shells include the Korn shell (ksh), the C shell (csh) and its derivative tcsh, the Almquist shell (ash) and its Debian derivative (dash).

Shells, including bash, allow you to create and modify shell
variables, which you may export to your environment for use by other processes
running in the shell or by other shells that you may spawn from the current shell.

Table 3. Common bash environment variables
Name Function
USER The name of the logged-in user
UID The numeric user id of the
logged-in user
HOME The user's home directory
PWD The current working directory
SHELL The name of the shell
$ The process id (or PID of the running Bash shell (or other) process)
PPID The process id of the process that started this process (that is, the id of the parent process)
? The exit code of the last command

When you create a shell variable, you will often want to export it to the environment
so it will be available to other processes that you start from this shell. Variables that
you export are not available to a parent shell.

In shells such as the C and tcsh shells, you use the set command to set variables in
your shell, and the setenv command to set and export variables. The syntax differs
slightly from that of the export command.

You remove a variable from the Bash shell using the unset command.

You can use
the -v option to be sure that you are removing a variable definition. Functions can
have the same name as variables, so use the -f if you want to remove a function
definition. Without either -f or -v, the bash unset command removes a variable
definition if it exists; otherwise, it removes a function definition if one exists.

If this shell is bash, then it executes several profile scripts before you get
control. If /etc/profile exists, it is executed first. Depending on your distribution, other
scripts in the /etc tree may also be executed, for example, /etc/bash.bashrc or
/etc/bashrc. Once the system scripts have run, a script in your home directory is run
if it exists. Bash looks for the files ~/.bash_profile, ~/.bash_login, and ~/.profile in that
order. The first one found is executed.

You may force bash to read profiles as if it were a login shell using the --login
option. If you do not want to execute the profiles for a login shell, specify the
--noprofile option. Similarly, if you want to disable execution of the ~/.bashrc file
for an interactive shell, start bash with the --norc option.

The Bash shell allows you to define aliases for commands.

You can also use the alias command to display all the aliases if you use it with no
options or with just the -p option, and you can display the aliases for one or more
names by giving the names as arguments without assignments. Listing 10 shows the
aliases for which and vi.

Sometimes called the "Swiss army knife" of the UNIX and Linux toolbox, sed is an
extremely powerful editing filter that uses regular expressions. You now understand
that the challenge is to strip off the first 8 words and the blanks that follow them from
every line of output that begins with 'd'. You can do it all with sed: select only those
lines you are interested in using the pattern-matching expression /^d/, substituting
a null string for the first eight words using the substitute command
s/^d\([^ ]* *\)\(8\}//. Use the -n option to print only lines that you specify
with the p command


Inside the function, you can refer to the parameters using the bash special variables
in Table 4. You prefix these with a $ symbol to reference them as with other shell
variables.

Shell parameters for functions

0, 1, 2, ... The positional parameters starting from
parameter 0. Parameter 0 refers to the
name of the program that started bash,
or the name of the shell script if the
function is running within a shell script.
See the bash man pages for
information on other possibilities, such
as when bash is started with the -c
parameter. A string enclosed in single
or double quotes will be passed as a
single parameter, and the quotes will
be stripped. In the case of double
quotes, any shell variables such as
$HOME will be expanded before the
function is called. You will need to use
single or double quotes to pass
parameters that contain embedded
blanks or other characters that might
have special meaning to the shell.

* The positional parameters starting from
parameter 1. If the expansion is done
within double quotes, then the
expansion is a single word with the first
character of the interfield separator
(IFS) special variable separating the
parameters or no intervening space if
IFS is null. The default IFS value is a
blank, tab, and newline. If IFS is unset,
then the separator used is a blank, just
as for the default IFS.

@ The positional parameters starting from
parameter 1. If the expansion is done
within double quotes, then each
parameter becomes a single word, so
that "$@" is equivalent to "$1" "$2" ....
If your parameters are likely to contain
embedded blanks, you will want to use
this form.

# The number of parameters, not
including parameter 0.

Shell scripts

test and [
The test builtin command returns 0 (True) or 1 (False) depending on the evaluation
of an expression expr. You can also use square brackets so that test expr and
[ expr ] are equivalent. You can examine the return value by displaying $?; you can
use the return value as you have before with && and ||; or you can test it using the
various conditional constructs that are covered later in this section.

(( and [[
The test command is very powerful, but somewhat unwieldy with its requirement
for escaping and the difference between string and arithmetic comparisons.
Fortunately bash has two other ways of testing that are somewhat more natural for
people who are familiar with C, C++, or Java syntax. The (( )) compound
command evaluates an arithmetic expression and sets the exit status to 1 if the
expression evaluates to 0, or to 0 if the expression evaluates to a non-zero value.
You do not need to escape operators between (( and )). Arithmetic is done on
integers. Division by 0 causes an error, but overflow does not. You may perform the
usual C language arithmetic, logical, and bitwise operations. The let command can
also execute one or more arithmetic expressions. It is usually used to assign values
to arithmetic variables.

If, then, else statements
The bash if command is a compound command that tests the return value of a test
or command ($? and branches based on whether it is True (0) or False (not 0).
Although the tests above returned only 0 or 1 values, commands may return other
values. You will learn more about testing those a little later in this tutorial. The if
command in bash has a then clause containing a list of commands to be executed
if the test or command returns 0. The command also has one or more optional elif
clauses. Each of these optional elif clauses has an additional test and then
clause with an associated list of commands, an optional final else clause, and list of
commands to be executed if neither the original test, nor any of the tests used in the
elif clauses was true. A terminal fi marks the end of the construct.

The Bash shell has a shopt builtin that allows you to set or unset many shell
options. One is nocasematch, which, if set, instructs the shell to ignore case in
string matching.

Loops
Bash and other shells have three looping constructs that are somewhat similar to
those in the C language. Each will execute a list of commands zero or more times.
The list of commands is surrounded by the words do and done, each preceded by a
semicolon.
for
loops come in two flavors. The most common form in shell scripting iterates
over a set of values, executing the command list once for each value. The set
may be empty, in which case the command list is not executed. The other form
is more like a traditional C for loop, using three arithmetic expressions to
control a starting condition, step function, and end condition.
while
loops evaluate a condition each time the loop starts and execute the command
list if the condition is true. If the condition is not initially true, the commands are
never executed.
until
loops execute the command list and evaluate a condition each time the loop
ends. If the condition is true the loop is executed again. Even if the condition is
not initially true, the commands are executed at least once.

четверг, 15 апреля 2010 г.

Система хранения данных с адресацией по содержимому EMC Centera

В заметке приведен краткий список преимуществ cистема хранения данных с адресацией по содержимому (content addressable storage) EMC Centera.

Надежность хранения

Есть механизмы по идентификации ошибок - дисков, узлов, файловой системы.
Есть механизмы для автоматической коррекции ошибок.
Есть два варианта защиты данных - зеркало и контроль четности.
Данные хранятся на двух разных узлах - в случае зеркала.
Защита с четностью бьет объект на 6 фрагментов и размещает их на 6 узлах. Четность хранится на 7 узле.
Имеется удвоенная внутренняя сеть.
В узлах по 2 блока питания.

Операционная система CentraStar обеспечивает надежность хранения и целостности файлов. Классы хранения, гарантированное уничтожение данных по окончании хранения.

Варианты поставки и функций: Basic, governance edition, compliance edition.

Репликация

star, chain (bidirectional).


Адресация

По получении в Centera о данных генерируется уникальный контентный адрес, он отсылается приложению, далее приложение хранит этот адрес и обращается к данным через него.
Центера хранит .xml content description file - там данные о файле, его адрес, комментарии, доп. инфо. Контентный адрес создается на пару - сам файл данных и файл с описанием хранимого файла. Это обеспечивает уникальность контентного адреса.

Простота администрирования

Самая низкая TCO на рынке.
Самоуправляемая, самоконфигурирования, самоисправляющаяся система.
1 PB на одного инженера. Есть java centera monitor. Centera view.

Характеристики

Один узел состоит из:
1 RU сервер, 1 ГБ RAM, P4, 4 шт. 1 или 2 ТБ дисков, 3 шт. 1 Gb Ethernet интерфейсов - 2 во внетреннюю сеть, 1 во внешнюю.
Узел может функционировать в режиме доступа, хранения или смешанном.

Базовый комплект состоит из 4 узлов при защите зеркалом или 8 узлов при защите контролем четности. Увеличение по 2 узла для зеркала или 8 для четности.
В шкафу 32 узла и 2 шт. 24-портовых коммутатора.

Centera xранит одну копию объекта (single instance storage).

Centera Universal Access - CUA - обеспечивает доступ к содержимому Centera для любых устройств, которые не поддерживают Centera API по протоколам nfs, xam (extensible access method), cifs. Ftp, http.

Xam - стандартизованное API для обращения к Centera (разработчики стандарта IBM и EMC )

Дисковые библиотеки EMC Data Domain

В заметке приведен краткий список преимуществ дисковых библиотек с дедупликацией Data Domain от компании EMC.

Cкорость

Данные размещаются на дисках уже дедуплицированными. Механизм дедупликации ЦПУ-ориентированный.

SISL - stream informed segment layout архитектура позволяет горизонтально масштабироваться при наращивании процессорной мощности устройств. 99% дуплицированных данных переменной длины определяются в RAM. Соотвествующие (связанные) фрагменты и их идентификаторы хранятся в одном месте что сокращает дисковые операции при их чтении и записи. Далее уникальные фрагменты сжимаются.

EMC закрыл линейку своих библиотек DL3D после покупки Data Domain.


Data Domain boost software - ПО переносит ряд процессов дедупликации на сервер резервного копирования. (symantec netbackup и backup exec + networker) повышает скорость записи данных на дисковую библиотеку на 50%.

Для библиотеки DD690 скорость записи - 2,7 ТБ/час (Symantec OpenStarage по 10 Гб Ethernet). DD880 - 5.4 ТБ/час, DD660 - 2.0 ТБ/час

Для библиотеки DD690
Raw capacity - до 48 ТБ(3 полки)
Logical capacity - 1-2 ПБ

Легкость интеграции

Эмулирует ленточную библиотеку - VTL. IBM Tivoli поддерживает DD. Поддерживаемые протоколы - Nfs cifs, open storage, vtl over fc.

Репликация

Благодаря передачи только дедуплицированных уникальных блоков возможна репликация между библиотеками по WAN каналам.

Механизм межсайтовой дедупликации - если один из сайтов передал дедуплицированные сегменты, другие при репликации их передавать уже не будут. Дополнительно сокращает объем передаваемых данных и время репликации.
Возможны локальная и кроссайтовая дедупликация.

Скорость репликации может достигать 27 ТБ по 10 Гб за 1 час. Возможны разные архитектуры.
Высвобождает до 99% пропускной способности по сравнению с обычной репликацией.

Емкость

Для долговременного хранения можно использовать ленту.

Дедупликация

Сокращает занимаемый объем данными в 10-30 раз

Надежность хранения

Происходит непрерывная верификация целостности данных во время записи данных и их дальнейшего хранения.
Raid-6 - защищает систему от сбоев 2 дисков подряд.
Данные хранятся на диске зашифрованными (aes-128 или aes-256).

суббота, 3 апреля 2010 г.

LPI exam 102 prep: Linux documentation

Краткие заметки, сделанные при подготовке к сдаче экзамена LPI 117-102 (Junior Level Linux Professional (LPIC-1)).

Local documentation

The primary (and traditional) source of documentation is the manual pages, which
you can access using the man command.

Man pages are displayed using a pager, which is usually the less command on
Linux systems.

The common manual sections, with some example contents
are:
1. User commands (env, ls, echo, mkdir, tty)
2. System calls or kernel functions (link, sethostname, mkdir)
3. Library routines (acosh, asctime, btree, locale, XML::Parser)
4. Device-related information (isdn_audio, mouse, tty, zero)
5. File format descriptions (keymaps, motd, wvdial.conf)
6. Games (note that many games are now graphical and have graphical
help outside the man page system)
7. Miscellaneous (arp, boot, regex, unix utf8)
8. System administration (debugfs, fdisk, fsck, mount, renice, rpm)

In addition to the standard manual pages, the Free Software Foundation has created
a number of info files that are processed with the info program.

your system may also have one or more graphical interfaces to manual
pages, such as xman (from the XFree86 Project) and yelp (the Gnome help
browser).

If you know that a topic occurs in a particular section, you can specify the section.
For example, man 4 tty or man 2 mkdir.

An alternative is to use the -a option to
display all applicable manual sections. If you specify -a, you will be prompted after
quitting the page for each section.

Use man less to find out more about / (search forwards), ? (search backwards), and n (repeat last search), among many other commands.

The info command comes from the makers of emacs, so the searching commands
are more like emacs commands. For example, ctrl-s searches forwards and
ctrl-r searches backwards using an incremental search. You can also move
around with the arrow keys, follow links (indicated with a star) using the Enter key,
and quit using q. Use the --vi-keys option with info if you'd prefer similar key
bindings to those used for man.

The whatis command searches man pages for the name you give and displays the name
information from the appropriate manual pages. The apropos command does a
keyword search of manual pages and lists ones containing your keyword

Manual pages may be in many locations on your system. You can determine the
current search path using the manpath command.

Depending on your system, configuration information for the man system is stored in
/etc/man.config or /etc/manpath.confg. Older systems use /etc/man.conf.

You may have noticed that the apropos and whatis commands ran quickly. This is
because they do not actually search the individual manual pages. Rather, they use a
database created by the makewhatis command. This is usually run by the system
either daily or weekly as a cron job.

If you wish to print the page, specify the -t option to format the page for printing
using the groff or troff program.

In addition to the manual pages and info pages that you have already seen, your
Linux system probably includes a lot more documentation. The customary place to
store this is in /usr/share/doc, or /usr/doc on older systems.

Internet documentation

HOWTOs
are subject-specific help, such as the Linux IPv6 HOWTO.
Guides
are longer, in-depth books, such as Introduction to Linux - A Hands on Guide.
FAQs
are Frequently Asked Questions, such as the Linux Documentation Project
(LDP) FAQ.
man pages
are help on individual commands, as you used in the previous section of this
tutorial.
Linux Gazette
is an online magazine, currently available in English, French, German,
Indonesian, Italian, Portuguese, Russian, and Spanish.

Notifying users

The first two of these, /etc/issue and /etc/issue.net, are displayed on an ASCII
terminal that is connected locally (/etc/issue) or remotely (/etc/issue.net).

Both /etc/issue and /etc/issue.net provide user feedback in the form of a logon
prompt and could also be used to advise users of issues such as impending
outages. However, this is usually done with a message of the day or motd, which is
stored in /etc/motd. The contents of /etc/motd are displayed after a successful login
but just before the login shell is started.

Изменение имени пользователя и сведений об организации после установки Windows XP

Иногда возникает необходимость поменять имя пользователя и название компании в ОС Windows уже после ее установки. Процедура довольно простая.

В меню Пуск выберите пункт Выполнить.
В поле Открыть введите команду regedit и нажмите кнопку OK.
Найдите следующий раздел реестра:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

Чтобы изменить название организации, выполните следующие действия.
В правой панели дважды щелкните параметр RegisteredOrganization. В поле Значение введите необходимое имя и нажмите кнопку OK.

Чтобы изменить имя зарегистрированного пользователя, выполните следующие действия.
В правой панели дважды щелкните параметр RegisteredOwner. В поле Значение введите необходимое имя и нажмите кнопку OK.

В меню Файл выберите команду Выход, чтобы закрыть окно редактора реестра.

Источник - http://support.microsoft.com/kb/310441/ru